File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments