diff --git a/cereal/log.capnp b/cereal/log.capnp index 46324095d2..bc025986bb 100644 --- a/cereal/log.capnp +++ b/cereal/log.capnp @@ -191,9 +191,10 @@ struct OnroadEvent @0xc4fa6047f024e718 { manualLongitudinalRequired @154; silentPedalPressed @155; silentLkasEnable @156; - silentBrakeHold @157; - silentWrongGear @158; - silentReverseGear @159; + silentLkasDisable @157; + silentBrakeHold @158; + silentWrongGear @159; + silentReverseGear @160; soundsUnavailableDEPRECATED @47; } diff --git a/selfdrive/selfdrived/events.py b/selfdrive/selfdrived/events.py index 21d6f4decc..3d56cd3390 100755 --- a/selfdrive/selfdrived/events.py +++ b/selfdrive/selfdrived/events.py @@ -992,11 +992,6 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = { }, EventName.silentPedalPressed: { - ET.USER_DISABLE: Alert( - "", - "", - AlertStatus.normal, AlertSize.none, - Priority.MID, VisualAlert.none, AudibleAlert.none, .2), ET.NO_ENTRY: NoEntryAlert("Pedal Pressed During Attempt", visual_alert=VisualAlert.brakePressed), }, @@ -1009,17 +1004,20 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = { Priority.MID, VisualAlert.none, AudibleAlert.none, .2, 0.), }, - EventName.silentBrakeHold: { + EventName.silentLkasDisable: { ET.USER_DISABLE: Alert( "", "", AlertStatus.normal, AlertSize.none, Priority.MID, VisualAlert.none, AudibleAlert.none, .2, 0.), + }, + + EventName.silentBrakeHold: { ET.NO_ENTRY: NoEntryAlert("Brake Hold Active"), }, EventName.silentWrongGear: { - ET.USER_DISABLE: Alert( + ET.PERMANENT: Alert( "Gear not D", "openpilot Unavailable", AlertStatus.normal, AlertSize.mid, @@ -1037,11 +1035,6 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = { "", AlertStatus.normal, AlertSize.full, Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2, creation_delay=0.5), - ET.USER_DISABLE: Alert( - "Reverse\nGear", - "", - AlertStatus.normal, AlertSize.full, - Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2, creation_delay=0.), ET.NO_ENTRY: NoEntryAlert("Reverse Gear"), }, diff --git a/sunnypilot/mads/mads.py b/sunnypilot/mads/mads.py index 086f4fadf2..c0eb45cd83 100644 --- a/sunnypilot/mads/mads.py +++ b/sunnypilot/mads/mads.py @@ -43,11 +43,17 @@ class ModularAssistiveDrivingSystem: if self.state_machine.state == State.paused and self.enabled: self.selfdrive.events.add(EventName.silentLkasEnable) + def transition_paused_state(): + if self.state_machine.state != State.paused: + self.selfdrive.events.add(EventName.silentLkasDisable) + if not self.selfdrive.enabled: if self.selfdrive.events.has(EventName.wrongGear) and not self.selfdrive.events.has(EventName.reverseGear): self.selfdrive.events.replace(EventName.wrongGear, EventName.silentWrongGear) + transition_paused_state() if self.selfdrive.events.has(EventName.reverseGear) and CS.vEgo < 5: self.selfdrive.events.replace(EventName.reverseGear, EventName.silentReverseGear) + transition_paused_state() if not self.selfdrive.events.has(EventName.silentWrongGear) and not self.selfdrive.events.has(EventName.silentReverseGear): update_silent_lkas_enable() @@ -55,9 +61,11 @@ class ModularAssistiveDrivingSystem: if self.disengage_lateral_on_brake_toggle: if self.selfdrive.events.has(EventName.brakeHold): self.selfdrive.events.replace(EventName.brakeHold, EventName.silentBrakeHold) + transition_paused_state() if self.selfdrive.events.has(EventName.pedalPressed): self.selfdrive.events.add(EventName.silentPedalPressed) + transition_paused_state() if not CS.brakePressed and not CS.brakeHoldActive and not CS.parkingBrake and not CS.regenBraking: update_silent_lkas_enable() diff --git a/sunnypilot/mads/state.py b/sunnypilot/mads/state.py index ec2c04208a..b3a2e67a97 100644 --- a/sunnypilot/mads/state.py +++ b/sunnypilot/mads/state.py @@ -31,8 +31,7 @@ class StateMachine: if self.state != State.disabled: # user and immediate disable always have priority in a non-disabled state if events.contains(ET.USER_DISABLE): - if events.has(EventName.silentPedalPressed) or events.has(EventName.silentBrakeHold) or \ - events.has(EventName.silentWrongGear) or events.has(EventName.silentReverseGear): + if events.has(EventName.silentLkasDisable): self.state = State.paused else: self.state = State.disabled