From bcff9ca4ce19697d361cd0407fff9c89e6083d0f Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Tue, 26 Nov 2024 13:57:42 -0500 Subject: [PATCH] silent park brake --- cereal/log.capnp | 1 + selfdrive/selfdrived/events.py | 9 +++++++++ sunnypilot/mads/mads.py | 3 +++ sunnypilot/mads/state.py | 5 +++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cereal/log.capnp b/cereal/log.capnp index 61db521c90..69267b90a2 100644 --- a/cereal/log.capnp +++ b/cereal/log.capnp @@ -197,6 +197,7 @@ struct OnroadEvent @0xc4fa6047f024e718 { silentReverseGear @160; silentDoorOpen @161; silentSeatbeltNotLatched @162; + silentParkBrake @163; soundsUnavailableDEPRECATED @47; } diff --git a/selfdrive/selfdrived/events.py b/selfdrive/selfdrived/events.py index 7c0b6bca96..fe27d1af24 100755 --- a/selfdrive/selfdrived/events.py +++ b/selfdrive/selfdrived/events.py @@ -1054,6 +1054,15 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = { ET.NO_ENTRY: NoEntryAlert("Seatbelt Unlatched"), }, + EventName.silentParkBrake: { + ET.WARNING: Alert( + "", + "", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.), + ET.NO_ENTRY: NoEntryAlert("Parking Brake Engaged"), + }, + } diff --git a/sunnypilot/mads/mads.py b/sunnypilot/mads/mads.py index 4f9c706624..8a62d8b3b4 100644 --- a/sunnypilot/mads/mads.py +++ b/sunnypilot/mads/mads.py @@ -60,6 +60,9 @@ class ModularAssistiveDrivingSystem: if self.events.has(EventName.seatbeltNotLatched): self.events.replace(EventName.seatbeltNotLatched, EventName.silentSeatbeltNotLatched) transition_paused_state() + if self.events.has(EventName.parkBrake): + self.events.replace(EventName.parkBrake, EventName.silentParkBrake) + transition_paused_state() if self.disengage_lateral_on_brake_toggle: if self.events.has(EventName.pedalPressed): diff --git a/sunnypilot/mads/state.py b/sunnypilot/mads/state.py index a64977717a..dfb3ce7713 100644 --- a/sunnypilot/mads/state.py +++ b/sunnypilot/mads/state.py @@ -10,9 +10,10 @@ ACTIVE_STATES = (State.enabled, State.softDisabling, State.overriding) ENABLED_STATES = (State.paused, *ACTIVE_STATES) GEARS_ALLOW_PAUSED_SILENT = [EventName.silentWrongGear, EventName.silentReverseGear, EventName.silentBrakeHold, - EventName.silentDoorOpen, EventName.silentSeatbeltNotLatched] + EventName.silentDoorOpen, EventName.silentSeatbeltNotLatched, EventName.parkBrake] GEARS_ALLOW_PAUSED = [EventName.wrongGear, EventName.reverseGear, EventName.brakeHold, - EventName.doorOpen, EventName.seatbeltNotLatched, *GEARS_ALLOW_PAUSED_SILENT] + EventName.doorOpen, EventName.seatbeltNotLatched, EventName.silentParkBrake, + *GEARS_ALLOW_PAUSED_SILENT] class StateMachine: