From 26b8d4432e995bfc4be0926df0ec73954bbec96f Mon Sep 17 00:00:00 2001 From: Jafar Al-Gharaibeh Date: Mon, 20 Dec 2021 09:22:27 -0600 Subject: [PATCH 1/3] Mazda: alert when LKAS is disabled Signed-off-by: Jafar Al-Gharaibeh --- selfdrive/car/mazda/carstate.py | 6 +++++- selfdrive/car/mazda/interface.py | 4 +++- selfdrive/controls/lib/events.py | 7 +++++-- selfdrive/controls/tests/test_startup.py | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/selfdrive/car/mazda/carstate.py b/selfdrive/car/mazda/carstate.py index 7ebf60c96bd6ea..7e80e533a4fbac 100644 --- a/selfdrive/car/mazda/carstate.py +++ b/selfdrive/car/mazda/carstate.py @@ -16,6 +16,7 @@ def __init__(self, CP): self.acc_active_last = False self.low_speed_alert = False self.lkas_allowed_speed = False + self.lkas_disabled = False def update(self, cp, cp_cam): @@ -91,9 +92,12 @@ def update(self, cp, cp_cam): self.acc_active_last = ret.cruiseState.enabled + self.crz_btns_counter = cp.vl["CRZ_BTNS"]["CTR"] + + # camera signals + self.lkas_disabled = cp_cam.vl["CAM_LANEINFO"]["LANE_LINES"] == 0 self.cam_lkas = cp_cam.vl["CAM_LKAS"] self.cam_laneinfo = cp_cam.vl["CAM_LANEINFO"] - self.crz_btns_counter = cp.vl["CRZ_BTNS"]["CTR"] ret.steerError = cp_cam.vl["CAM_LKAS"]["ERR_BIT_1"] == 1 return ret diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index b4ae938228b885..9557cbc77be53f 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -86,7 +86,9 @@ def update(self, c, can_strings): # events events = self.create_common_events(ret) - if self.CS.low_speed_alert: + if self.CS.lkas_disabled: + events.add(EventName.lkasDisabled) + elif self.CS.low_speed_alert: events.add(EventName.belowSteerSpeed) ret.events = events.to_msg() diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 48a257ab4c560d..6d84d6fdf2cdd5 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -267,8 +267,6 @@ def joystick_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, sof EventName.stockFcw: {}, - EventName.lkasDisabled: {}, - # ********** events only containing alerts displayed in all states ********** EventName.joystickDebug: { @@ -834,4 +832,9 @@ def joystick_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, sof ET.NO_ENTRY: NoEntryAlert("Cruise Fault: Restart the Car"), }, + EventName.lkasDisabled: { + ET.PERMANENT: NormalPermanentAlert("LKAS Disabled: Enable LKAS to engage"), + ET.NO_ENTRY: NoEntryAlert("LKAS Disabled"), + }, + } diff --git a/selfdrive/controls/tests/test_startup.py b/selfdrive/controls/tests/test_startup.py index 658adf499eed5e..d64d28cadafc78 100755 --- a/selfdrive/controls/tests/test_startup.py +++ b/selfdrive/controls/tests/test_startup.py @@ -50,8 +50,8 @@ class TestStartup(unittest.TestCase): (EventName.communityFeatureDisallowed, TOYOTA.COROLLA, False, COROLLA_FW_VERSIONS_NO_DSU), # dashcamOnly car - (EventName.startupNoControl, MAZDA.CX5, True, CX5_FW_VERSIONS), - (EventName.startupNoControl, MAZDA.CX5, False, CX5_FW_VERSIONS), + (EventName.lkasDisabled, MAZDA.CX5, True, CX5_FW_VERSIONS), + (EventName.lkasDisabled, MAZDA.CX5, False, CX5_FW_VERSIONS), # unrecognized car with no fw (EventName.startupNoFw, None, True, None), From 6118540852da2c22ef805e22340aba1f15c65dd9 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 21 Jan 2022 16:17:23 -0800 Subject: [PATCH 2/3] update refs --- selfdrive/controls/lib/events.py | 2 +- selfdrive/controls/tests/test_startup.py | 4 ++-- selfdrive/test/process_replay/compare_logs.py | 4 ++-- selfdrive/test/process_replay/ref_commit | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index ba9fce18157fb4..63def298ea6add 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -184,7 +184,7 @@ class StartupAlert(Alert): def __init__(self, alert_text_1: str, alert_text_2: str = "Always keep hands on wheel and eyes on road", alert_status=AlertStatus.normal): super().__init__(alert_text_1, alert_text_2, alert_status, AlertSize.mid, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.), + Priority.LOW, VisualAlert.none, AudibleAlert.none, 10.), # ********** helper functions ********** diff --git a/selfdrive/controls/tests/test_startup.py b/selfdrive/controls/tests/test_startup.py index d64d28cadafc78..658adf499eed5e 100755 --- a/selfdrive/controls/tests/test_startup.py +++ b/selfdrive/controls/tests/test_startup.py @@ -50,8 +50,8 @@ class TestStartup(unittest.TestCase): (EventName.communityFeatureDisallowed, TOYOTA.COROLLA, False, COROLLA_FW_VERSIONS_NO_DSU), # dashcamOnly car - (EventName.lkasDisabled, MAZDA.CX5, True, CX5_FW_VERSIONS), - (EventName.lkasDisabled, MAZDA.CX5, False, CX5_FW_VERSIONS), + (EventName.startupNoControl, MAZDA.CX5, True, CX5_FW_VERSIONS), + (EventName.startupNoControl, MAZDA.CX5, False, CX5_FW_VERSIONS), # unrecognized car with no fw (EventName.startupNoFw, None, True, None), diff --git a/selfdrive/test/process_replay/compare_logs.py b/selfdrive/test/process_replay/compare_logs.py index 9cf8e3fa9a9857..33b73ea22a8978 100755 --- a/selfdrive/test/process_replay/compare_logs.py +++ b/selfdrive/test/process_replay/compare_logs.py @@ -87,8 +87,8 @@ def compare_logs(log1, log2, ignore_fields=None, ignore_msgs=None, tolerance=Non def outside_tolerance(diff): if diff[0] == "change": a, b = diff[2] - finite = math.isfinite(a) and math.isfinite(b) - if finite and isinstance(a, numbers.Number) and isinstance(b, numbers.Number): + is_numbers = isinstance(a, numbers.Number) and isinstance(b, numbers.Number) + if is_numbers and math.isfinite(a) and math.isfinite(b): return abs(a - b) > max(tolerance, tolerance * max(abs(a), abs(b))) return True diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index c3fa542c0ba199..720d64a0c96920 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -4a64d5122c408e2ba759d531df2d6ab7b4d7508a \ No newline at end of file +45f4e286f2fae228c7f637e56a9e372709519bfd \ No newline at end of file From 93dcd7399cfebf9f90e778d375f00ac88dcc5142 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 30 Jan 2022 20:59:02 -0800 Subject: [PATCH 3/3] revert that --- selfdrive/controls/lib/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index a45588abd13e83..514d2f0cc20c6d 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -184,7 +184,7 @@ class StartupAlert(Alert): def __init__(self, alert_text_1: str, alert_text_2: str = "Always keep hands on wheel and eyes on road", alert_status=AlertStatus.normal): super().__init__(alert_text_1, alert_text_2, alert_status, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 10.), + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.), # ********** helper functions **********