openpilot is a driver assistance system built around a continuously running perception-and-control loop. Raw camera frames flow into a neural network called supercombo, whose outputs feed a planning layer, which then drives longitudinal and lateral actuator commands sent to the car over the CAN bus. Every component communicates asynchronously through cereal, a Cap’n Proto–based IPC framework that serializes messages into a shared-memory message queue calledDocumentation 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.
msgq.
Vision pipeline
The core perceptual work happens inselfdrive/modeld/modeld.py. The model process (modeld) receives frames from the road-facing camera and wide-angle road camera via VisionIPC shared memory, runs them through the supercombo neural network, and publishes structured outputs on the modelV2 socket.
Supercombo is a single end-to-end network with two internally distinct subnetworks:
- Vision encoder — processes pairs of NV12 camera frames (two consecutive frames to encode motion) warped to a canonical input shape. Features are extracted into a 512-dimensional feature vector (
FEATURE_LEN = 512). - Driving policy — consumes the vision features plus recurrent state, desired behaviour signals (lane-change intent, traffic convention), and prior control state. It outputs a multi-hypothesis trajectory plan, lane-line and road-edge detections, lead-vehicle trajectories, FCW probabilities, and a desired curvature/acceleration action.
MODEL_RUN_FREQ = 20) while camera context is sampled at 5 Hz (MODEL_CONTEXT_FREQ = 5), giving the policy access to recent temporal context without running the full encoder every frame.
Control loop
Model outputs travel through a pipeline of processes that progressively refine intentions into low-level actuator commands.Camera frames captured
camerad continuously reads frames from the road-facing and wide-road cameras and publishes them into VisionIPC shared-memory buffers. The driver-facing camera stream is handled separately for driver monitoring.Neural network inference (modeld)
modeld dequeues the latest road-camera frames, warps them to the model’s input resolution, and runs supercombo inference. The modelV2 message is published containing the desired curvature, desired acceleration, lane lines, road edges, lead-vehicle predictions, and FCW output.Longitudinal planning (plannerd)
plannerd subscribes to modelV2 and radarState. It combines the model’s desired acceleration with radar-derived lead-vehicle data to produce a safe longitudinal plan, including a target acceleration (aTarget) and stop flag. The result is published as longitudinalPlan.State management (selfdrived)
selfdrived runs at 100 Hz and acts as the system supervisor. It monitors engagement state, driver monitoring alerts, panda safety model consistency, excessive actuation checks, and hardware health. It publishes selfdriveState (enabled/active flags and alert metadata) and onroadEvents.Low-level control (controlsd)
controlsd subscribes to selfdriveState, modelV2, longitudinalPlan, and carState. It runs the lateral controller (PID, torque, or angle depending on the car) against the model’s desired curvature and the longitudinal PID against plannerd’s acceleration target. The combined actuator commands are published as carControl.CAN output (card / panda)
The car-specific driver (
card) translates carControl into CAN messages for the vehicle’s ADAS ECUs. These messages are transmitted over USB to the panda hardware interface, which places them on the vehicle’s CAN bus. Panda enforces independent hardware-level safety limits before any message is sent.Driver monitoring
Parallel to the driving pipeline,dmonitoringmodeld processes frames from the driver-facing camera to estimate driver attention. It publishes driverMonitoringState, which selfdrived reads to issue distraction alerts or trigger disengagement lockout if the driver is persistently unresponsive. Driver monitoring is a required safety feature and cannot be disabled.
Inter-process messaging with cereal
All processes communicate exclusively through cereal sockets backed bymsgq. Cereal uses Cap’n Proto schemas (defined in the cereal repository) to define strongly typed message structures for every signal—carState, modelV2, longitudinalPlan, carControl, and many others. Processes declare their publish and subscribe sockets at startup; SubMaster and PubMaster handle serialization, frequency checks, and liveness monitoring automatically.
openpilot ACC vs. stock ACC
openpilot replaces—rather than supplements—the car’s stock Lane Keep Assist and Automated Lane Centering. On supported cars, it also replaces the stock Adaptive Cruise Control. The key difference is the source of the control signal:| Feature | Stock system | openpilot |
|---|---|---|
| Lane centering | Rule-based, camera-only | Supercombo neural network |
| Adaptive cruise | Radar-only, fixed-gap logic | Model + radar fusion, learned behaviour |
| Following distance | Fixed tiers | Continuous, personality-adjustable |
| FCW | Stock system active | openpilot FCW runs in addition to stock |
