From d7a708d6dadb73879cab4bf00d6ce67626a67978 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 5 Apr 2022 11:36:18 -0700 Subject: [PATCH] tests: add overriding to state machine test (#24131) * add overriding to state machine test * overriding should consider soft disable too --- selfdrive/controls/controlsd.py | 6 +++++- selfdrive/controls/tests/test_state_machine.py | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 0a95ff7bf5..922fa7e36b 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -479,7 +479,11 @@ class Controls: # OVERRIDING elif self.state == State.overriding: - if not self.events.any(ET.OVERRIDE): + if self.events.any(ET.SOFT_DISABLE): + self.state = State.softDisabling + self.soft_disable_timer = int(SOFT_DISABLE_TIME / DT_CTRL) + self.current_alert_types.append(ET.SOFT_DISABLE) + elif not self.events.any(ET.OVERRIDE): self.state = State.enabled else: self.current_alert_types.append(ET.OVERRIDE) diff --git a/selfdrive/controls/tests/test_state_machine.py b/selfdrive/controls/tests/test_state_machine.py index 99a111e612..244c56687c 100755 --- a/selfdrive/controls/tests/test_state_machine.py +++ b/selfdrive/controls/tests/test_state_machine.py @@ -12,11 +12,10 @@ State = log.ControlsState.OpenpilotState # The event types that maintain the current state MAINTAIN_STATES = {State.enabled: None, State.disabled: None, State.softDisabling: ET.SOFT_DISABLE, - State.preEnabled: ET.PRE_ENABLE} -ALL_STATES = tuple((state for state in State.schema.enumerants.values() if - state != State.overriding)) # TODO: remove overriding exception + State.preEnabled: ET.PRE_ENABLE, State.overriding: ET.OVERRIDE} +ALL_STATES = tuple(State.schema.enumerants.values()) # The event types checked in DISABLED section of state machine -ENABLE_EVENT_TYPES = (ET.ENABLE, ET.PRE_ENABLE) +ENABLE_EVENT_TYPES = (ET.ENABLE, ET.PRE_ENABLE, ET.OVERRIDE) def make_event(event_types):