Skip to content

Commit

Permalink
AC_AutoTune: fix tests to work better
Browse files Browse the repository at this point in the history
  • Loading branch information
bnsgeyer committed Apr 9, 2024
1 parent 28dc4bb commit efb7cb1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libraries/AC_AutoTune/AC_AutoTune_Heli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ void AC_AutoTune_Heli::test_init()
case RD_UP:
// initialize start frequency
if (is_zero(start_freq)) {
// continue using frequency where testing left off or RD_UP completed
if (test_phase[12] > 0.0f && test_phase[12] < 180.0f) {
// continue using frequency where testing left off with RD_UP completed
if (test_phase[12] > 0.0f && test_phase[12] < 180.0f && tune_type == RP_UP) {
freq_cnt = 12;
// start with freq found for sweep where phase was 180 deg
} else if (!is_zero(sweep_tgt.ph180.freq)) {
Expand Down Expand Up @@ -260,7 +260,7 @@ void AC_AutoTune_Heli::test_init()
freqresp_mtr.set_dwell_cycles(num_dwell_cycles);
if (!is_zero(start_freq)) {
// time limit set by adding the pre calc cycles with the dwell cycles. 500 ms added to account for settling with buffer.
step_time_limit_ms = (uint32_t) (500 + ((float) freqresp_tgt.get_dwell_cycles() + pre_calc_cycles + 2.0f) * 1000.0f * M_2PI / start_freq);
step_time_limit_ms = (uint32_t) (2000 + ((float) freqresp_tgt.get_dwell_cycles() + pre_calc_cycles + 2.0f) * 1000.0f * M_2PI / start_freq);
}
}
freqresp_tgt.init(input_type, resp_type);
Expand Down Expand Up @@ -1160,7 +1160,7 @@ void AC_AutoTune_Heli::updating_rate_ff_up(float &tune_ff, float *freq, float *g
} else {
if ((gain[frq_cnt] > 0.1 && gain[frq_cnt] < 0.93) || gain[frq_cnt] > 0.98) {
if (tune_ff > 0.0f) {
tune_ff = tune_ff / gain[frq_cnt];
tune_ff = 0.95f * tune_ff / gain[frq_cnt];
} else {
tune_ff = 0.03f;
}
Expand Down

0 comments on commit efb7cb1

Please sign in to comment.