Skip to content

Commit

Permalink
card: fix cruise speed initialization w/ buttons (#34386)
Browse files Browse the repository at this point in the history
* fix initialize w/ buttons

* what

* comment
  • Loading branch information
sshane authored Jan 15, 2025
1 parent b3fc407 commit 38fad75
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion selfdrive/car/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 38fad75

Please sign in to comment.