mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
positionControl: add check on sign before sqrtf
This commit is contained in:
parent
05f1efd1a4
commit
171bd6d784
@ -164,7 +164,12 @@ void PositionControl::_velocityControl(const float dt)
|
||||
// Get allowed horizontal thrust after prioritizing vertical control
|
||||
const float thrust_max_squared = _lim_thr_max * _lim_thr_max;
|
||||
const float thrust_z_squared = _thr_sp(2) * _thr_sp(2);
|
||||
float thrust_max_xy = sqrtf(thrust_max_squared - thrust_z_squared);
|
||||
const float thrust_max_xy_squared = thrust_max_squared - thrust_z_squared;
|
||||
float thrust_max_xy = 0;
|
||||
|
||||
if (thrust_max_xy_squared > 0) {
|
||||
thrust_max_xy = sqrtf(thrust_max_xy_squared);
|
||||
}
|
||||
|
||||
// Saturate thrust in horizontal direction
|
||||
const Vector2f thrust_sp_xy(_thr_sp);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user