Skip to content

Commit

Permalink
AC_Autotune: Fix bug introduced in #27370
Browse files Browse the repository at this point in the history
  • Loading branch information
lthall authored and peterbarker committed Aug 6, 2024
1 parent 14b505c commit a4a9113
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libraries/AC_AutoTune/AC_AutoTune_Multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,7 @@ void AC_AutoTune_Multi::twitch_test_init()
test_rate_min = 0.0;
test_angle_max = 0.0;
test_angle_min = 0.0;
accel_measure_rate_max = 0.0;
}

//run twitch test
Expand Down Expand Up @@ -1315,18 +1316,18 @@ void AC_AutoTune_Multi::twitch_test_run(AxisType test_axis, const float dir_sign
case RD_UP:
case RD_DOWN:
twitching_test_rate(lean_angle, rotation_rate, target_rate, test_rate_min, test_rate_max, test_angle_min);
twitching_measure_acceleration(test_accel_max, rotation_rate, test_rate_max);
twitching_measure_acceleration(test_accel_max, rotation_rate, accel_measure_rate_max);
twitching_abort_rate(lean_angle, rotation_rate, angle_abort, test_rate_min, test_angle_min);
break;
case RP_UP:
twitching_test_rate(lean_angle, rotation_rate, target_rate * (1 + 0.5 * aggressiveness), test_rate_min, test_rate_max, test_angle_min);
twitching_measure_acceleration(test_accel_max, rotation_rate, test_rate_max);
twitching_measure_acceleration(test_accel_max, rotation_rate, accel_measure_rate_max);
twitching_abort_rate(lean_angle, rotation_rate, angle_abort, test_rate_min, test_angle_min);
break;
case SP_DOWN:
case SP_UP:
twitching_test_angle(lean_angle, rotation_rate, target_angle * (1 + 0.5 * aggressiveness), test_angle_min, test_angle_max, test_rate_min, test_rate_max);
twitching_measure_acceleration(test_accel_max, rotation_rate - dir_sign * start_rate, test_rate_max);
twitching_measure_acceleration(test_accel_max, rotation_rate - dir_sign * start_rate, accel_measure_rate_max);
break;
case RFF_UP:
case MAX_GAINS:
Expand Down
1 change: 1 addition & 0 deletions libraries/AC_AutoTune/AC_AutoTune_Multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class AC_AutoTune_Multi : public AC_AutoTune
float test_rate_max; // the maximum angular rate achieved during TESTING_RATE
float test_angle_min; // the minimum angle achieved during TESTING_ANGLE
float test_angle_max; // the maximum angle achieved during TESTING_ANGLE
float accel_measure_rate_max; // the maximum rate used to measure average acceleration during twitch
};

#endif // AC_AUTOTUNE_ENABLED

0 comments on commit a4a9113

Please sign in to comment.