diff --git a/cereal b/cereal index 4d93775f7e..c2761bdbd8 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 4d93775f7e6fb5ffbd8f6b68ee5e6704b023d2ea +Subproject commit c2761bdbd85b844ed9900eb2f067312be3a0aaea diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 92785b07d4..22f0f6c63b 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -147,6 +147,7 @@ class Controls: self.v_cruise_kph = 255 self.v_cruise_kph_last = 0 self.mismatch_counter = 0 + self.cruise_mismatch_counter = 0 self.can_error_counter = 0 self.last_blinker_frame = 0 self.saturated_count = 0 @@ -260,9 +261,7 @@ class Controls: if log.PandaState.FaultType.relayMalfunction in pandaState.faults: self.events.add(EventName.relayMalfunction) - if not self.sm['liveParameters'].valid: - self.events.add(EventName.vehicleModelInvalid) - + # Check for HW or system issues if len(self.sm['radarState'].radarErrors): self.events.add(EventName.radarFault) elif not self.sm.valid["pandaStates"]: @@ -277,6 +276,8 @@ class Controls: else: self.logged_comm_issue = False + if not self.sm['liveParameters'].valid: + self.events.add(EventName.vehicleModelInvalid) if not self.sm['lateralPlan'].mpcSolutionValid: self.events.add(EventName.plannerError) if not self.sm['liveLocationKalman'].sensorsOK and not NOSENSOR: @@ -290,6 +291,13 @@ class Controls: if log.PandaState.FaultType.relayMalfunction in pandaState.faults: 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 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 diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 7afd4f493e..8a67ac131b 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -301,6 +301,10 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo 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 # detects the use of a community feature it switches to dashcam mode # until these features are allowed using a toggle in settings. diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index b2df9d03c8..2957526be2 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -0ee2d1f6b658ecb823212827f5fd6b996f143119 \ No newline at end of file +e1ac1b89b7c6638c5777f1e8db368d264e0de8e6 \ No newline at end of file diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index 2af882bc37..9126e2310e 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -112,7 +112,7 @@ def check_cpu_usage(first_proc, last_proc): cpu_usage = cpu_time / dt * 100. if cpu_usage > max(normal_cpu_usage * 1.15, normal_cpu_usage + 5.0): # cpu usage is high while playing sounds - if proc_name == "./_soundd" and cpu_usage < 25.: + if proc_name == "./_soundd" and cpu_usage < 65.: continue result += f"Warning {proc_name} using more CPU than normal\n" r = False