Skip to content

Commit 241d738

Browse files
committed
actuator: Make sure throttle is fine after the Smith predictor.
1 parent 5874ba4 commit 241d738

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

flight/Modules/Actuator/actuator.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ DONT_BUILD_IF((MIXERSETTINGS_MIXER1VECTOR_NUMELEM - MIXERSETTINGS_MIXER1VECTOR_A
7676

7777
#define MIXER_SCALE 128
7878
#define ACTUATOR_EPSILON 0.00001f
79+
#define THROTTLE_EPSILON 0.000001f
7980

8081
// Private types
8182

@@ -1209,7 +1210,23 @@ static void smithp_compensate(struct smith_predictor *m, float *desired_vect)
12091210
1);
12101211

12111212
for (int i = 0; i < MIXERSETTINGS_MIXER1VECTOR_NUMELEM; i++) {
1212-
desired_vect[i] += m->mix * (desired_vect[i] - inv[i]);
1213+
float v = m->mix * (desired_vect[i] - inv[i]);
1214+
1215+
if (i == MIXERSETTINGS_MIXER1VECTOR_THROTTLECURVE1) {
1216+
/* This predictive stuff is noisy and can apparently cause some feedback in the low throttle
1217+
region, that makes throttle eventually oscillate around the zero point under certain conditions.
1218+
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);
1226+
} else {
1227+
desired_vect[i] += v;
1228+
}
1229+
12131230
}
12141231
}
12151232

0 commit comments

Comments
 (0)