diff --git a/selfdrive/selfdrived/events.py b/selfdrive/selfdrived/events.py index 90c82c1056..527b478e4b 100755 --- a/selfdrive/selfdrived/events.py +++ b/selfdrive/selfdrived/events.py @@ -991,8 +991,8 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = { Priority.LOW, VisualAlert.none, AudibleAlert.none, 1.), }, - # FIXME-SP: no longer used, remove prior merging EventName.silentPedalPressed: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.none), ET.NO_ENTRY: NoEntryAlert("Pedal Pressed During Attempt", visual_alert=VisualAlert.brakePressed), }, diff --git a/sunnypilot/mads/mads.py b/sunnypilot/mads/mads.py index c75a9c1e4f..da8658d599 100644 --- a/sunnypilot/mads/mads.py +++ b/sunnypilot/mads/mads.py @@ -64,6 +64,7 @@ class ModularAssistiveDrivingSystem: 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: diff --git a/sunnypilot/mads/state.py b/sunnypilot/mads/state.py index b3a2e67a97..57b919fc9b 100644 --- a/sunnypilot/mads/state.py +++ b/sunnypilot/mads/state.py @@ -31,7 +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.silentLkasDisable): + if events.has(EventName.silentLkasDisable) or events.has(EventName.silentPedalPressed): self.state = State.paused else: self.state = State.disabled diff --git a/sunnypilot/mads/tests/test_mads_state_machine.py b/sunnypilot/mads/tests/test_mads_state_machine.py index 09f2e97d14..b47bb05b6e 100644 --- a/sunnypilot/mads/tests/test_mads_state_machine.py +++ b/sunnypilot/mads/tests/test_mads_state_machine.py @@ -59,15 +59,17 @@ class TestMADSStateMachine: self.events.clear() def test_user_disable_to_paused(self): + paused_events = (EventName.silentLkasDisable, EventName.silentPedalPressed) for state in ALL_STATES: for et in MAINTAIN_STATES[state]: self.events.add(make_event([et, ET.USER_DISABLE])) - self.events.add(EventName.silentLkasDisable) - self.state_machine.state = state - self.state_machine.update(self.events) - final_state = State.paused if self.events.has(EventName.silentLkasDisable) and state != State.disabled else State.disabled - assert self.state_machine.state == final_state - self.events.clear() + for en in paused_events: + self.events.add(en) + self.state_machine.state = state + self.state_machine.update(self.events) + final_state = State.paused if self.events.has(en) and state != State.disabled else State.disabled + assert self.state_machine.state == final_state + self.events.clear() def test_soft_disable(self): for state in ALL_STATES: