|
|
@ -724,32 +724,26 @@ MulticopterAttitudeControl::control_attitude(float dt) |
|
|
|
|
|
|
|
|
|
|
|
/* limit rates */ |
|
|
|
/* limit rates */ |
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
if (_v_control_mode.flag_control_velocity_enabled && !_v_control_mode.flag_control_manual_enabled) { |
|
|
|
if ((_v_control_mode.flag_control_velocity_enabled || _v_control_mode.flag_control_auto_enabled) && |
|
|
|
|
|
|
|
!_v_control_mode.flag_control_manual_enabled) { |
|
|
|
_rates_sp(i) = math::constrain(_rates_sp(i), -_params.auto_rate_max(i), _params.auto_rate_max(i)); |
|
|
|
_rates_sp(i) = math::constrain(_rates_sp(i), -_params.auto_rate_max(i), _params.auto_rate_max(i)); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_rates_sp(i) = math::constrain(_rates_sp(i), -_params.mc_rate_max(i), _params.mc_rate_max(i)); |
|
|
|
_rates_sp(i) = math::constrain(_rates_sp(i), -_params.mc_rate_max(i), _params.mc_rate_max(i)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* weather-vane mode, dampen yaw rate */ |
|
|
|
|
|
|
|
if (_v_att_sp.disable_mc_yaw_control == true && _v_control_mode.flag_control_velocity_enabled && !_v_control_mode.flag_control_manual_enabled) { |
|
|
|
|
|
|
|
float wv_yaw_rate_max = _params.auto_rate_max(2) * _params.vtol_wv_yaw_rate_scale; |
|
|
|
|
|
|
|
_rates_sp(2) = math::constrain(_rates_sp(2), -wv_yaw_rate_max, wv_yaw_rate_max); |
|
|
|
|
|
|
|
// prevent integrator winding up in weathervane mode
|
|
|
|
|
|
|
|
_rates_int(2) = 0.0f; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* feed forward yaw setpoint rate */ |
|
|
|
/* feed forward yaw setpoint rate */ |
|
|
|
_rates_sp(2) += _v_att_sp.yaw_sp_move_rate * yaw_w * _params.yaw_ff; |
|
|
|
_rates_sp(2) += _v_att_sp.yaw_sp_move_rate * yaw_w * _params.yaw_ff; |
|
|
|
|
|
|
|
|
|
|
|
/* weather-vane mode, scale down yaw rate */ |
|
|
|
/* weather-vane mode, dampen yaw rate */ |
|
|
|
if (_v_att_sp.disable_mc_yaw_control == true && _v_control_mode.flag_control_velocity_enabled && !_v_control_mode.flag_control_manual_enabled) { |
|
|
|
if ((_v_control_mode.flag_control_velocity_enabled || _v_control_mode.flag_control_auto_enabled) && |
|
|
|
|
|
|
|
_v_att_sp.disable_mc_yaw_control == true && !_v_control_mode.flag_control_manual_enabled) { |
|
|
|
float wv_yaw_rate_max = _params.auto_rate_max(2) * _params.vtol_wv_yaw_rate_scale; |
|
|
|
float wv_yaw_rate_max = _params.auto_rate_max(2) * _params.vtol_wv_yaw_rate_scale; |
|
|
|
_rates_sp(2) = math::constrain(_rates_sp(2), -wv_yaw_rate_max, wv_yaw_rate_max); |
|
|
|
_rates_sp(2) = math::constrain(_rates_sp(2), -wv_yaw_rate_max, wv_yaw_rate_max); |
|
|
|
// prevent integrator winding up in weathervane mode
|
|
|
|
// prevent integrator winding up in weathervane mode
|
|
|
|
_rates_int(2) = 0.0f; |
|
|
|
_rates_int(2) = 0.0f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|