diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 1632a9e..6c9d745 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -481,12 +481,16 @@ class Controls: self.events.add(EventName.cameraMalfunction) elif not self.sm.all_freq_ok(self.camera_packets): self.events.add(EventName.cameraFrameRate) - # CLEARPILOT: also gate on model_suppress + lat_engage_suppress — the fps transition - # on engage briefly pushes avg cycle time over the 11.1ms (90% of 10ms) threshold - # while downstream services (plannerd, locationd) drain the sudden 5x message rate - if not REPLAY and self.rk.lagging and not model_suppress and not lat_engage_suppress: + # CLEARPILOT: alert only when avg cycle time exceeds 20ms (≈50Hz effective). + # Stock rk.lagging fires at 11.1ms (90% of 10ms) which the Hyundai CAN load + # routinely crosses while driving — that's normal, not a fault. 50Hz control is + # still plenty responsive. `rk.lagging` is still used defensively elsewhere + # (lines ~479, 492) to skip secondary checks when slightly overloaded. + avg_dt = sum(self.rk._dts) / len(self.rk._dts) + alert_lagging = avg_dt > 0.020 + if not REPLAY and alert_lagging and not model_suppress and not lat_engage_suppress: import sys - print(f"CLP controlsdLagging: remaining={self.rk.remaining:.4f} standstill={CS.standstill} vEgo={CS.vEgo:.2f}", file=sys.stderr) + print(f"CLP controlsdLagging: avg_dt={avg_dt*1000:.2f}ms remaining={self.rk.remaining:.4f} standstill={CS.standstill} vEgo={CS.vEgo:.2f}", file=sys.stderr) self.events.add(EventName.controlsdLagging) if not self.radarless_model: if not model_suppress and (len(self.sm['radarState'].radarErrors) or (not self.rk.lagging and not self.sm.all_checks(['radarState']))):