-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heli AutoTune: fix rate and accel limiting #28911
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -528,9 +528,9 @@ void AC_AutoTune_Heli::load_test_gains() | |
rate_test_max = orig_roll_rate; | ||
accel_test_max = tune_roll_accel; | ||
} else { | ||
// have attitude controller use accel and rate limit parameter | ||
rate_test_max = rate_max; | ||
accel_test_max = accel_max; | ||
// have attitude controller not perform rate limiting and angle P scaling based on accel max | ||
rate_test_max = 0.0; | ||
accel_test_max = 0.0; | ||
} | ||
if (tune_type == SP_UP || tune_type == TUNE_CHECK) { | ||
rate_i = tune_roll_rff*AUTOTUNE_FFI_RATIO_FINAL; | ||
|
@@ -552,9 +552,9 @@ void AC_AutoTune_Heli::load_test_gains() | |
rate_test_max = orig_pitch_rate; | ||
accel_test_max = tune_pitch_accel; | ||
} else { | ||
// have attitude controller use accel and rate limit parameter | ||
rate_test_max = rate_max; | ||
accel_test_max = accel_max; | ||
// have attitude controller not perform rate limiting and angle P scaling based on accel max | ||
rate_test_max = 0.0; | ||
accel_test_max = 0.0; | ||
} | ||
if (tune_type == SP_UP || tune_type == TUNE_CHECK) { | ||
rate_i = tune_pitch_rff*AUTOTUNE_FFI_RATIO_FINAL; | ||
|
@@ -577,9 +577,9 @@ void AC_AutoTune_Heli::load_test_gains() | |
rate_test_max = orig_yaw_rate; | ||
accel_test_max = tune_yaw_accel; | ||
} else { | ||
// have attitude controller use accel and rate limit parameter | ||
rate_test_max = rate_max; | ||
accel_test_max = accel_max; | ||
// have attitude controller not perform rate limiting and angle P scaling based on accel max | ||
rate_test_max = 0.0; | ||
accel_test_max = 0.0; | ||
} | ||
if (tune_type == SP_UP || tune_type == TUNE_CHECK) { | ||
rate_i = tune_yaw_rp*AUTOTUNE_YAW_PI_RATIO_FINAL; | ||
|
@@ -811,7 +811,22 @@ void AC_AutoTune_Heli::dwell_test_run(sweep_info &test_data) | |
} | ||
|
||
if (settle_time == 0) { | ||
target_angle_cd = -chirp_input.update((now - dwell_start_time_ms) * 0.001, degrees(tgt_attitude) * 100.0f); | ||
dwell_freq = chirp_input.get_frequency_rads(); | ||
float tgt_att_limited = tgt_attitude; | ||
if (is_positive(dwell_freq)) { | ||
float tgt_att_temp = tgt_attitude; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need the extra variable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lthall I think it is needed to hold the rate limited attitude. If the rate limit is not set then it will skip setting tgt_att_temp variable. I guess I could just use the tgt_att_limited variable throughout and keep setting it from the MIN function. |
||
if (is_positive(rate_max)) { | ||
float ang_limit_rate = radians(rate_max) / dwell_freq; | ||
tgt_att_temp = MIN(ang_limit_rate, tgt_attitude); | ||
} | ||
if (is_positive(accel_max)) { | ||
float ang_limit_accel = radians(accel_max) / sq(dwell_freq); | ||
tgt_att_limited = MIN(ang_limit_accel, tgt_att_temp); | ||
} else { | ||
tgt_att_limited = tgt_att_temp; | ||
} | ||
} | ||
target_angle_cd = -chirp_input.update((now - dwell_start_time_ms) * 0.001, degrees(tgt_att_limited) * 100.0f); | ||
dwell_freq = chirp_input.get_frequency_rads(); | ||
const Vector2f att_fdbk { | ||
-5730.0f * vel_hold_gain * velocity_bf.y, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are limiting the chirp then we shouldn't be hitting these limits unless there is a plot input.
I am not very familiar with how you handle pilot input here but it may be dangerous if you don't have acceleration limiting and do accept pilot input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lthall Pilot input is not allowed during the autotune input. It works just like multi autotune where once the pilot makes inputs, the autotune maneuver is stopped.