diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index e093b5e0d0..6d0f1e0c60 100755 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -121,6 +121,9 @@ class Car: MadsParams().set_alternative_experience(self.CP) MadsParams().set_car_specific_params(self.CP) + # Dynamic Experimental Control + self.dynamic_experimental_control = self.params.get_bool("DynamicExperimentalControl") + openpilot_enabled_toggle = self.params.get_bool("OpenpilotEnabledToggle") controller_available = self.CI.CC is not None and openpilot_enabled_toggle and not self.CP.dashcamOnly @@ -248,7 +251,7 @@ class Car: CS, RD = self.state_update() if self.sm['carControl'].enabled and not self.CC_prev.enabled: - self.v_cruise_helper.initialize_v_cruise(CS, self.experimental_mode) + self.v_cruise_helper.initialize_v_cruise(CS, self.experimental_mode,self.dynamic_experimental_control) self.state_publish(CS, RD) @@ -263,6 +266,10 @@ class Car: while not evt.is_set(): self.is_metric = self.params.get_bool("IsMetric") self.experimental_mode = self.params.get_bool("ExperimentalMode") and self.CP.openpilotLongitudinalControl + + # sunnypilot + self.dynamic_experimental_control = self.params.get_bool("DynamicExperimentalControl") + time.sleep(0.1) def card_thread(self): diff --git a/selfdrive/car/cruise.py b/selfdrive/car/cruise.py index b92d0c7465..bd1bec39a3 100644 --- a/selfdrive/car/cruise.py +++ b/selfdrive/car/cruise.py @@ -120,12 +120,13 @@ class VCruiseHelper: self.button_timers[b.type.raw] = 1 if b.pressed else 0 self.button_change_states[b.type.raw] = {"standstill": CS.cruiseState.standstill, "enabled": enabled} - def initialize_v_cruise(self, CS, experimental_mode: bool) -> None: + def initialize_v_cruise(self, CS, experimental_mode: bool, dynamic_experimental_control: bool) -> None: # initializing is handled by the PCM if self.CP.pcmCruise: return - initial = V_CRUISE_INITIAL_EXPERIMENTAL_MODE if experimental_mode else V_CRUISE_INITIAL + initial_experimental_mode = experimental_mode and not dynamic_experimental_control + initial = V_CRUISE_INITIAL_EXPERIMENTAL_MODE if initial_experimental_mode else V_CRUISE_INITIAL if any(b.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for b in CS.buttonEvents) and self.v_cruise_initialized: self.v_cruise_kph = self.v_cruise_kph_last