mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-06 04:35:47 +08:00
in lists
This commit is contained in:
@@ -108,6 +108,9 @@ class Events:
|
||||
def has(self, event_name: int) -> bool:
|
||||
return event_name in self.events
|
||||
|
||||
def has_list(self, events_list: list[int]) -> bool:
|
||||
return all(event_name in self.events for event_name in events_list)
|
||||
|
||||
def remove(self, event_name: int, static: bool = False) -> None:
|
||||
if static and event_name in self.static_events:
|
||||
self.static_events.remove(event_name)
|
||||
|
||||
@@ -4,7 +4,7 @@ from opendbc.car.hyundai.values import HyundaiFlags
|
||||
from opendbc.sunnypilot.car.hyundai.values import HyundaiFlagsSP
|
||||
|
||||
from openpilot.sunnypilot.mads.helpers import MadsParams
|
||||
from openpilot.sunnypilot.mads.state import StateMachine
|
||||
from openpilot.sunnypilot.mads.state import StateMachine, GEARS_ALLOW_PAUSED_SILENT
|
||||
|
||||
State = custom.SelfdriveStateSP.ModularAssistiveDrivingSystem.ModularAssistiveDrivingSystemState
|
||||
ButtonType = car.CarState.ButtonEvent.Type
|
||||
@@ -58,9 +58,7 @@ class ModularAssistiveDrivingSystem:
|
||||
self.selfdrive.events.replace(EventName.brakeHold, EventName.silentBrakeHold)
|
||||
transition_paused_state()
|
||||
|
||||
if not self.selfdrive.events.has(EventName.silentWrongGear) and \
|
||||
not self.selfdrive.events.has(EventName.silentReverseGear) and \
|
||||
not self.selfdrive.events.has(EventName.silentBrakeHold):
|
||||
if self.selfdrive.events.has_list(GEARS_ALLOW_PAUSED_SILENT):
|
||||
update_silent_lkas_enable()
|
||||
|
||||
if self.disengage_lateral_on_brake_toggle:
|
||||
|
||||
@@ -9,6 +9,10 @@ EventName = log.OnroadEvent.EventName
|
||||
ACTIVE_STATES = (State.enabled, State.softDisabling, State.overriding)
|
||||
ENABLED_STATES = (State.paused, *ACTIVE_STATES)
|
||||
|
||||
GEARS_ALLOW_PAUSED_SILENT = [EventName.silentWrongGear, EventName.silentReverseGear, EventName.silentBrakeHold]
|
||||
GEARS_ALLOW_PAUSED = [EventName.wrongGear, EventName.reverseGear, EventName.brakeHold, *GEARS_ALLOW_PAUSED_SILENT]
|
||||
ALLOW_PAUSED = [EventName.silentPedalPressed, *GEARS_ALLOW_PAUSED]
|
||||
|
||||
|
||||
class StateMachine:
|
||||
def __init__(self, mads):
|
||||
@@ -96,7 +100,8 @@ class StateMachine:
|
||||
elif self.state == State.disabled:
|
||||
if events.contains(ET.ENABLE):
|
||||
if events.contains(ET.NO_ENTRY):
|
||||
self.state = State.paused
|
||||
if events.has_list(ALLOW_PAUSED):
|
||||
self.state = State.paused
|
||||
self.add_current_alert_types(ET.NO_ENTRY)
|
||||
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user