From 0ced91c9829544a4955f4991d8ce49ae15b73dab Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Tue, 13 Aug 2024 01:05:16 -0400 Subject: [PATCH] better --- selfdrive/car/interfaces.py | 2 -- selfdrive/controls/controlsd.py | 12 +++++++----- selfdrive/controls/lib/drive_helpers.py | 13 ------------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index dbddb38c0e..77608de820 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -244,8 +244,6 @@ class CarInterfaceBase(ABC): self.cruise_cancelled_btn = True self.prev_acc_mads_combo = False self.mads_event_lock = True - self.gap_button_counter = 0 - self.experimental_mode_hold = False self.last_mads_init = 0. self.madsEnabledInit = False self.madsEnabledInitPrev = False diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 8367cca979..7d4beb4b66 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -719,16 +719,18 @@ class Controls: # toggle experimental mode once on distance button hold if self.CP.openpilotLongitudinalControl: - if self.v_cruise_helper.experimental_mode_update and self.v_cruise_helper.button_timers[ButtonType.gapAdjustCruise] == CRUISE_LONG_PRESS: + if self.v_cruise_helper.button_timers[ButtonType.gapAdjustCruise] == CRUISE_LONG_PRESS and \ + not self.v_cruise_helper.experimental_mode_update: self.experimental_mode = not self.experimental_mode self.params.put_bool_nonblocking("ExperimentalMode", self.experimental_mode) + self.v_cruise_helper.experimental_mode_update = True # decrement personality on distance button press if self.CP.openpilotLongitudinalControl: - if any(not be.pressed and be.type == ButtonType.gapAdjustCruise for be in CS.buttonEvents) and \ - not self.v_cruise_helper.experimental_mode_update: - self.personality = (self.personality - 1) % 3 - self.params.put_nonblocking('LongitudinalPersonality', str(self.personality)) + if any(not be.pressed and be.type == ButtonType.gapAdjustCruise for be in CS.buttonEvents): + if not self.v_cruise_helper.experimental_mode_update: + self.personality = (self.personality - 1) % 3 + self.params.put_nonblocking('LongitudinalPersonality', str(self.personality)) self.v_cruise_helper.experimental_mode_update = False return CC, lac_log diff --git a/selfdrive/controls/lib/drive_helpers.py b/selfdrive/controls/lib/drive_helpers.py index cc5d19209c..f73572b228 100644 --- a/selfdrive/controls/lib/drive_helpers.py +++ b/selfdrive/controls/lib/drive_helpers.py @@ -98,9 +98,6 @@ class VCruiseHelper: self._update_v_cruise_min(is_metric) if CS.cruiseState.available: - if self.CP.openpilotLongitudinalControl: - self._update_experimental_mode(CS) - if not self.CP.pcmCruise or not self.CP.pcmCruiseSpeed: # if stock cruise is completely disabled, then we can use our own set speed logic self._update_v_cruise_non_pcm(CS, enabled, is_metric, reverse_acc) @@ -242,16 +239,6 @@ class VCruiseHelper: self.v_cruise_min = VOLKSWAGEN_V_CRUISE_MIN[is_metric] self.is_metric_prev = is_metric - def _update_experimental_mode(self, CS): - for b in CS.buttonEvents: - if b.type == ButtonType.gapAdjustCruise and not b.pressed: - if self.button_timers[ButtonType.gapAdjustCruise] > CRUISE_LONG_PRESS: - return # end long press - break - else: - if self.button_timers[ButtonType.gapAdjustCruise] and self.button_timers[ButtonType.gapAdjustCruise] == CRUISE_LONG_PRESS: - self.experimental_mode_update = True - def clip_curvature(v_ego, prev_curvature, new_curvature): v_ego = max(MIN_SPEED, v_ego)