mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-06 13:18:52 +08:00
mc_pos_control: AUTO speed limiting bug fixed
This commit is contained in:
@@ -829,10 +829,12 @@ MulticopterPositionControl::control_auto(float dt)
|
||||
|
||||
/* move setpoint not faster than max allowed speed */
|
||||
math::Vector<3> pos_sp_old_s = _pos_sp.emult(scale);
|
||||
math::Vector<3> d_pos_s = pos_sp_s - pos_sp_old_s;
|
||||
float d_pos_s_len = d_pos_s.length();
|
||||
if (d_pos_s_len > dt) {
|
||||
pos_sp_s = pos_sp_old_s + d_pos_s / d_pos_s_len * dt;
|
||||
|
||||
/* difference between current and desired position setpoints, 1 = max speed */
|
||||
math::Vector<3> d_pos_m = (pos_sp_s - pos_sp_old_s).edivide(_params.pos_p);
|
||||
float d_pos_m_len = d_pos_m.length();
|
||||
if (d_pos_m_len > dt) {
|
||||
pos_sp_s = pos_sp_old_s + (d_pos_m / d_pos_m_len * dt).emult(_params.pos_p);
|
||||
}
|
||||
|
||||
/* scale result back to normal space */
|
||||
|
||||
Reference in New Issue
Block a user