Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/commaai/openpilot/llms.txt

Use this file to discover all available pages before exploring further.

Simulation lets you run a full openpilot stack — controls, planning, and perception — without a physical car or comma device. openpilot uses the MetaDrive simulator via a bridge process that translates between openpilot’s internal message bus and the simulator’s API. This is useful for validating control logic changes, testing new features, and iterating quickly without any road time.

Prerequisites

The simulator requires the tools optional dependencies, which include the MetaDrive package. Install them into your virtual environment:
pip install -e ".[tools]"
MetaDrive is only available on x86_64 (AMD64) machines. It is not supported on ARM (aarch64), including Apple Silicon Macs running Linux in a VM.

Running the simulation

The simulation consists of two processes: the openpilot stack and the MetaDrive bridge. Start them in separate terminals.
1

Start openpilot

Launch the openpilot processes using the simulator launch script:
./tools/sim/launch_openpilot.sh
This starts all the openpilot daemons configured for simulator use.
2

Start the MetaDrive bridge

In a second terminal, start the bridge process. The bridge connects the MetaDrive simulator to openpilot’s message bus:
cd tools/sim
./run_bridge.py
A MetaDrive window will open showing a simulated driving environment.
3

Engage openpilot

With both processes running, use the keyboard controls in the MetaDrive window to interact with the simulation:
KeyAction
2Engage openpilot (also decreases cruise speed)
1Cruise resume / increase speed
3Cruise cancel
SDisengage (simulates a brake press)
rReset simulation
iToggle ignition
qExit all
w a s dManual vehicle control
Press 2 to engage openpilot, then 1 to increase the cruise speed.

Bridge options

The bridge supports several flags for different testing scenarios:
./run_bridge.py --help
FlagDescription
--joystickControl the simulated car with a physical joystick
--high_qualityEnable higher-quality rendering in MetaDrive
--dual_cameraEnable a second (wide) camera to simulate the comma three/four dual-camera setup
Example with dual camera and high quality:
./run_bridge.py --dual_camera --high_quality

Webcam mode

If you want to test openpilot’s vision pipeline with real camera input rather than a simulator, tools/webcam/ provides an alternative. Webcam mode runs openpilot using USB or built-in webcams on your PC as camera inputs — no comma device required.
Webcam mode is for development and testing only. Do not use webcam mode to operate a real car on public roads.

Tips for simulation development

  • Use the --high_quality flag when you need accurate visual inputs for testing the vision model.
  • Use --dual_camera if your code paths depend on the wide-angle camera stream.
  • Combine simulation with the replay tool to test against recorded real-world data alongside synthetic scenarios.
  • Run selfdrive/ui/ui.py alongside the simulation to see openpilot’s UI overlays in real time.

Build docs developers (and LLMs) love