Skip to content

Commit

Permalink
actuator: Avoid zero-crossing throttle. Properly this time.
Browse files Browse the repository at this point in the history
  • Loading branch information
glowtape committed Apr 19, 2018
1 parent 778fce6 commit a19fac6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions flight/Modules/Actuator/actuator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,12 +1217,11 @@ static void smithp_compensate(struct smith_predictor *m, float *desired_vect)
region, that makes throttle eventually oscillate around the zero point under certain conditions.
This leads to funny business with the motors, e.g. grinding. */
float t = desired_vect[i];
if ((t >= THROTTLE_EPSILON && (t+v) < THROTTLE_EPSILON) ||
(t <= -THROTTLE_EPSILON && (t+v) > -THROTTLE_EPSILON)) {
v = 0;
}
/* Also bound throttle. */
desired_vect[i] = bound_sym(desired_vect[i] + v, 1.0f);
float r = t+v;

/* Don't cross zero via prediction. Also bound throttle. */
if (sign(t) == sign(r))
desired_vect[i] = bound_sym(r, 1.0f);
} else {
desired_vect[i] += v;
}
Expand Down

0 comments on commit a19fac6

Please sign in to comment.