mc_pos_control: limit if just xy distance close to target

This commit is contained in:
Dennis Mannhart
2017-03-22 15:21:34 +01:00
parent f9551c12de
commit 20a47a1a72
@@ -1500,8 +1500,9 @@ void MulticopterPositionControl::control_auto(float dt)
}
/* set velocity limit if close to current setpoint and no next setpoint available */
math::Vector<3> dist = _curr_pos_sp - _pos;
_limit_vel_xy = (!next_setpoint_valid || (_pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_LOITER))
&& ((_curr_pos_sp - _pos).length() <= _target_threshold_xy.get());
&& (sqrtf(dist(0) * dist(0) + dist(1) * dist(1)) <= _target_threshold_xy.get());
if (current_setpoint_valid &&
(_pos_sp_triplet.current.type != position_setpoint_s::SETPOINT_TYPE_IDLE)) {