From 0e3d07ee2a3160017d556c068652c7f647be7465 Mon Sep 17 00:00:00 2001 From: Jafar Al-Gharaibeh Date: Mon, 20 Dec 2021 09:22:27 -0600 Subject: [PATCH] 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 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/selfdrive/car/mazda/carstate.py b/selfdrive/car/mazda/carstate.py index 7ebf60c96bd6ea8..7e80e533a4fbacc 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 b4ae938228b885b..9557cbc77be53f5 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 48a257ab4c560d1..6d84d6fdf2cdd50 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"), + }, + }