From ff87abb45bd59a2fd42e1d8cedeabe3c0e713916 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Mon, 30 Sep 2024 11:04:56 -0400 Subject: [PATCH] comments --- sunnypilot/mads/state.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sunnypilot/mads/state.py b/sunnypilot/mads/state.py index 7c65f1c65d..f29049f223 100644 --- a/sunnypilot/mads/state.py +++ b/sunnypilot/mads/state.py @@ -21,7 +21,13 @@ class StateMachineBase(ABC): self.state = State.disabled def __call__(self, events: Events) -> tuple[State, bool, bool]: + # soft disable timer and current alert types are from the state machine of openpilot + # decrement the soft disable timer at every step, as it's reset on + # entrance in SOFT_DISABLING state + + # ENABLED, SOFT DISABLING, PAUSED, OVERRIDING 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): self.state = State.paused @@ -34,16 +40,18 @@ class StateMachineBase(ABC): self.add_current_alert_types(ET.IMMEDIATE_DISABLE) else: + # ENABLED, SOFT DISABLING, PAUSED, OVERRIDING self.handle(events) + # DISABLED elif self.state == State.disabled: self.handle(events) + # check if MADS is engaged & available, and actuators are enabled enabled = self.state in ENABLED_STATES and self.mads.available active = self.state in ACTIVE_STATES and self.mads.available if active: self.add_current_alert_types(ET.WARNING) - return self.state, enabled, active @abstractmethod