only send 0 when fully stopped

This commit is contained in:
Jason Wen
2024-07-23 21:53:35 -04:00
parent 597dadd45b
commit a3e60f92cf
+4 -2
View File
@@ -299,7 +299,7 @@ class CarController(CarControllerBase):
# TODO: unclear if this is needed
jerk = 3.0 if actuators.longControlState == LongCtrlState.pid else 1.0
use_fca = self.CP.flags & HyundaiFlags.USE_FCA.value
self.make_accel(accel, actuators)
self.make_accel(CS, accel, actuators)
can_sends.extend(hyundaican.create_acc_commands(self.packer, CC.enabled and CS.out.cruiseState.enabled, self.accel_raw, self.accel_val, self.jerk_l, self.jerk_u, int(self.frame / 2),
hud_control, set_speed_in_units, stopping,
CC.cruiseControl.override, use_fca, CS, escc, self.CP, self.lead_distance, self.cb_lower, self.cb_upper))
@@ -533,12 +533,14 @@ class CarController(CarControllerBase):
self.cb_upper = clip(0.9 + accel * 0.2, 0, 1.2)
self.cb_lower = clip(0.8 + accel * 0.2, 0, 1.2)
def make_accel(self, accel, actuators):
def make_accel(self, CS, accel, actuators):
long_control = actuators.longControlState
self.accel_raw = accel
rate_up, rate_down = 0.1, 0.1
if long_control == LongCtrlState.off:
self.accel_raw, self.accel_val = 0, 0
else:
if long_control == LongCtrlState.stopping and CS.out.standstill:
self.accel_raw = 0
self.accel_val = clip(self.accel_raw, self.accel_last - rate_down, self.accel_last + rate_up)
self.accel_last = self.accel_val