Skip to content

Commit

Permalink
Toyota: remove longitudinal derivative (commaai#1635)
Browse files Browse the repository at this point in the history
* rm deriv

* do less
  • Loading branch information
sshane authored Jan 14, 2025
1 parent 92d3e7e commit 43168b3
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions opendbc/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@

def get_long_tune(CP, params):
kiBP = [0.]
kdBP = [0.]
kdV = [0.]
if CP.carFingerprint in TSS2_CAR:
kiV = [0.25]
kdV = [0.25 / 4]

else:
kiBP = [0., 5., 35.]
kiV = [3.6, 2.4, 1.5]

return PIDController(0.0, (kiBP, kiV), k_f=1.0, k_d=(kdBP, kdV),
return PIDController(0.0, (kiBP, kiV), k_f=1.0,
pos_limit=params.ACCEL_MAX, neg_limit=params.ACCEL_MIN,
rate=1 / (DT_CTRL * 3))

Expand All @@ -69,12 +66,7 @@ def __init__(self, dbc_names, CP):

# *** start long control state ***
self.long_pid = get_long_tune(self.CP, self.params)

self.error_rate = FirstOrderFilter(0.0, 0.5, DT_CTRL * 3)
self.prev_error = 0.0

self.aego = FirstOrderFilter(0.0, 0.25, DT_CTRL * 3)

self.pitch = FirstOrderFilter(0, 0.5, DT_CTRL)

self.accel = 0
Expand Down Expand Up @@ -228,18 +220,12 @@ def update(self, CC, CS, now_nanos):
a_ego_future = a_ego_blended + j_ego * 0.5

if actuators.longControlState == LongCtrlState.pid:
error = pcm_accel_cmd - a_ego_blended
self.error_rate.update((error - self.prev_error) / (DT_CTRL * 3))
self.prev_error = error

error_future = pcm_accel_cmd - a_ego_future
pcm_accel_cmd = self.long_pid.update(error_future, error_rate=self.error_rate.x,
pcm_accel_cmd = self.long_pid.update(error_future,
speed=CS.out.vEgo,
feedforward=pcm_accel_cmd)
else:
self.long_pid.reset()
self.error_rate.x = 0.0
self.prev_error = 0.0

# Along with rate limiting positive jerk above, this greatly improves gas response time
# Consider the net acceleration request that the PCM should be applying (pitch included)
Expand Down

0 comments on commit 43168b3

Please sign in to comment.