controlsd: alert on cruise mismatch for >1s (#22841)

* controlsd: alert on cruise mismatch for >1s

* bump cereal

* update refs

* bump allowed soundd cpu

* bump cereal
old-commit-hash: 035bc0c20f
commatwo_master
Adeeb Shihadeh 4 years ago committed by GitHub
parent 448d5f9e93
commit d6c42f11f4
  1. 2
      cereal
  2. 14
      selfdrive/controls/controlsd.py
  3. 4
      selfdrive/controls/lib/events.py
  4. 2
      selfdrive/test/process_replay/ref_commit
  5. 2
      selfdrive/test/test_onroad.py

@ -1 +1 @@
Subproject commit 4d93775f7e6fb5ffbd8f6b68ee5e6704b023d2ea Subproject commit c2761bdbd85b844ed9900eb2f067312be3a0aaea

@ -147,6 +147,7 @@ class Controls:
self.v_cruise_kph = 255 self.v_cruise_kph = 255
self.v_cruise_kph_last = 0 self.v_cruise_kph_last = 0
self.mismatch_counter = 0 self.mismatch_counter = 0
self.cruise_mismatch_counter = 0
self.can_error_counter = 0 self.can_error_counter = 0
self.last_blinker_frame = 0 self.last_blinker_frame = 0
self.saturated_count = 0 self.saturated_count = 0
@ -260,9 +261,7 @@ class Controls:
if log.PandaState.FaultType.relayMalfunction in pandaState.faults: if log.PandaState.FaultType.relayMalfunction in pandaState.faults:
self.events.add(EventName.relayMalfunction) self.events.add(EventName.relayMalfunction)
if not self.sm['liveParameters'].valid: # Check for HW or system issues
self.events.add(EventName.vehicleModelInvalid)
if len(self.sm['radarState'].radarErrors): if len(self.sm['radarState'].radarErrors):
self.events.add(EventName.radarFault) self.events.add(EventName.radarFault)
elif not self.sm.valid["pandaStates"]: elif not self.sm.valid["pandaStates"]:
@ -277,6 +276,8 @@ class Controls:
else: else:
self.logged_comm_issue = False self.logged_comm_issue = False
if not self.sm['liveParameters'].valid:
self.events.add(EventName.vehicleModelInvalid)
if not self.sm['lateralPlan'].mpcSolutionValid: if not self.sm['lateralPlan'].mpcSolutionValid:
self.events.add(EventName.plannerError) self.events.add(EventName.plannerError)
if not self.sm['liveLocationKalman'].sensorsOK and not NOSENSOR: if not self.sm['liveLocationKalman'].sensorsOK and not NOSENSOR:
@ -290,6 +291,13 @@ class Controls:
if log.PandaState.FaultType.relayMalfunction in pandaState.faults: if log.PandaState.FaultType.relayMalfunction in pandaState.faults:
self.events.add(EventName.relayMalfunction) self.events.add(EventName.relayMalfunction)
# Check for mismatch between openpilot and car's PCM
cruise_mismatch = CS.cruiseState.enabled and (not self.enabled or not self.CP.pcmCruise)
self.cruise_mismatch_counter = self.cruise_mismatch_counter + 1 if cruise_mismatch else 0
if self.cruise_mismatch_counter > int(1. / DT_CTRL):
self.events.add(EventName.cruiseMismatch)
# Check for FCW
stock_long_is_braking = self.enabled and not self.CP.openpilotLongitudinalControl and CS.aEgo < -1.5 stock_long_is_braking = self.enabled and not self.CP.openpilotLongitudinalControl and CS.aEgo < -1.5
model_fcw = self.sm['modelV2'].meta.hardBrakePredicted and not CS.brakePressed and not stock_long_is_braking model_fcw = self.sm['modelV2'].meta.hardBrakePredicted and not CS.brakePressed and not stock_long_is_braking
planner_fcw = self.sm['longitudinalPlan'].fcw and self.enabled planner_fcw = self.sm['longitudinalPlan'].fcw and self.enabled

@ -301,6 +301,10 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
Priority.LOWER, VisualAlert.none, AudibleAlert.none, .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, .2),
}, },
EventName.cruiseMismatch: {
ET.PERMANENT: ImmediateDisableAlert("openpilot failed to cancel cruise"),
},
# Some features or cars are marked as community features. If openpilot # Some features or cars are marked as community features. If openpilot
# detects the use of a community feature it switches to dashcam mode # detects the use of a community feature it switches to dashcam mode
# until these features are allowed using a toggle in settings. # until these features are allowed using a toggle in settings.

@ -1 +1 @@
0ee2d1f6b658ecb823212827f5fd6b996f143119 e1ac1b89b7c6638c5777f1e8db368d264e0de8e6

@ -112,7 +112,7 @@ def check_cpu_usage(first_proc, last_proc):
cpu_usage = cpu_time / dt * 100. cpu_usage = cpu_time / dt * 100.
if cpu_usage > max(normal_cpu_usage * 1.15, normal_cpu_usage + 5.0): if cpu_usage > max(normal_cpu_usage * 1.15, normal_cpu_usage + 5.0):
# cpu usage is high while playing sounds # cpu usage is high while playing sounds
if proc_name == "./_soundd" and cpu_usage < 25.: if proc_name == "./_soundd" and cpu_usage < 65.:
continue continue
result += f"Warning {proc_name} using more CPU than normal\n" result += f"Warning {proc_name} using more CPU than normal\n"
r = False r = False

Loading…
Cancel
Save