Simulator: update documentation for metadrive (#30002)

* update sim docs

* update docs
old-commit-hash: 84609f365b
laptop
Justin Newberry 2 years ago committed by GitHub
parent 3cd9856fcc
commit dc0babfae4
  1. 98
      tools/sim/README.md
  2. 18
      tools/sim/lib/keyboard_ctrl.py
  3. 2
      tools/sim/run_bridge.py
  4. 2
      tools/sim/tmux_script.sh

@ -1,58 +1,76 @@
openpilot in simulator openpilot in simulator
===================== =====================
openpilot implements a [bridge](bridge.py) that allows it to run in the [CARLA simulator](https://carla.org/). openpilot implements a [bridge](run_bridge.py) that allows it to run in the [MetaDrive simulator](https://github.com/metadriverse/metadrive) or [CARLA simulator](https://carla.org/).
## System Requirements ## Launching openpilot
First, start openpilot.
``` bash
# Run locally
./tools/sim/launch_openpilot.sh
```
openpilot doesn't have any extreme hardware requirements, however CARLA requires an NVIDIA graphics card and is very resource-intensive and may not run smoothly on your system. ## Bridge usage
For this case, we have the simulator in low quality by default. ```
$ ./run_bridge.py -h
usage: run_bridge.py [-h] [--joystick] [--high_quality] [--dual_camera] [--simulator SIMULATOR] [--town TOWN] [--spawn_point NUM_SELECTED_SPAWN_POINT] [--host HOST] [--port PORT]
You can also check out the [CARLA python documentation](https://carla.readthedocs.io/en/latest/python_api/) to find more parameters to tune that might increase performance on your system. Bridge between the simulator and openpilot.
## Running the simulator options:
Start Carla simulator, openpilot and bridge processes located in tools/sim: -h, --help show this help message and exit
``` bash --joystick
# Terminal 1 --high_quality
./start_carla.sh --dual_camera
--simulator SIMULATOR
--town TOWN
--spawn_point NUM_SELECTED_SPAWN_POINT
--host HOST
--port PORT
```
# Terminal 2 - Run openpilot and bridge in one Docker: #### Bridge Controls:
./start_openpilot_docker.sh - To engage openpilot press 2, then press 1 to increase the speed and 2 to decrease.
- To disengage, press "S" (simulates a user brake)
# Running the latest local code execute #### All inputs:
# Terminal 2:
./launch_openpilot.sh
# Terminal 3
./bridge.py
```
### Bridge usage
_Same commands hold for start_openpilot_docker_
``` ```
$ ./bridge.py -h | key | functionality |
Usage: bridge.py [options] |------|-----------------------|
Bridge between CARLA and openpilot. | 1 | Cruise Resume / Accel |
| 2 | Cruise Set / Decel |
| 3 | Cruise Cancel |
| r | Reset Simulation |
| i | Toggle Ignition |
| q | Exit all |
| wasd | Control manually |
```
Options: ## MetaDrive
-h, --help show this help message and exit
--joystick Use joystick input to control the car ### Launching Metadrive
--high_quality Set simulator to higher quality (requires good GPU) Start bridge processes located in tools/sim:
--town TOWN Select map to drive in ``` bash
--spawn_point NUM Number of the spawn point to start in ./run_bridge.py --simulator metadrive
--host HOST Host address of Carla client (127.0.0.1 as default)
--port PORT Port of Carla client (2000 as default)
``` ```
To engage openpilot press 1 a few times while focused on bridge.py to increase the cruise speed. ## Carla
All inputs:
| key | functionality | openpilot doesn't have any extreme hardware requirements, however CARLA requires an NVIDIA graphics card and is very resource-intensive and may not run smoothly on your system.
|:----:|:-----------------:| For this case, we have the simulator in low quality by default.
| 1 | Cruise up 1 mph |
| 2 | Cruise down 1 mph | You can also check out the [CARLA python documentation](https://carla.readthedocs.io/en/latest/python_api/) to find more parameters to tune that might increase performance on your system.
| 3 | Cruise cancel |
| q | Exit all | ### Launching Carla
| wasd | Control manually | Start Carla simulator and bridge processes located in tools/sim:
``` bash
# Terminal 1
./start_carla.sh
# Terminal 2
./run_bridge.py --simulator carla
```
## Further Reading ## Further Reading

@ -19,15 +19,15 @@ STDIN_FD = sys.stdin.fileno()
KEYBOARD_HELP = """ KEYBOARD_HELP = """
| key | functionality | | key | functionality |
----------------------------- |------|-----------------------|
| 1 | Cruise Resume | | 1 | Cruise Resume / Accel |
| 2 | Cruise Set | | 2 | Cruise Set / Decel |
| 3 | Cruise Cancel | | 3 | Cruise Cancel |
| r | Reset Simulation | | r | Reset Simulation |
| i | Toggle Ignition | | i | Toggle Ignition |
| q | Exit all | | q | Exit all |
| wasd | Control manually | | wasd | Control manually |
""" """

@ -11,7 +11,7 @@ from openpilot.tools.sim.bridge.metadrive.metadrive_bridge import MetaDriveBridg
def parse_args(add_args=None): def parse_args(add_args=None):
parser = argparse.ArgumentParser(description='Bridge between CARLA and openpilot.') parser = argparse.ArgumentParser(description='Bridge between the simulator and openpilot.')
parser.add_argument('--joystick', action='store_true') parser.add_argument('--joystick', action='store_true')
parser.add_argument('--high_quality', action='store_true') parser.add_argument('--high_quality', action='store_true')
parser.add_argument('--dual_camera', action='store_true') parser.add_argument('--dual_camera', action='store_true')

@ -2,5 +2,5 @@
tmux new -d -s carla-sim tmux new -d -s carla-sim
tmux send-keys "./launch_openpilot.sh" ENTER tmux send-keys "./launch_openpilot.sh" ENTER
tmux neww tmux neww
tmux send-keys "./bridge.py $*" ENTER tmux send-keys "./run_bridge.py $*" ENTER
tmux a -t carla-sim tmux a -t carla-sim

Loading…
Cancel
Save