feat: raise controlsdLagging alert threshold to 20ms avg
Stock rk.lagging fires at 11.1ms (90% of 10ms interval), which the Hyundai CAN load routinely crosses during normal driving as carstate parses 50-200 msgs/sec. That's normal, not a fault — the same code behaved the same way at the fork baseline; we just made it visible with the LAG overlay. 50Hz effective control is still tighter than any human reaction loop. rk.lagging remains wired to the defensive skip paths (secondary camera and radar checks) at the original tighter threshold, so we still avoid false-alarming dependent events when briefly overloaded. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -481,12 +481,16 @@ class Controls:
|
|||||||
self.events.add(EventName.cameraMalfunction)
|
self.events.add(EventName.cameraMalfunction)
|
||||||
elif not self.sm.all_freq_ok(self.camera_packets):
|
elif not self.sm.all_freq_ok(self.camera_packets):
|
||||||
self.events.add(EventName.cameraFrameRate)
|
self.events.add(EventName.cameraFrameRate)
|
||||||
# CLEARPILOT: also gate on model_suppress + lat_engage_suppress — the fps transition
|
# CLEARPILOT: alert only when avg cycle time exceeds 20ms (≈50Hz effective).
|
||||||
# on engage briefly pushes avg cycle time over the 11.1ms (90% of 10ms) threshold
|
# Stock rk.lagging fires at 11.1ms (90% of 10ms) which the Hyundai CAN load
|
||||||
# while downstream services (plannerd, locationd) drain the sudden 5x message rate
|
# routinely crosses while driving — that's normal, not a fault. 50Hz control is
|
||||||
if not REPLAY and self.rk.lagging and not model_suppress and not lat_engage_suppress:
|
# 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
|
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)
|
self.events.add(EventName.controlsdLagging)
|
||||||
if not self.radarless_model:
|
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']))):
|
if not model_suppress and (len(self.sm['radarState'].radarErrors) or (not self.rk.lagging and not self.sm.all_checks(['radarState']))):
|
||||||
|
|||||||
Reference in New Issue
Block a user