From a5d6fe83aebf345cbc129028f65a4fe4afbaa4f2 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sat, 14 Sep 2024 17:50:38 -0400 Subject: [PATCH] diff --- .../controllers.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/selfdrive/controls/lib/sunnypilot/custom_stock_longitudinal_controller/controllers.py b/selfdrive/controls/lib/sunnypilot/custom_stock_longitudinal_controller/controllers.py index 57eef2141f..8891a6246d 100644 --- a/selfdrive/controls/lib/sunnypilot/custom_stock_longitudinal_controller/controllers.py +++ b/selfdrive/controls/lib/sunnypilot/custom_stock_longitudinal_controller/controllers.py @@ -55,6 +55,10 @@ class CustomStockLongitudinalControllerBase(ABC): ButtonControlState.loading: LoadingState(), } + @abstractmethod + def create_mock_button_messages(self) -> list[SendCan]: + pass + def state_publish(self): customStockLongitudinalControl = custom.CarControlSP.CustomStockLongitudinalControl.new_message() customStockLongitudinalControl.state = self.button_state @@ -82,15 +86,11 @@ class CustomStockLongitudinalControllerBase(ABC): self.steady_speed = cur_speed return self.steady_speed - def get_cruise_button(self, CS: car.CarState) -> int: + def get_cruise_button(self, CS: car.CarState) -> None: self.target_speed = round(self.final_speed_kph * (CV.KPH_TO_MPH if not self.car_state.params_list.is_metric else 1)) self.v_cruise = round(CS.cruiseState.speed * (CV.MS_TO_MPH if not self.car_state.params_list.is_metric else CV.MS_TO_KPH)) - cruise_button = self.button_states[self.button_state](self, CS) - return cruise_button - @abstractmethod - def create_mock_button_messages(self) -> list[SendCan]: - pass + self.cruise_button = self.button_states[self.button_state](self, CS) def update(self, CS: car.CarState, CC: car.CarControl) -> list[SendCan]: self.is_active = CS.cruiseState.enabled and not CC.cruiseControl.cancel and not CC.cruiseControl.resume @@ -105,7 +105,8 @@ class CustomStockLongitudinalControllerBase(ABC): self.v_cruise_min = get_set_point(self.car_state.params_list.is_metric) self.final_speed_kph = self.get_v_target(CC) - self.cruise_button = self.get_cruise_button(CS) + + self.get_cruise_button(CS) can_sends = self.create_mock_button_messages()