Skip to content

Commit cc7275b

Browse files
committed
pbio/drivebase: Update changed control settings.
New control settings were introduced in the previous commit, so drive bases must get appropriate values too or we get undefined behavior. Now we can also drop the "hack" of dividing the proportional gain by four, which was originally done to make drivebases run smoother at low speeds. This is now accomplished by handling low speed in the controllers explicitly.
1 parent 0ebf103 commit cc7275b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/pbio/src/drivebase.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ static void drivebase_adopt_settings(pbio_control_settings_t *s_distance, pbio_c
6363
s_distance->deceleration = pbio_int_math_min(s_left->deceleration, s_right->deceleration) * 3 / 4;
6464

6565
// Use minimum PID of both motors, to avoid overly aggressive control if
66-
// one of the two motors has much higher PID values. For proportional
67-
// control, take a much lower gain. Drivebases don't need it, and it makes
68-
// for a smoother ride.
69-
s_distance->pid_kp = pbio_int_math_min(s_left->pid_kp, s_right->pid_kp) / 4;
66+
// one of the two motors has much higher PID values.
67+
s_distance->pid_kp = pbio_int_math_min(s_left->pid_kp, s_right->pid_kp);
7068
s_distance->pid_kd = pbio_int_math_min(s_left->pid_kd, s_right->pid_kd);
7169

72-
// Integral control is not necessary since there is constant external
70+
// Use the same thresholds for reduced proportional gain.
71+
s_distance->pid_kp_low_pct = pbio_int_math_min(s_left->pid_kp_low_pct, s_right->pid_kp_low_pct);
72+
s_distance->pid_kp_low_error_threshold = pbio_int_math_min(s_left->pid_kp_low_error_threshold, s_right->pid_kp_low_error_threshold);
73+
s_distance->pid_kp_low_speed_threshold = pbio_int_math_min(s_left->pid_kp_low_speed_threshold, s_right->pid_kp_low_speed_threshold);
74+
75+
// Integral control is not necessary since there is no constant external
7376
// force to overcome that wouldn't be done by proportional control.
7477
s_distance->pid_ki = 0;
7578

0 commit comments

Comments
 (0)