Skip to content

Commit 40f37f3

Browse files
committed
actuator: Avoid zero-crossing throttle. Part Trois.
1 parent 778fce6 commit 40f37f3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

flight/Modules/Actuator/actuator.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -1216,13 +1216,14 @@ static void smithp_compensate(struct smith_predictor *m, float *desired_vect)
12161216
/* This predictive stuff is noisy and can apparently cause some feedback in the low throttle
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. */
1219-
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);
1219+
float r = desired_vect[i]+v;
1220+
float s = sign(desired_vect[i]);
1221+
1222+
/* Don't cross zero via prediction. Also bound throttle. */
1223+
if (sign(r) != s)
1224+
desired_vect[i] = s*THROTTLE_EPSILON;
1225+
else
1226+
desired_vect[i] = bound_sym(r, 1.0f);
12261227
} else {
12271228
desired_vect[i] += v;
12281229
}

0 commit comments

Comments
 (0)