|
21 | 21 | # to be overcome to move it at all, this is compensated for too. |
22 | 22 |
|
23 | 23 | KP = 1.0 |
24 | | -KI = 0.1 |
25 | | -KD = 0.3 |
| 24 | +KI = 0.3 |
| 25 | +KD = 0.0 |
26 | 26 | INTERP_SPEEDS = [1, 1.5, 2.0, 3.0, 5, 7.5, 10, 15, 30] |
27 | 27 | KP_INTERP = [250, 120, 65, 30, 11.5, 5.5, 3.5, 2.0, KP] |
28 | 28 |
|
29 | 29 | LP_FILTER_CUTOFF_HZ = 1.2 |
30 | 30 | JERK_LOOKAHEAD_SECONDS = 0.19 |
31 | 31 | JERK_GAIN = 0.3 |
32 | 32 | LAT_ACCEL_REQUEST_BUFFER_SECONDS = 1.0 |
33 | | -VERSION = 1 # bump this when changing controller |
| 33 | +VERSION = 0 # bump this when changing controller |
34 | 34 |
|
35 | 35 | class LatControlTorque(LatControl): |
36 | 36 | def __init__(self, CP, CI, dt): |
@@ -84,17 +84,22 @@ def update(self, active, CS, VM, params, steer_limited_by_safety, desired_curvat |
84 | 84 | measurement_rate = self.measurement_rate_filter.update((measurement - self.previous_measurement) / self.dt) |
85 | 85 | self.previous_measurement = measurement |
86 | 86 |
|
87 | | - error = setpoint - measurement |
| 87 | + error = setpoint - measurement + JERK_GAIN * desired_lateral_jerk |
88 | 88 |
|
89 | 89 | # do error correction in lateral acceleration space, convert at end to handle non-linear torque responses correctly |
90 | 90 | pid_log.error = float(error) |
91 | 91 | ff = gravity_adjusted_future_lateral_accel |
92 | 92 | # latAccelOffset corrects roll compensation bias from device roll misalignment relative to car roll |
93 | 93 | ff -= self.torque_params.latAccelOffset |
94 | | - ff += get_friction(error + JERK_GAIN * desired_lateral_jerk, lateral_accel_deadzone, FRICTION_THRESHOLD, self.torque_params) |
| 94 | + # TODO remove lateral jerk from feed forward - moving it from error means jerk is not scaled by low speed factor |
| 95 | + ff += get_friction(error, lateral_accel_deadzone, FRICTION_THRESHOLD, self.torque_params) |
95 | 96 |
|
96 | 97 | freeze_integrator = steer_limited_by_safety or CS.steeringPressed or CS.vEgo < 5 |
97 | | - output_lataccel = self.pid.update(pid_log.error, -measurement_rate, CS.vEgo, ff, freeze_integrator) |
| 98 | + output_lataccel = self.pid.update(pid_log.error, |
| 99 | + -measurement_rate, |
| 100 | + feedforward=ff, |
| 101 | + speed=CS.vEgo, |
| 102 | + freeze_integrator=freeze_integrator) |
98 | 103 | output_torque = self.torque_from_lateral_accel(output_lataccel, self.torque_params) |
99 | 104 |
|
100 | 105 | pid_log.active = True |
|
0 commit comments