mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 06:53:33 +08:00
fw att control: bugfixes for integrator
This commit is contained in:
@@ -116,8 +116,7 @@ float ECL_PitchController::control_bodyrate(float roll, float pitch,
|
||||
/* get the usual dt estimate */
|
||||
uint64_t dt_micros = ecl_elapsed_time(&_last_run);
|
||||
_last_run = ecl_absolute_time();
|
||||
|
||||
float dt = dt_micros / 1000000;
|
||||
float dt = (dt_micros > 500000) ? 0.0f : (float)dt_micros * 1e-6f;
|
||||
|
||||
/* lock integral for long intervals */
|
||||
if (dt_micros > 500000)
|
||||
@@ -142,11 +141,9 @@ float ECL_PitchController::control_bodyrate(float roll, float pitch,
|
||||
|
||||
_rate_error = _bodyrate_setpoint - pitch_bodyrate;
|
||||
|
||||
float ilimit_scaled = 0.0f;
|
||||
|
||||
if (!lock_integrator && k_i_rate > 0.0f && airspeed > 0.5f * airspeed_min) {
|
||||
|
||||
float id = _rate_error * k_i_rate * dt * scaler;
|
||||
float id = _rate_error * dt;
|
||||
|
||||
/*
|
||||
* anti-windup: do not allow integrator to increase into the
|
||||
@@ -164,9 +161,9 @@ float ECL_PitchController::control_bodyrate(float roll, float pitch,
|
||||
}
|
||||
|
||||
/* integrator limit */
|
||||
_integrator = math::constrain(_integrator, -ilimit_scaled, ilimit_scaled);
|
||||
_integrator = math::constrain(_integrator, -_integrator_max, _integrator_max);
|
||||
/* store non-limited output */
|
||||
_last_output = ((_rate_error * _k_d * scaler) + _integrator + (_rate_setpoint * k_roll_ff)) * scaler;
|
||||
_last_output = ((_rate_error * _k_d * scaler) + _integrator * k_i_rate * scaler + (_rate_setpoint * k_roll_ff)) * scaler;
|
||||
|
||||
return math::constrain(_last_output, -_max_deflection_rad, _max_deflection_rad);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user