The navigation system in openpilot provides real-time route calculation, turn-by-turn instructions, and high-fidelity map rendering. It is designed to integrate deeply with the driving experience, providing data to the longitudinal planner for proactive speed adjustments and displaying a customized map interface optimized for driver assistance.
The navigation stack consists of several decoupled components communicating via the cereal messaging system. The primary daemon, navd, handles the heavy lifting of routing and instruction generation, while the UI process manages the visual representation using MapLibre.
The following diagram illustrates the flow of navigation data from user input to vehicle control.
Navigation Data Flow
Sources: selfdrive/navd/, selfdrive/ui/, selfdrive/locationd/.
The navd process is responsible for the lifecycle of a navigation session. It monitors the navRoute cereal message for new destination requests and utilizes external APIs (typically Mapbox) to fetch route geometries and maneuvers.
navd fetches a detailed polyline and a list of steps (turns, exits, etc.).navInstruction messages, which include distance to the next turn, turn type (left, right, slight, etc.), and street names.LiveLocationKalman from locationd, navd tracks the vehicle's progress along the route to trigger instruction updates and rerouting if the vehicle deviates from the path.The openpilot UI utilizes MapLibre (an open-source fork of Mapbox GL JS/Native) to render vector maps. The renderer is customized to match the openpilot aesthetic, featuring a dark theme and high-contrast route lines.
The navigation view is integrated into the MainLayout. When the system is started and in the ONROAD state, the UI transitions to the AugmentedRoadView, which acts as the container for the 3D road model and HUD elements.
Entity Mapping: UI to Code
Navigation data and driving state influence the longitudinal planning stack. The plannerd daemon runs the LongitudinalPlanner to determine the vehicle's speed profile openpilot/selfdrive/controls/plannerd.py20-29
The LongitudinalPlanner class processes inputs from the driving model and radar to calculate target accelerations openpilot/selfdrive/controls/lib/longitudinal_planner.py48-65
experimentalMode is enabled, the planner incorporates "End-to-End" (e2e) outputs from modelV2, specifically desiredAcceleration and shouldStop predictions openpilot/selfdrive/controls/lib/longitudinal_planner.py133-140 In this mode, if the e2e acceleration is lower than the MPC-calculated acceleration, the system attributes the source to LongitudinalPlanSource.e2e openpilot/selfdrive/controls/lib/longitudinal_planner.py137-140limit_accel_in_turns openpilot/selfdrive/controls/lib/longitudinal_planner.py34-45 This ensures comfort when the vehicle is in a turn by calculating a_x_allowed relative to v_ego and steeringAngleDeg openpilot/selfdrive/controls/lib/longitudinal_planner.py89-90LongitudinalMpc solver handles distance to obstacles and target cruise speeds openpilot/selfdrive/controls/lib/longitudinal_planner.py112-114 It utilizes different personality settings (Aggressive, Standard, Relaxed) to adjust the planning behavior openpilot/selfdrive/controls/lib/longitudinal_planner.py112-114accel_coast, which influences the acceleration limits when the driver is not pressing the throttle openpilot/selfdrive/controls/lib/longitudinal_planner.py31-32 openpilot/selfdrive/controls/lib/longitudinal_planner.py67-70Entity Mapping: Planning Logic
Sources: openpilot/selfdrive/controls/lib/longitudinal_planner.py48-157 openpilot/selfdrive/controls/plannerd.py20-29
The UI and navigation system adapt to specific hardware platforms and user preferences managed through the Params system openpilot/selfdrive/selfdrived/selfdrived.py50-52
The selfdrived daemon and UI monitor several parameters that affect navigation and planning:
LongitudinalPersonality parameter determines the MPC's behavior profile openpilot/selfdrive/selfdrived/selfdrived.py124IsMetric parameter determines if speed and distance are rendered in km/h or mph openpilot/selfdrive/selfdrived/selfdrived.py96ExperimentalMode parameter enables features like e2e longitudinal control, allowing the model to react to traffic lights and stop signs openpilot/selfdrive/controls/lib/longitudinal_planner.py136-140The selfdrived process manages the transition between initialization and active navigation states. It tracks if the car is recognized and if longitudinal control is available openpilot/selfdrive/selfdrived/selfdrived.py100-107
| Setting | Parameter Key | Description |
|---|---|---|
| Metric System | IsMetric | Toggle between Metric and Imperial units openpilot/selfdrive/selfdrived/selfdrived.py96 |
| Experimental Mode | ExperimentalMode | Enables E2E longitudinal and vision-based stopping openpilot/selfdrive/controls/lib/longitudinal_planner.py136-140 |
| Personality | LongitudinalPersonality | Sets the MPC profile (Aggressive, Standard, Relaxed) openpilot/selfdrive/selfdrived/selfdrived.py124 |
| LDW | IsLdwEnabled | Enables Lane Departure Warnings via plannerd openpilot/selfdrive/selfdrived/selfdrived.py97 openpilot/selfdrive/controls/plannerd.py19 |
Sources: openpilot/selfdrive/selfdrived/selfdrived.py50-140 openpilot/selfdrive/controls/lib/longitudinal_planner.py136-140 openpilot/selfdrive/controls/plannerd.py19-36
Refresh this wiki