Skip to content

Commit

Permalink
Toyota: fix acceleration discontinuity when stopping (#1664)
Browse files Browse the repository at this point in the history
fix jumping when stopping
  • Loading branch information
sshane authored Jan 25, 2025
1 parent 00bb29c commit b949b43
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions opendbc/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,15 @@ def update(self, CC, CS, now_nanos):
j_ego = (self.aego.x - prev_aego) / (DT_CTRL * 3)
a_ego_future = a_ego_blended + j_ego * 0.5

if actuators.longControlState == LongCtrlState.pid:
if CC.longActive:
# constantly slowly unwind integral to recover from large temporary errors
self.long_pid.i -= ACCEL_PID_UNWIND * float(np.sign(self.long_pid.i))

error_future = pcm_accel_cmd - a_ego_future
pcm_accel_cmd = self.long_pid.update(error_future,
speed=CS.out.vEgo,
feedforward=pcm_accel_cmd)
feedforward=pcm_accel_cmd,
freeze_integrator=actuators.longControlState != LongCtrlState.pid)
else:
self.long_pid.reset()

Expand Down

0 comments on commit b949b43

Please sign in to comment.