Skip to content

Commit

Permalink
Latcontrol torque: integrator need not be reset (commaai#24606)
Browse files Browse the repository at this point in the history
slow integrators need not be reset
  • Loading branch information
haraschax authored and Casey Francis committed May 22, 2022
1 parent bf3454a commit 5202696
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions selfdrive/controls/lib/latcontrol_torque.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def update(self, active, CS, CP, VM, params, last_actuators, desired_curvature,
if CS.vEgo < MIN_STEER_SPEED or not active:
output_torque = 0.0
pid_log.active = False
self.pid.reset()
else:
if self.use_steering_angle:
actual_curvature = -VM.calc_curvature(math.radians(CS.steeringAngleDeg - params.angleOffsetDeg), CS.vEgo, params.roll)
Expand All @@ -59,10 +58,14 @@ def update(self, active, CS, CP, VM, params, last_actuators, desired_curvature,
pid_log.error = error

ff = desired_lateral_accel - params.roll * ACCELERATION_DUE_TO_GRAVITY
# convert friction into lateral accel units for feedforward
friction_compensation = interp(desired_lateral_jerk, [-JERK_THRESHOLD, JERK_THRESHOLD], [-self.friction, self.friction])
ff += friction_compensation / self.kf
freeze_integrator = CS.steeringRateLimited or CS.steeringPressed or CS.vEgo < 5
output_torque = self.pid.update(error,
override=CS.steeringPressed, feedforward=ff,
feedforward=ff,
speed=CS.vEgo,
freeze_integrator=CS.steeringRateLimited)
freeze_integrator=freeze_integrator)

friction_compensation = interp(desired_lateral_jerk, [-JERK_THRESHOLD, JERK_THRESHOLD], [-self.friction, self.friction])
output_torque += friction_compensation
Expand Down

0 comments on commit 5202696

Please sign in to comment.