mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-29 21:33:42 +08:00
need this check
This commit is contained in:
@@ -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),
|
||||
},
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user