# cwal1220/edgepilot architecture

> Architecture diagram of the GitHub repository cwal1220/edgepilot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cwal1220/edgepilot
- Repository: https://github.com/cwal1220/edgepilot

## Overview

edgepilot is embedded openpilot perception and lateral-control software for the MaixCAM2, integrated with a Hyundai K7 and Panda USB/CAN interface. The main path runs from camera capture through model inference and lateral planning/control to Panda and vehicle steering; localization supplies state, while the HUD and recorder consume runtime data. Separate branches provide web tuning and replay. The README documents process-level data paths; sampled source confirms selected internals, but many runtime processes and integrations were not inspected directly.

Main entry points: [`src/common/ipc_messages.h`](https://github.com/cwal1220/edgepilot/blob/main/src/common/ipc_messages.h) (Shared State IPC), [`src/controls/lateral_controller.cc`](https://github.com/cwal1220/edgepilot/blob/main/src/controls/lateral_controller.cc) (Lateral Control), [`scripts/manager.py`](https://github.com/cwal1220/edgepilot/blob/main/scripts/manager.py) (Process Manager), [`platform/maixcam2/maix_cmm.cc`](https://github.com/cwal1220/edgepilot/blob/main/platform/maixcam2/maix_cmm.cc) (CMM Frame Ring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Vision"]
  node_camerad["Camera Capture<br/>[camerad.cc]"]
  node_frame_ring[("CMM Frame Ring<br/>[maix_cmm.cc]")]
  node_modeld["Model Runtime<br/>[modeld.cc]"]
  node_ax_session["NPU Session"]
end

subgraph group_state_control["State and Control"]
  node_ipc["Shared State IPC<br/>[ipc_messages.h]"]
  node_locationd["Localization"]
  node_planner["Lateral Planner<br/>[lateral_planner.cc]"]
  node_controlsd["Lateral Control"]
  node_learners["Online Learners"]
end

subgraph group_vehicle_interface["Vehicle Interface"]
  node_vehicle_can["Vehicle CAN<br/>[vehicle_can.cc]"]
  node_hyundai_can["Hyundai Messages<br/>[hyundai_can.cc]"]
  node_pandad["Panda Daemon<br/>[pandad.cc]"]
  node_panda_client["Panda USB Client<br/>[panda_client.cc]"]
  node_panda_firmware["Panda Safety Firmware<br/>[main.c]"]
end

subgraph group_runtime_views["Runtime and Views"]
  node_overlayd["HUD Renderer<br/>[overlayd.cc]"]
  node_recordd["Drive Recorder<br/>[recordd.cc]"]
  node_recordings[("Drive Recordings")]
  node_manager["Process Manager<br/>[manager.py]"]
end

subgraph group_tuning_replay["Tuning and Replay"]
  node_web_console["Web Console"]
  node_replayd["Replay Runtime<br/>[replayd.cc]"]
  node_recording_reader["Recording Reader"]
end

node_driver(("Driver"))
node_camera["Camera"]
node_car["Hyundai K7"]
node_display["LCD Display"]

node_camera -->|"provides frames"| node_camerad
node_camerad -->|"writes frames"| node_frame_ring
node_frame_ring -->|"feeds views"| node_modeld
node_modeld -->|"runs inference"| node_ax_session
node_modeld -->|"publishes model state"| node_ipc
node_ipc -->|"supplies state"| node_locationd
node_ipc -->|"supplies model state"| node_planner
node_planner -->|"publishes plan"| node_ipc
node_ipc -->|"supplies runtime state"| node_controlsd
node_learners -->|"provides estimates"| node_controlsd
node_controlsd -->|"builds steering frames"| node_hyundai_can
node_vehicle_can -->|"publishes vehicle state"| node_ipc
node_pandad -->|"uses USB client"| node_panda_client
node_pandad -->|"publishes Panda state"| node_ipc
node_controlsd -->|"publishes control state"| node_ipc
node_pandad -->|"communicates over USB"| node_panda_firmware
node_panda_firmware -->|"safety-gated CAN"| node_car
node_hyundai_can -->|"sends CAN commands"| node_pandad
node_car -->|"sends CAN signals"| node_vehicle_can
node_frame_ring -->|"scales preview"| node_overlayd
node_ipc -->|"supplies HUD state"| node_overlayd
node_overlayd -->|"draws overlay"| node_display
node_frame_ring -->|"copies video"| node_recordd
node_ipc -->|"logs runtime states"| node_recordd
node_recordd -->|"writes recordings"| node_recordings
node_manager -->|"starts process"| node_camerad
node_manager -->|"starts process"| node_modeld
node_manager -->|"starts process"| node_controlsd
node_manager -->|"starts process"| node_overlayd
node_manager -->|"starts process"| node_recordd
node_web_console -->|"updates parameters"| node_controlsd
node_recordings -.->|"provides replay data"| node_replayd
node_recordings -->|"reads recordings"| node_recording_reader

click node_camerad "https://github.com/cwal1220/edgepilot/blob/main/src/camera/camerad.cc"
click node_frame_ring "https://github.com/cwal1220/edgepilot/blob/main/platform/maixcam2/maix_cmm.cc"
click node_modeld "https://github.com/cwal1220/edgepilot/blob/main/src/model/modeld.cc"
click node_ax_session "https://github.com/cwal1220/edgepilot/blob/main/src/model/ax_engine_session.cc"
click node_ipc "https://github.com/cwal1220/edgepilot/blob/main/src/common/ipc_messages.h"
click node_locationd "https://github.com/cwal1220/edgepilot/blob/main/src/localization/localization_pipeline.cc"
click node_planner "https://github.com/cwal1220/edgepilot/blob/main/src/planning/lateral_planner.cc"
click node_controlsd "https://github.com/cwal1220/edgepilot/blob/main/src/controls/lateral_controller.cc"
click node_learners "https://github.com/cwal1220/edgepilot/blob/main/src/learners/lateral_learners.cc"
click node_vehicle_can "https://github.com/cwal1220/edgepilot/blob/main/src/car/vehicle_can.cc"
click node_hyundai_can "https://github.com/cwal1220/edgepilot/blob/main/src/car/hyundai_can.cc"
click node_pandad "https://github.com/cwal1220/edgepilot/blob/main/src/panda/pandad.cc"
click node_panda_client "https://github.com/cwal1220/edgepilot/blob/main/src/panda/panda_client.cc"
click node_panda_firmware "https://github.com/cwal1220/edgepilot/blob/main/firmware/panda/board/main.c"
click node_overlayd "https://github.com/cwal1220/edgepilot/blob/main/src/hud/overlayd.cc"
click node_recordd "https://github.com/cwal1220/edgepilot/blob/main/src/recording/recordd.cc"
click node_recordings "https://github.com/cwal1220/edgepilot/blob/main/src/recording/recording_writer.cc"
click node_manager "https://github.com/cwal1220/edgepilot/blob/main/scripts/manager.py"
click node_web_console "https://github.com/cwal1220/edgepilot/tree/main/scripts/web_console"
click node_replayd "https://github.com/cwal1220/edgepilot/blob/main/src/recording/replayd.cc"
click node_recording_reader "https://github.com/cwal1220/edgepilot/blob/main/tools/model/recording_reader.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_camerad,node_frame_ring,node_modeld,node_ax_session toneBlue
class node_ipc,node_locationd,node_planner,node_controlsd,node_learners toneAmber
class node_vehicle_can,node_hyundai_can,node_pandad,node_panda_client,node_panda_firmware toneMint
class node_overlayd,node_recordd,node_recordings,node_manager toneRose
class node_web_console,node_replayd,node_recording_reader,node_driver,node_camera,node_car,node_display toneIndigo
```

## Components

### Vision

- [Camera Capture](https://github.com/cwal1220/edgepilot/blob/main/src/camera/camerad.cc): `src/camera/camerad.cc`
- [CMM Frame Ring](https://github.com/cwal1220/edgepilot/blob/main/platform/maixcam2/maix_cmm.cc): `platform/maixcam2/maix_cmm.cc`
- [Model Runtime](https://github.com/cwal1220/edgepilot/blob/main/src/model/modeld.cc): `src/model/modeld.cc`
- [NPU Session](https://github.com/cwal1220/edgepilot/blob/main/src/model/ax_engine_session.cc): `src/model/ax_engine_session.cc`

### State and Control

- [Shared State IPC](https://github.com/cwal1220/edgepilot/blob/main/src/common/ipc_messages.h): `src/common/ipc_messages.h`
- [Localization](https://github.com/cwal1220/edgepilot/blob/main/src/localization/localization_pipeline.cc): `src/localization/localization_pipeline.cc`
- [Lateral Planner](https://github.com/cwal1220/edgepilot/blob/main/src/planning/lateral_planner.cc): `src/planning/lateral_planner.cc`
- [Lateral Control](https://github.com/cwal1220/edgepilot/blob/main/src/controls/lateral_controller.cc): `src/controls/lateral_controller.cc`
- [Online Learners](https://github.com/cwal1220/edgepilot/blob/main/src/learners/lateral_learners.cc): `src/learners/lateral_learners.cc`

### Vehicle Interface

- [Vehicle CAN](https://github.com/cwal1220/edgepilot/blob/main/src/car/vehicle_can.cc): `src/car/vehicle_can.cc`
- [Hyundai Messages](https://github.com/cwal1220/edgepilot/blob/main/src/car/hyundai_can.cc): `src/car/hyundai_can.cc`
- [Panda Daemon](https://github.com/cwal1220/edgepilot/blob/main/src/panda/pandad.cc): `src/panda/pandad.cc`
- [Panda USB Client](https://github.com/cwal1220/edgepilot/blob/main/src/panda/panda_client.cc): `src/panda/panda_client.cc`
- [Panda Safety Firmware](https://github.com/cwal1220/edgepilot/blob/main/firmware/panda/board/main.c): `firmware/panda/board/main.c`

### Runtime and Views

- [HUD Renderer](https://github.com/cwal1220/edgepilot/blob/main/src/hud/overlayd.cc): `src/hud/overlayd.cc`
- [Drive Recorder](https://github.com/cwal1220/edgepilot/blob/main/src/recording/recordd.cc): `src/recording/recordd.cc`
- [Drive Recordings](https://github.com/cwal1220/edgepilot/blob/main/src/recording/recording_writer.cc): `src/recording/recording_writer.cc`
- [Process Manager](https://github.com/cwal1220/edgepilot/blob/main/scripts/manager.py): `scripts/manager.py`

### Tuning and Replay

- [Web Console](https://github.com/cwal1220/edgepilot/tree/main/scripts/web_console): `scripts/web_console`
- [Replay Runtime](https://github.com/cwal1220/edgepilot/blob/main/src/recording/replayd.cc): `src/recording/replayd.cc`
- [Recording Reader](https://github.com/cwal1220/edgepilot/blob/main/tools/model/recording_reader.py): `tools/model/recording_reader.py`

### Other components

- **Driver**
- **Camera**
- **Hyundai K7**
- **LCD Display**

## Connections

- Camera → Camera Capture: provides frames (evidence: `README.md`)
- Camera Capture → CMM Frame Ring: writes frames (evidence: `README.md`)
- CMM Frame Ring → Model Runtime: feeds views (evidence: `README.md`)
- Model Runtime → NPU Session: runs inference (evidence: `README.md`)
- Model Runtime → Shared State IPC: publishes model state (evidence: `README.md`)
- Shared State IPC → Localization: supplies state
- Shared State IPC → Lateral Planner: supplies model state (evidence: `src/planning/lateral_planner.cc`)
- Lateral Planner → Shared State IPC: publishes plan (evidence: `README.md`)
- Shared State IPC → Lateral Control: supplies runtime state (evidence: `README.md`)
- Online Learners → Lateral Control: provides estimates
- Lateral Control → Hyundai Messages: builds steering frames
- Vehicle CAN → Shared State IPC: publishes vehicle state (evidence: `README.md`)
- Panda Daemon → Panda USB Client: uses USB client (evidence: `src/panda/panda_client.cc`)
- Panda Daemon → Shared State IPC: publishes Panda state (evidence: `README.md`)
- Lateral Control → Shared State IPC: publishes control state (evidence: `README.md`)
- Panda Daemon → Panda Safety Firmware: communicates over USB (evidence: `README.md`)
- Panda Safety Firmware → Hyundai K7: safety-gated CAN (evidence: `README.md`)
- Hyundai Messages → Panda Daemon: sends CAN commands (evidence: `README.md`)
- Hyundai K7 → Vehicle CAN: sends CAN signals (evidence: `README.md`)
- CMM Frame Ring → HUD Renderer: scales preview (evidence: `README.md`)
- Shared State IPC → HUD Renderer: supplies HUD state (evidence: `README.md`)
- HUD Renderer → LCD Display: draws overlay (evidence: `README.md`)
- CMM Frame Ring → Drive Recorder: copies video (evidence: `README.md`)
- Shared State IPC → Drive Recorder: logs runtime states (evidence: `README.md`)
- Drive Recorder → Drive Recordings: writes recordings (evidence: `README.md`)
- Process Manager → Camera Capture: starts process (evidence: `README.md`)
- Process Manager → Model Runtime: starts process (evidence: `README.md`)
- Process Manager → Lateral Control: starts process (evidence: `README.md`)
- Process Manager → HUD Renderer: starts process (evidence: `README.md`)
- Process Manager → Drive Recorder: starts process (evidence: `README.md`)
- Web Console → Lateral Control: updates parameters (evidence: `README.md`)
- Drive Recordings → Replay Runtime: provides replay data (evidence: `README.md`)
- Drive Recordings → Recording Reader: reads recordings (evidence: `tools/model/recording_reader.py`)
