controlsd: disambiguate can error and can socket lag (#25559)

old-commit-hash: 94f353a5e3
taco
Adeeb Shihadeh 3 years ago committed by GitHub
parent 0448644af4
commit 3b747049ad
  1. 18
      selfdrive/controls/controlsd.py

@ -161,14 +161,14 @@ class Controls:
self.state = State.disabled
self.enabled = False
self.active = False
self.can_rcv_error = False
self.can_rcv_timeout = False
self.soft_disable_timer = 0
self.v_cruise_kph = V_CRUISE_INITIAL
self.v_cruise_cluster_kph = V_CRUISE_INITIAL
self.v_cruise_kph_last = 0
self.mismatch_counter = 0
self.cruise_mismatch_counter = 0
self.can_rcv_error_counter = 0
self.can_rcv_timeout_counter = 0
self.last_blinker_frame = 0
self.distance_traveled = 0
self.last_functional_fan_frame = 0
@ -339,19 +339,19 @@ class Controls:
# generic catch-all. ideally, a more specific event should be added above instead
has_disable_events = self.events.any(ET.NO_ENTRY) and (self.events.any(ET.SOFT_DISABLE) or self.events.any(ET.IMMEDIATE_DISABLE))
no_system_errors = (not has_disable_events) or (len(self.events) == num_events)
if (not self.sm.all_checks() or self.can_rcv_error) and no_system_errors:
if (not self.sm.all_checks() or self.can_rcv_timeout) and no_system_errors:
if not self.sm.all_alive():
self.events.add(EventName.commIssue)
elif not self.sm.all_freq_ok():
self.events.add(EventName.commIssueAvgFreq)
else: # invalid or can_rcv_error.
else: # invalid or can_rcv_timeout.
self.events.add(EventName.commIssue)
logs = {
'invalid': [s for s, valid in self.sm.valid.items() if not valid],
'not_alive': [s for s, alive in self.sm.alive.items() if not alive],
'not_freq_ok': [s for s, freq_ok in self.sm.freq_ok.items() if not freq_ok],
'can_error': self.can_rcv_error,
'can_rcv_timeout': self.can_rcv_timeout,
}
if logs != self.logged_comm_issue:
cloudlog.event("commIssue", error=True, **logs)
@ -440,10 +440,10 @@ class Controls:
# Check for CAN timeout
if not can_strs:
self.can_rcv_error_counter += 1
self.can_rcv_error = True
self.can_rcv_timeout_counter += 1
self.can_rcv_timeout = True
else:
self.can_rcv_error = False
self.can_rcv_timeout = False
# When the panda and controlsd do not agree on controls_allowed
# we want to disengage openpilot. However the status from the panda goes through
@ -785,7 +785,7 @@ class Controls:
controlsState.cumLagMs = -self.rk.remaining * 1000.
controlsState.startMonoTime = int(start_time * 1e9)
controlsState.forceDecel = bool(force_decel)
controlsState.canErrorCounter = self.can_rcv_error_counter
controlsState.canErrorCounter = self.can_rcv_timeout_counter
lat_tuning = self.CP.lateralTuning.which()
if self.joystick_mode:

Loading…
Cancel
Save