|
19 | 19 | # move it at all, this is compensated for too. |
20 | 20 |
|
21 | 21 |
|
22 | | -LOW_SPEED_FACTOR = 200 |
23 | | -JERK_THRESHOLD = 0.2 |
| 22 | +FRICTION_THRESHOLD = 0.2 |
24 | 23 |
|
25 | 24 |
|
26 | 25 | def set_torque_tune(tune, MAX_LAT_ACCEL=2.5, FRICTION=0.01, steering_angle_deadzone_deg=0.0): |
@@ -66,14 +65,16 @@ def update(self, active, CS, VM, params, last_actuators, desired_curvature, desi |
66 | 65 | actual_lateral_accel = actual_curvature * CS.vEgo ** 2 |
67 | 66 | lateral_accel_deadzone = curvature_deadzone * CS.vEgo ** 2 |
68 | 67 |
|
69 | | - setpoint = desired_lateral_accel + LOW_SPEED_FACTOR * desired_curvature |
70 | | - measurement = actual_lateral_accel + LOW_SPEED_FACTOR * actual_curvature |
| 68 | + |
| 69 | + low_speed_factor = interp(CS.vEgo, [0, 15], [500, 0]) |
| 70 | + setpoint = desired_lateral_accel + low_speed_factor * desired_curvature |
| 71 | + measurement = actual_lateral_accel + low_speed_factor * actual_curvature |
71 | 72 | error = apply_deadzone(setpoint - measurement, lateral_accel_deadzone) |
72 | 73 | pid_log.error = error |
73 | 74 |
|
74 | 75 | ff = desired_lateral_accel - params.roll * ACCELERATION_DUE_TO_GRAVITY |
75 | 76 | # convert friction into lateral accel units for feedforward |
76 | | - friction_compensation = interp(error, [-JERK_THRESHOLD, JERK_THRESHOLD], [-self.friction, self.friction]) |
| 77 | + friction_compensation = interp(error, [-FRICTION_THRESHOLD, FRICTION_THRESHOLD], [-self.friction, self.friction]) |
77 | 78 | ff += friction_compensation / self.kf |
78 | 79 | freeze_integrator = CS.steeringRateLimited or CS.steeringPressed or CS.vEgo < 5 |
79 | 80 | output_torque = self.pid.update(error, |
|
0 commit comments