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