feat: dashcamd trip lifecycle, status indicator, CLAUDE.md updates
dashcamd now waits for valid system time + GPS fix + drive gear before starting a trip. Returns to waiting state on 10-min park timeout or ignition off. Publishes DashcamState and per-trip DashcamFrames to memory params. Status window shows stopped/waiting/recording states. Updated CLAUDE.md with current display mode behavior, OmxEncoder port details, speed limit warning thresholds, and dashcam param docs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
44
CLAUDE.md
44
CLAUDE.md
@@ -15,7 +15,7 @@ ClearPilot is a custom fork of **FrogPilot** (itself a fork of comma.ai's openpi
|
||||
- **Native dashcamd**: C++ process capturing raw camera frames via VisionIPC with OMX H.264 hardware encoding
|
||||
- **Standstill power saving**: model inference throttled to 1fps and fan quieted when car is stopped
|
||||
- **ClearPilot menu**: sidebar settings panel replacing stock home screen (Home, Dashcam, Debug panels)
|
||||
- **Status window**: live system stats (temp, fan, storage, RAM, WiFi, VPN, GPS, telemetry status)
|
||||
- **Status window**: live system stats (temp, fan, storage, RAM, WiFi, VPN, GPS, telemetry, dashcam status)
|
||||
- **Debug button (LFA)**: steering wheel button repurposed for screen toggle and future UI actions
|
||||
- **Telemetry system**: diff-based CSV logger via ZMQ IPC, toggleable from Debug panel
|
||||
- **Bench mode**: `--bench` flag for onroad UI testing without car connected
|
||||
@@ -101,7 +101,7 @@ ClearPilot uses memory params (`/dev/shm/params/d/`) for UI toggles that should
|
||||
- **Python access**: Use `Params("/dev/shm/params")`
|
||||
- **Defaults**: Set in `manager_init()` via `Params("/dev/shm/params").put(key, value)`
|
||||
- **UI toggles**: Use `ToggleControl` with manual `toggleFlipped` lambda that writes via `Params("/dev/shm/params")`. Do NOT use `ParamControl` for memory params — it reads/writes persistent params only
|
||||
- **Current memory params**: `TelemetryEnabled` (default "0"), `VpnEnabled` (default "1"), `ModelStandby` (default "0"), `ScreenDisplayMode`
|
||||
- **Current memory params**: `TelemetryEnabled` (default "0"), `VpnEnabled` (default "1"), `ModelStandby` (default "0"), `ScreenDisplayMode`, `DashcamState` (default "stopped"), `DashcamFrames` (default "0")
|
||||
- **IMPORTANT — method names differ between C++ and Python**: C++ uses camelCase (`putBool`, `getBool`, `getInt`), Python uses snake_case (`put_bool`, `get_bool`, `get_int`). This is a common source of silent failures — the wrong casing compiles/runs but doesn't work.
|
||||
|
||||
### Building Native (C++) Processes
|
||||
@@ -245,20 +245,21 @@ A single `session.log` in each session directory records major events:
|
||||
- **Segment length**: 3 minutes per file
|
||||
- **Save path**: `/data/media/0/videos/YYYYMMDD-HHMMSS/YYYYMMDD-HHMMSS.mp4` (trip directories)
|
||||
- **GPS subtitles**: companion `.srt` file per segment with 1Hz entries (speed MPH, lat/lon, UTC timestamp)
|
||||
- **Trip lifecycle**: starts recording on launch with 10-min idle timer; car in drive cancels timer; park/off restarts timer; ignition cycle = new trip
|
||||
- **Trip lifecycle**: waits in WAITING state until valid system time + GPS fix + car in drive; records until car parked 10 min or ignition off; then returns to WAITING
|
||||
- **Graceful shutdown**: thermald sets `DashcamShutdown` param, dashcamd closes segment and acks within 15s
|
||||
- **Storage**: ~56 MB per 3-minute segment at 2500 kbps
|
||||
- **Storage**: ~56 MB per 3-minute segment at 2500 kbps (verified: actual bitrate ~2570 kbps)
|
||||
- **Crash handler**: SIGSEGV/SIGABRT handler writes backtrace to `/tmp/dashcamd_crash.log`
|
||||
- **Storage device**: WDC SDINDDH4-128G UFS 2.1 — automotive grade, ~384 TB write endurance, no concern for continuous writes
|
||||
|
||||
### Key Differences from Old Screen Recorder
|
||||
### OmxEncoder
|
||||
|
||||
| | Old (screen recorder) | New (dashcamd) |
|
||||
|---|---|---|
|
||||
| Source | `QWidget::grab()` screen capture | Raw NV12 from VisionIPC |
|
||||
| Resolution | 1440x720 | 1928x1208 |
|
||||
| Works with screen off | No (needs visible widget) | Yes (independent of UI) |
|
||||
| Process type | Part of UI process | Standalone native process |
|
||||
| Encoder input | RGBA -> NV12 conversion | NV12 direct (added `encode_frame_nv12`) |
|
||||
The OMX encoder (`selfdrive/frogpilot/screenrecorder/omx_encoder.cc`) was ported from upstream FrogPilot with the following key properties:
|
||||
|
||||
- Each encoder instance calls `OMX_Init()` in constructor and `OMX_Deinit()` in destructor — manages its own OMX lifecycle
|
||||
- Constructor takes 5 args: `(path, width, height, fps, bitrate)` — no h265/downscale params
|
||||
- `encoder_close()` calls `av_write_trailer` + ffmpeg faststart remux (`-movflags +faststart`)
|
||||
- Destructor has null guards and error handling on all OMX state transitions
|
||||
- ClearPilot addition: `encode_frame_nv12()` for direct NV12 input (dashcamd), alongside original `encode_frame_rgba()` (screen recorder)
|
||||
|
||||
### Key Files
|
||||
|
||||
@@ -266,7 +267,7 @@ A single `session.log` in each session directory records major events:
|
||||
|------|------|
|
||||
| `selfdrive/clearpilot/dashcamd.cc` | Main dashcam process — VisionIPC -> OMX encoder |
|
||||
| `selfdrive/clearpilot/SConscript` | Build config for dashcamd |
|
||||
| `selfdrive/frogpilot/screenrecorder/omx_encoder.cc` | OMX encoder (added `encode_frame_nv12` method) |
|
||||
| `selfdrive/frogpilot/screenrecorder/omx_encoder.cc` | OMX encoder (upstream FrogPilot port + `encode_frame_nv12`) |
|
||||
| `selfdrive/frogpilot/screenrecorder/omx_encoder.h` | Encoder header |
|
||||
| `selfdrive/manager/process_config.py` | dashcamd registered as NativeProcess, camerad always_run, encoderd disabled |
|
||||
| `system/loggerd/deleter.py` | Trip-aware storage rotation (oldest trip first, then segments within active trip) |
|
||||
@@ -275,12 +276,14 @@ A single `session.log` in each session directory records major events:
|
||||
|
||||
- `DashcamDebug` — when `"1"`, dashcamd runs even without car connected (for bench testing)
|
||||
- `DashcamShutdown` — set by thermald before power-off, dashcamd acks by clearing it
|
||||
- `DashcamState` (memory param) — "stopped", "waiting", or "recording" — published every 5s
|
||||
- `DashcamFrames` (memory param) — per-trip encoded frame count, resets each trip — published every 5s
|
||||
|
||||
## Standstill Power Saving
|
||||
|
||||
When `carState.standstill` is true:
|
||||
|
||||
- **modeld**: skips GPU inference on 19/20 frames (1fps vs 20fps), reports 0 frame drops to avoid triggering `modeldLagging` in controlsd
|
||||
- **modeld**: skips GPU inference on 19/20 frames (1fps vs 20fps), reports 0 frame drops to avoid triggering `modeldLagging` in controlsd. Runs full 20fps during calibration (`liveCalibration.calStatus != calibrated`)
|
||||
- **dmonitoringmodeld**: same 1fps throttle, added `carState` subscription
|
||||
- **Fan controller**: uses offroad clamps (0-30%) instead of onroad (30-100%) at standstill; thermal protection still active via feedforward if temp > 60°C
|
||||
|
||||
@@ -321,6 +324,12 @@ The Hyundai Tucson's LFA steering wheel button cycles through 5 display modes vi
|
||||
|
||||
**Not in drive (parked/off):** any except 3 → 3 (screen off), state 3 → 0 (auto-normal)
|
||||
|
||||
**Shift to drive from screen off:** auto-resets to mode 0 (auto-normal) via `controlsd`
|
||||
|
||||
**Shift to park from nightrider:** auto-switches to mode 3 (screen off) via `home.cc`
|
||||
|
||||
**Tap screen while screen off:** resets to mode 0 (auto-normal) via `window.cc` touch handler
|
||||
|
||||
### Nightrider Mode
|
||||
|
||||
- Camera feed suppressed (OpenGL clears to black instead of rendering camera texture)
|
||||
@@ -357,7 +366,10 @@ Display power is managed by `Device::updateWakefulness()` in `selfdrive/ui/ui.cc
|
||||
|
||||
- **Ignition off (offroad)**: screen blanks after `ScreenTimeout` seconds (default 120) of no touch. Tapping wakes it.
|
||||
- **Ignition on (onroad)**: screen stays on unconditionally — ignition=true short-circuits the timeout check.
|
||||
- **Debug button (LFA)**: cycles through display modes including screen off (state 3). Only state 3 calls `Hardware::set_display_power(false)`.
|
||||
- **ScreenDisplayMode 3 override**: `updateWakefulness` checks `ScreenDisplayMode` first — if mode 3, calls `setAwake(false)` unconditionally, preventing ignition-on from overriding screen-off.
|
||||
- **Debug button (LFA)**: cycles through display modes including screen off (state 3).
|
||||
- **Park transition**: always shows splash screen; if coming from nightrider mode, auto-switches to screen off (mode 3) via `home.cc`.
|
||||
- **Touch wake**: tapping screen while in mode 3 resets to mode 0 via `window.cc` event filter.
|
||||
|
||||
## Offroad UI (ClearPilot Menu)
|
||||
|
||||
@@ -500,7 +512,7 @@ Power On
|
||||
- **GPS data**: logged directly by telemetryd via cereal `gpsLocation` subscription at 1Hz — group: `gps` (latitude, longitude, speed, altitude, bearing, accuracy)
|
||||
- **CSV location**: `/data/log2/current/telemetry.csv` (or session directory)
|
||||
- **Onroad overlay**: when telemetry enabled, status bar shows temp, fan %, model FPS, and STANDSTILL indicator
|
||||
- **Speed limit**: `speed_limit.calculated` is the final computed speed limit value (in vehicle units, MPH when `is_metric=False`). This is the value that will be used for the future speed limit warning chime feature
|
||||
- **Speed limit**: processed by `selfdrive/clearpilot/speed_logic.py` (SpeedState class), converts m/s to display units, writes to memory params. Cruise warning signs appear when cruise set speed exceeds speed limit by threshold (10 mph if limit >= 50, 7 mph if < 50) or is 5+ mph under. Ding sound plays when warning sign appears or speed limit changes while visible (30s cooldown)
|
||||
|
||||
### Key Dependencies
|
||||
|
||||
|
||||
Reference in New Issue
Block a user