mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-07 14:50:35 +08:00
Saturate velocity command for mc_pos_control.
This commit is contained in:
committed by
Lorenz Meier
parent
5727985678
commit
adbccfaa1c
@@ -1032,7 +1032,14 @@ MulticopterPositionControl::task_main()
|
||||
/* run position & altitude controllers, calculate velocity setpoint */
|
||||
math::Vector<3> pos_err = _pos_sp - _pos;
|
||||
|
||||
/* make sure velocity setpoint is saturated */
|
||||
_vel_sp = pos_err.emult(_params.pos_p) + _vel_ff;
|
||||
for (int i=0; i<3; i++) {
|
||||
if (_vel_sp(i) > _params.vel_max(i)) {
|
||||
_vel_sp(i) = _params.vel_max(i);
|
||||
} else if (_vel_sp(i) < -_params.vel_max(i))
|
||||
_vel_sp(i) = -_params.vel_max(i);
|
||||
}
|
||||
|
||||
if (!_control_mode.flag_control_altitude_enabled) {
|
||||
_reset_alt_sp = true;
|
||||
|
||||
Reference in New Issue
Block a user