From 2b522021d5373545cac7fc3e86f659915dac64a7 Mon Sep 17 00:00:00 2001 From: Brian Hanson Date: Tue, 14 Apr 2026 02:40:18 -0500 Subject: [PATCH] modeld 3-mode power saving, tlog disabled, dashcamd boot fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - modeld: full 20fps (lat active), 4fps (driving no lateral), 0fps (standstill). Standby timestamp written in both standby and 4fps modes to suppress transient errors on engagement transition - tlog: all calls commented out (was causing 100Hz CPU load in controlsd and carstate). tlog client now checks TelemetryEnabled param before sending — zero cost when disabled - dashcamd: wait for valid frame dimensions on startup (fix SIGSEGV), always_run (manages own trip lifecycle) - Fan: driving range 15-100% Co-Authored-By: Claude Opus 4.6 (1M context) --- selfdrive/modeld/modeld.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/selfdrive/modeld/modeld.py b/selfdrive/modeld/modeld.py index 93011b1..527e4ad 100755 --- a/selfdrive/modeld/modeld.py +++ b/selfdrive/modeld/modeld.py @@ -241,16 +241,21 @@ def main(demo=False): sm.update(0) - # CLEARPILOT: power saving — skip inference when lateral control is not active - # Covers standstill, manual driving (no cruise), and disengaged states - # Exception: keep processing during lane changes (no_lat_lane_change) + # CLEARPILOT: power saving — three modes based on driving state + # Full 20fps: lat active or lane changing + # Reduced 4fps: not lat active, not standstill (driving without cruise) + # Standby 0fps: standstill lat_active = sm['carControl'].latActive lane_changing = params_memory.get_bool("no_lat_lane_change") - should_standby = not lat_active and not lane_changing + standstill = sm['carState'].standstill + full_rate = lat_active or lane_changing + + # Standby transitions (standstill only) + should_standby = standstill and not full_rate if should_standby and not model_standby: params_memory.put_bool("ModelStandby", True) model_standby = True - cloudlog.warning("modeld: standby ON (lat_active=%s standstill=%s)", lat_active, sm['carState'].standstill) + cloudlog.warning("modeld: standby ON (standstill)") elif not should_standby and model_standby: params_memory.put_bool("ModelStandby", False) model_standby = False @@ -265,6 +270,19 @@ def main(demo=False): last_vipc_frame_id = meta_main.frame_id continue + # Reduced framerate: 4fps when not lat active and not standstill + # Skip 4 out of every 5 frames (20fps -> 4fps) + # Write standby timestamp so controlsd suppresses transient errors + if not full_rate: + now = _time.monotonic() + if now - last_standby_ts_write > 1.0: + params_memory.put("ModelStandbyTs", str(now)) + last_standby_ts_write = now + if run_count % 5 != 0: + last_vipc_frame_id = meta_main.frame_id + run_count += 1 + continue + desire = DH.desire is_rhd = sm["driverMonitoringState"].isRHD frame_id = sm["roadCameraState"].frameId