From 73e620245a533cf0840f621f7f43c8eb67cd933f Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sun, 15 Sep 2024 00:11:24 -0400 Subject: [PATCH] add super --- .../states.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sunnypilot/controls/lib/custom_stock_longitudinal_controller/states.py b/sunnypilot/controls/lib/custom_stock_longitudinal_controller/states.py index dc9d2296eb..850429faac 100644 --- a/sunnypilot/controls/lib/custom_stock_longitudinal_controller/states.py +++ b/sunnypilot/controls/lib/custom_stock_longitudinal_controller/states.py @@ -28,6 +28,9 @@ class ButtonStateBase(ABC): class InactiveState(ButtonStateBase): + def __init__(self, controller): + super().__init__(controller) + def handle(self) -> None: self.button_count = 0 @@ -41,6 +44,9 @@ class InactiveState(ButtonStateBase): class LoadingState(ButtonStateBase): + def __init__(self, controller): + super().__init__(controller) + def handle(self) -> None: if self.controller.target_speed > self.controller.v_cruise: self.controller.button_state = ButtonControlState.accelerating @@ -52,6 +58,9 @@ class LoadingState(ButtonStateBase): class AcceleratingState(ButtonStateBase): + def __init__(self, controller): + super().__init__(controller) + def handle(self) -> int | None: self.button_count += 1 if self.controller.target_speed <= self.controller.v_cruise or self.button_count > RESET_COUNT: @@ -62,6 +71,9 @@ class AcceleratingState(ButtonStateBase): class DeceleratingState(ButtonStateBase): + def __init__(self, controller): + super().__init__(controller) + def handle(self) -> int | None: self.button_count += 1 if self.controller.target_speed >= self.controller.v_cruise or self.controller.v_cruise <= self.controller.v_cruise_min or self.button_count > RESET_COUNT: @@ -72,6 +84,9 @@ class DeceleratingState(ButtonStateBase): class HoldingState(ButtonStateBase): + def __init__(self, controller): + super().__init__(controller) + def handle(self) -> None: self.button_count += 1 if self.button_count > T_INTERNAL: @@ -81,6 +96,9 @@ class HoldingState(ButtonStateBase): class ResettingState(ButtonStateBase): + def __init__(self, controller): + super().__init__(controller) + def handle(self) -> None: self.controller.button_state = ButtonControlState.loading return None