Skip to content
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

MC rate controller: add I term reduction factor #12296

Merged
merged 2 commits into from
Jun 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ROMFS/px4fmu_common/init.d/airframes/4041_beta75x
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ then

param set MC_AIRMODE 2
param set MC_PITCHRATE_D 0.0010
param set MC_PITCHRATE_I 0.4
param set MC_PITCHRATE_I 0.5
param set MC_PITCHRATE_MAX 600
param set MC_PITCHRATE_P 0.0750
param set MC_PITCH_P 6
Expand Down
2 changes: 1 addition & 1 deletion ROMFS/px4fmu_common/init.d/airframes/4050_generic_250
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ $AUTOCNF = yes ]
then
param set MC_ROLL_P 8
param set MC_ROLLRATE_P 0.08
param set MC_ROLLRATE_I 0.2
param set MC_ROLLRATE_I 0.25
param set MC_ROLLRATE_D 0.001
param set MC_PITCH_P 8
param set MC_PITCHRATE_P 0.08
Expand Down
4 changes: 2 additions & 2 deletions ROMFS/px4fmu_common/init.d/airframes/4052_holybro_qav250
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ then

param set MC_AIRMODE 1
param set MC_PITCHRATE_D 0.0012
param set MC_PITCHRATE_I 0.25
param set MC_PITCHRATE_I 0.35
param set MC_PITCHRATE_MAX 1200
param set MC_PITCHRATE_P 0.082
param set MC_PITCH_P 8
param set MC_ROLLRATE_D 0.0012
param set MC_ROLLRATE_I 0.2
param set MC_ROLLRATE_I 0.3
param set MC_ROLLRATE_MAX 1200
param set MC_ROLLRATE_P 0.076
param set MC_ROLL_P 8
Expand Down
11 changes: 10 additions & 1 deletion src/modules/mc_att_control/mc_att_control_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,17 @@ MulticopterAttitudeControl::control_attitude_rates(float dt)

}

// I term factor: reduce the I gain with increasing rate error.
// This counteracts a non-linear effect where the integral builds up quickly upon a large setpoint
// change (noticeable in a bounce-back effect after a flip).
// The formula leads to a gradual decrease w/o steps, while only affecting the cases where it should:
// with the parameter set to 400 degrees, up to 100 deg rate error, i_factor is almost 1 (having no effect),
// and up to 200 deg error leads to <25% reduction of I.
float i_factor = rates_err(i) / math::radians(400.f);
i_factor = math::max(0.0f, 1.f - i_factor * i_factor);

// Perform the integration using a first order method and do not propagate the result if out of range or invalid
float rate_i = _rates_int(i) + rates_i_scaled(i) * rates_err(i) * dt;
float rate_i = _rates_int(i) + i_factor * rates_i_scaled(i) * rates_err(i) * dt;

if (PX4_ISFINITE(rate_i) && rate_i > -_rate_int_lim(i) && rate_i < _rate_int_lim(i)) {
_rates_int(i) = rate_i;
Expand Down