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

APM_Control: AP_RollContoroller: move rate limit #11237

Merged
merged 1 commit into from
May 6, 2019
Merged
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
15 changes: 7 additions & 8 deletions libraries/APM_Control/AP_RollController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ int32_t AP_RollController::_get_rate_out(float desired_rate, float scaler, bool
float kp_ff = MAX((gains.P - gains.I * gains.tau) * gains.tau - gains.D , 0) / eas2tas;
float k_ff = gains.FF / eas2tas;
float delta_time = (float)dt * 0.001f;

// Limit the demanded roll rate
if (gains.rmax && desired_rate < -gains.rmax) {
desired_rate = - gains.rmax;
} else if (gains.rmax && desired_rate > gains.rmax) {
desired_rate = gains.rmax;
}

// Get body rate vector (radians/sec)
float omega_x = _ahrs.get_gyro().x;

Expand Down Expand Up @@ -210,6 +202,13 @@ int32_t AP_RollController::get_servo_out(int32_t angle_err, float scaler, bool d
// Calculate the desired roll rate (deg/sec) from the angle error
float desired_rate = angle_err * 0.01f / gains.tau;

// Limit the demanded roll rate
if (gains.rmax && desired_rate < -gains.rmax) {
desired_rate = - gains.rmax;
} else if (gains.rmax && desired_rate > gains.rmax) {
desired_rate = gains.rmax;
}

return _get_rate_out(desired_rate, scaler, disable_integrator);
}

Expand Down