Skip to content

Commit

Permalink
Toyota: unwind longitudinal integral (#1652)
Browse files Browse the repository at this point in the history
* fix undershoot

* clean up

* maybe fine

* unwind instead

* revert

* up here
  • Loading branch information
sshane authored Jan 22, 2025
1 parent 70aa06d commit 32f3c12
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions opendbc/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# the down limit roughly matches the rate of ACCEL_NET, reducing PCM compensation windup
ACCEL_WINDUP_LIMIT = 4.0 * DT_CTRL * 3 # m/s^2 / frame
ACCEL_WINDDOWN_LIMIT = -4.0 * DT_CTRL * 3 # m/s^2 / frame
ACCEL_PID_UNWIND = 0.03 * DT_CTRL * 3 # m/s^2 / frame

# LKA limits
# EPS faults if you apply torque while the steering rate is above 100 deg/s for too long
Expand Down Expand Up @@ -220,6 +221,9 @@ def update(self, CC, CS, now_nanos):
a_ego_future = a_ego_blended + j_ego * 0.5

if actuators.longControlState == LongCtrlState.pid:
# 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,
Expand Down

0 comments on commit 32f3c12

Please sign in to comment.