From 38fad751cb5f52a82b24b067c112baf4ab01e160 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 14 Jan 2025 19:58:22 -0800 Subject: [PATCH] card: fix cruise speed initialization w/ buttons (#34386) * fix initialize w/ buttons * what * comment --- selfdrive/car/card.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index 0b0631bc2b610a..3ed835a1f5dd20 100755 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -72,6 +72,7 @@ def __init__(self, CI=None, RI=None) -> None: self.can_rcv_cum_timeout_counter = 0 self.CC_prev = car.CarControl.new_message() + self.CS_prev = car.CarState.new_message() self.initialized_prev = False self.last_actuators_output = structs.CarControl.Actuators() @@ -182,7 +183,8 @@ def state_update(self) -> tuple[car.CarState, structs.RadarDataT | None]: self.v_cruise_helper.update_v_cruise(CS, self.sm['carControl'].enabled, self.is_metric) if self.sm['carControl'].enabled and not self.CC_prev.enabled: - self.v_cruise_helper.initialize_v_cruise(CS, self.experimental_mode) + # Use CarState w/ buttons from the step selfdrived enables on + self.v_cruise_helper.initialize_v_cruise(self.CS_prev, self.experimental_mode) # TODO: mirror the carState.cruiseState struct? CS.vCruise = float(self.v_cruise_helper.v_cruise_kph) @@ -249,6 +251,7 @@ def step(self): self.controls_update(CS, self.sm['carControl']) self.initialized_prev = initialized + self.CS_prev = CS def params_thread(self, evt): while not evt.is_set():