diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index 0b52ccbcba..c7928d6271 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -135,7 +135,7 @@ class CarInterface(CarInterfaceBase): self.CS.accEnabled = False self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled - ret, self.CS = self.get_sp_common_state(ret, self.CS, gap_button=bool(self.CS.distance_button)) + ret = self.get_sp_common_state(ret, gap_button=bool(self.CS.distance_button)) ret.buttonEvents = [ *self.CS.button_events, diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index b5d1197894..8b55db3ee0 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -105,7 +105,7 @@ class CarInterface(CarInterfaceBase): self.CS.accEnabled = False self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled - ret, self.CS = self.get_sp_common_state(ret, self.CS, gap_button=bool(self.CS.distance_button)) + ret = self.get_sp_common_state(ret, gap_button=bool(self.CS.distance_button)) ret.buttonEvents = [ *self.CS.button_events, diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 2a1dade4f7..7e58baec08 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -251,7 +251,7 @@ class CarInterface(CarInterfaceBase): self.CS.accEnabled = False self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled - ret, self.CS = self.get_sp_common_state(ret, self.CS, gap_button=bool(distance_button)) + ret = self.get_sp_common_state(ret, gap_button=bool(distance_button)) ret.buttonEvents = [ *self.CS.button_events, diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 1f1134c151..f560d8323d 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -300,7 +300,7 @@ class CarInterface(CarInterfaceBase): elif not ret.cruiseState.enabled: self.CS.accEnabled = False - ret, self.CS = self.get_sp_common_state(ret, self.CS, gap_button=(self.CS.cruise_setting == 3)) + ret = self.get_sp_common_state(ret, gap_button=(self.CS.cruise_setting == 3)) ret.buttonEvents = [ *self.CS.button_events, diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index a73adac27a..e7c0071f5e 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -241,7 +241,7 @@ class CarInterface(CarInterfaceBase): self.get_sp_cancel_cruise_state() ret.cruiseState.enabled = ret.cruiseState.enabled if not self.enable_mads else False if self.CP.pcmCruise else self.CS.accEnabled - ret, self.CS = self.get_sp_common_state(ret, self.CS, gap_button=(self.CS.cruise_buttons[-1] == 3)) + ret = self.get_sp_common_state(ret, gap_button=(self.CS.cruise_buttons[-1] == 3)) ret.buttonEvents = [ *self.CS.button_events, diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index b3085b2ed6..cd9e161e60 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -621,17 +621,17 @@ class CarInterfaceBase(ABC): else: return CS.madsEnabled - def get_sp_common_state(self, cs_out, CS, gear_allowed=True, gap_button=False): - cs_out.cruiseState.enabled = CS.accEnabled if not self.CP.pcmCruise or not self.CP.pcmCruiseSpeed else cs_out.cruiseState.enabled + def get_sp_common_state(self, cs_out, gear_allowed=True, gap_button=False): + cs_out.cruiseState.enabled = self.CS.accEnabled if not self.CP.pcmCruise or not self.CP.pcmCruiseSpeed else cs_out.cruiseState.enabled if not self.enable_mads: - if cs_out.cruiseState.enabled and not CS.out.cruiseState.enabled: - CS.madsEnabled = True - elif not cs_out.cruiseState.enabled and CS.out.cruiseState.enabled: - CS.madsEnabled = False + if cs_out.cruiseState.enabled and not self.CS.out.cruiseState.enabled: + self.CS.madsEnabled = True + elif not cs_out.cruiseState.enabled and self.CS.out.cruiseState.enabled: + self.CS.madsEnabled = False if self.CP.openpilotLongitudinalControl: - self.toggle_exp_mode(gap_button) + self.toggle_exp_mode(gap_button) # TODO-SP: use buttonEvents to handle this, then remove gap_button lane_change_speed_min = get_min_lateral_speed(self.CS.params_list.pause_lateral_speed, self.CS.params_list.is_metric) @@ -643,22 +643,22 @@ class CarInterfaceBase(ABC): cs_out.latActive = gear_allowed - if not CS.control_initialized: - CS.control_initialized = True + if not self.CS.control_initialized: + self.CS.control_initialized = True # Disable on rising edge of gas or brake. Also disable on brake when speed > 0. if (cs_out.gasPressed and not self.CS.out.gasPressed and self.disengage_on_accelerator) or \ (cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)) or \ (cs_out.regenBraking and (not self.CS.out.regenBraking or not cs_out.standstill)): - if CS.madsEnabled: - CS.disengageByBrake = True + if self.CS.madsEnabled: + self.CS.disengageByBrake = True - cs_out.madsEnabled = CS.madsEnabled - cs_out.accEnabled = CS.accEnabled - cs_out.disengageByBrake = CS.disengageByBrake + cs_out.madsEnabled = self.CS.madsEnabled + cs_out.accEnabled = self.CS.accEnabled + cs_out.disengageByBrake = self.CS.disengageByBrake cs_out.brakeLightsDEPRECATED |= cs_out.brakePressed or cs_out.brakeHoldActive or cs_out.parkingBrake or cs_out.regenBraking - return cs_out, CS + return cs_out # TODO: SP: use upstream's buttonEvents counter checks from controlsd def toggle_exp_mode(self, gap_pressed): diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index 1a62a190de..74705d6ab7 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -71,7 +71,7 @@ class CarInterface(CarInterfaceBase): self.CS.accEnabled = False self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled - ret, self.CS = self.get_sp_common_state(ret, self.CS, gap_button=bool(self.CS.distance_button)) + ret = self.get_sp_common_state(ret, gap_button=bool(self.CS.distance_button)) ret.buttonEvents = [ *self.CS.button_events, diff --git a/selfdrive/car/nissan/interface.py b/selfdrive/car/nissan/interface.py index 64c2511c14..ee7f5c9c15 100644 --- a/selfdrive/car/nissan/interface.py +++ b/selfdrive/car/nissan/interface.py @@ -50,7 +50,7 @@ class CarInterface(CarInterfaceBase): self.get_sp_cancel_cruise_state() ret.cruiseState.enabled = ret.cruiseState.enabled if not self.enable_mads else False if self.CP.pcmCruise else self.CS.accEnabled - ret, self.CS = self.get_sp_common_state(ret, self.CS, gap_button=bool(self.CS.distance_button)) + ret = self.get_sp_common_state(ret, gap_button=bool(self.CS.distance_button)) ret.buttonEvents = [ *self.CS.button_events, diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index bc31910ad8..b983394bff 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -140,7 +140,7 @@ class CarInterface(CarInterfaceBase): self.get_sp_cancel_cruise_state() ret.cruiseState.enabled = ret.cruiseState.enabled if not self.enable_mads else False if self.CP.pcmCruise else self.CS.accEnabled - ret, self.CS = self.get_sp_common_state(ret, self.CS) + ret = self.get_sp_common_state(ret) ret.buttonEvents = [ *self.CS.button_events, diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index adce752408..fb29c9ccf3 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -238,7 +238,7 @@ class CarInterface(CarInterfaceBase): if not self.CP.pcmCruise: ret.cruiseState.enabled = self.CS.accEnabled - ret, self.CS = self.get_sp_common_state(ret, self.CS, gap_button=bool(distance_button)) + ret = self.get_sp_common_state(ret, gap_button=bool(distance_button)) ret.buttonEvents = [ *self.CS.button_events, diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py index 75d3b44a4c..6cb7f71f6a 100644 --- a/selfdrive/car/volkswagen/interface.py +++ b/selfdrive/car/volkswagen/interface.py @@ -140,8 +140,7 @@ class CarInterface(CarInterfaceBase): self.CS.accEnabled = False self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled - ret, self.CS = self.get_sp_common_state(ret, self.CS, - gap_button=any(b.type == ButtonType.gapAdjustCruise and b.pressed for b in self.CS.button_events)) + ret = self.get_sp_common_state(ret, gap_button=any(b.type == ButtonType.gapAdjustCruise and b.pressed for b in self.CS.button_events)) ret.buttonEvents = [ *self.CS.button_events,