Skip to content

Commit a19fac6

Browse files
committed
actuator: Avoid zero-crossing throttle. Properly this time.
1 parent 778fce6 commit a19fac6

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

flight/Modules/Actuator/actuator.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,12 +1217,11 @@ static void smithp_compensate(struct smith_predictor *m, float *desired_vect)
12171217
region, that makes throttle eventually oscillate around the zero point under certain conditions.
12181218
This leads to funny business with the motors, e.g. grinding. */
12191219
float t = desired_vect[i];
1220-
if ((t >= THROTTLE_EPSILON && (t+v) < THROTTLE_EPSILON) ||
1221-
(t <= -THROTTLE_EPSILON && (t+v) > -THROTTLE_EPSILON)) {
1222-
v = 0;
1223-
}
1224-
/* Also bound throttle. */
1225-
desired_vect[i] = bound_sym(desired_vect[i] + v, 1.0f);
1220+
float r = t+v;
1221+
1222+
/* Don't cross zero via prediction. Also bound throttle. */
1223+
if (sign(t) == sign(r))
1224+
desired_vect[i] = bound_sym(r, 1.0f);
12261225
} else {
12271226
desired_vect[i] += v;
12281227
}

0 commit comments

Comments
 (0)