diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py index 2816b20149794bb..ddd7a743b16554a 100644 --- a/selfdrive/controls/lib/latcontrol_torque.py +++ b/selfdrive/controls/lib/latcontrol_torque.py @@ -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) @@ -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