This document covers openpilot's main user interface system, which provides a pyray (raylib) based graphical interface for both onroad driving and offroad settings management. The system handles rendering, device interaction, and state management across different UI modes.
For information about network and settings management, see Network and Settings Management. For details about the camera hardware layer, see Camera System.
The Main UI System encompasses:
gui_app singleton for window and rendering management openpilot/system/ui/lib/application.py196-254MouseState thread polling at 140Hz openpilot/system/ui/lib/application.py137-194MainLayout for comma 3/3X and MiciMainLayout for comma 4 hardware.ModelRenderer.SoftwareLayout openpilot/selfdrive/ui/layouts/settings/software.py51-80 and SoftwareInfoLayoutMici openpilot/selfdrive/ui/mici/layouts/settings/software.py36-74The UI runs at 60 FPS on TICI hardware and uses raylib for cross-platform graphics rendering openpilot/system/ui/lib/application.py25
The UI system operates as a pyray/raylib application that bridges openpilot's messaging system with user interaction. The architecture is built around a singleton GuiApplication instance that manages the rendering loop.
Sources: openpilot/system/ui/lib/application.py196-254 openpilot/selfdrive/ui/ui_state.py26-62 openpilot/selfdrive/ui/mici/onroad/model_renderer.py52-62 openpilot/selfdrive/ui/layouts/settings/software.py89-106
The GuiApplication class manages window initialization, the rendering generator loop, and input handling.
MouseState tracks up to 2 touch slots openpilot/system/ui/lib/application.py30 It polls rl.get_touch_position(slot) and generates MouseEvent objects openpilot/system/ui/lib/application.py176-194Sources: openpilot/system/ui/lib/application.py137-194
The ModelRenderer draws the predicted driving path, lane lines, and road edges projected from the model output into screen space.
modelV2 for path geometry and radarState for lead vehicle tracking openpilot/selfdrive/ui/mici/onroad/model_renderer.py121-124_car_space_transform openpilot/selfdrive/ui/onroad/model_renderer.py80-82LeadVehicle objects store glow and chevron data for rendering indicators over detected cars openpilot/selfdrive/ui/onroad/model_renderer.py39-42liveCalibration to adjust the _path_offset_z based on camera height openpilot/selfdrive/ui/onroad/model_renderer.py101| Component | Logic | File |
|---|---|---|
ModelPoints | Stores raw 3D and projected 2D points | openpilot/selfdrive/ui/onroad/model_renderer.py33-36 |
LeadVehicle | Manages glow/chevron rendering state | openpilot/selfdrive/ui/onroad/model_renderer.py39-42 |
_update_raw_points | Extracts position/lane data from modelV2 | openpilot/selfdrive/ui/mici/onroad/model_renderer.py149-161 |
_draw_path | Renders the driving path with gradients | openpilot/selfdrive/ui/onroad/model_renderer.py128 |
Sources: openpilot/selfdrive/ui/onroad/model_renderer.py45-132 openpilot/selfdrive/ui/mici/onroad/model_renderer.py52-148
The UI provides a comprehensive interface for managing system updates and software configuration.
SoftwareLayout monitors UpdaterState, UpdateAvailable, and UpdaterFetchAvailable params openpilot/selfdrive/ui/layouts/settings/software.py102-105SoftwareInfoLayoutMici splits the UpdaterCurrentDescription to display version, branch, commit, and date openpilot/selfdrive/ui/mici/layouts/settings/software.py21-27updated daemon via Unix signals: SIGUSR1 for checking and SIGHUP for downloading openpilot/selfdrive/ui/layouts/settings/software.py161-166Sources: openpilot/selfdrive/ui/layouts/settings/software.py51-166 openpilot/selfdrive/ui/mici/layouts/settings/software.py76-184
State management is centralized in the UIState and Device singletons.
UIState uses SubMaster to subscribe to core messages like carState, selfdriveState, and modelV2 openpilot/selfdrive/ui/ui_state.py37-62add_offroad_transition_callback to allow widgets to react when the car turns on/off openpilot/selfdrive/ui/mici/layouts/settings/software.py86-88