Files
sunnypilot/tools/sim
YassineYousfi cad17b1255 modeld: parsing and publishing in python (#30273)
* WIP try modeld all in python

* fix plan

* add lane lines stds

* fix lane lines prob

* add lead prob

* add meta

* simplify plan parsing

* add hard brake pred

* add confidence

* fix desire state and desire pred

* check this file for now

* rm prints

* rm debug

* add todos

* add plan_t_idxs

* same as cpp

* removed cython

* add wfd width - rm cpp code

* add new files rm old files

* get metadata at compile time

* forgot this file

* now uses more CPU

* not used

* update readme

* lint

* copy this too

* simplify disengage probs

* update model replay ref commit

* update again

* confidence: remove if statemens

* use publish_state.enqueue

* Revert "use publish_state.enqueue"

This reverts commit d8807c8348338a1f773a8de00fd796abb8181404.

* confidence: better shape defs

* use ModelConstants class

* fix confidence

* Parser

* slightly more power too

* no inline ifs :(

* confidence: just use if statements
2023-10-19 14:23:51 -07:00
..
2022-04-22 18:00:49 +02:00
2023-10-02 16:11:56 -07:00

openpilot in simulator

openpilot implements a bridge that allows it to run in the MetaDrive simulator or CARLA simulator.

Launching openpilot

First, start openpilot.

# Run locally
./tools/sim/launch_openpilot.sh

Bridge usage

$ ./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]

Bridge between the simulator and openpilot.

options:
  -h, --help            show this help message and exit
  --joystick
  --high_quality
  --dual_camera
  --simulator SIMULATOR
  --town TOWN
  --spawn_point NUM_SELECTED_SPAWN_POINT
  --host HOST
  --port PORT

Bridge Controls:

  • To engage openpilot press 2, then press 1 to increase the speed and 2 to decrease.
  • To disengage, press "S" (simulates a user brake)

All inputs:

| key  |   functionality       |
|------|-----------------------|
|  1   | Cruise Resume / Accel |
|  2   | Cruise Set    / Decel |
|  3   | Cruise Cancel         |
|  r   | Reset Simulation      |
|  i   | Toggle Ignition       |
|  q   | Exit all              |
| wasd | Control manually      |

MetaDrive

Launching Metadrive

Start bridge processes located in tools/sim:

./run_bridge.py --simulator metadrive

Carla

CARLA is also partially supported, though the performance is not great. It needs to be manually installed with:

poetry install --with=carla

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.

You can also check out the CARLA python documentation to find more parameters to tune that might increase performance on your system.

Launching Carla

Start Carla simulator and bridge processes located in tools/sim:

# Terminal 1
./start_carla.sh

# Terminal 2
./run_bridge.py --simulator carla

Further Reading

The following resources contain more details and troubleshooting tips.