mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-20 10:29:07 +08:00
mc_pos_control: Protect against NaN and Inf setpoints
This commit is contained in:
parent
18d756dd59
commit
9cc94fcb2d
@ -726,11 +726,18 @@ MulticopterPositionControl::control_auto(float dt)
|
||||
reset_alt_sp();
|
||||
}
|
||||
|
||||
//Poll position setpoint
|
||||
bool updated;
|
||||
orb_check(_pos_sp_triplet_sub, &updated);
|
||||
|
||||
if (updated) {
|
||||
orb_copy(ORB_ID(position_setpoint_triplet), _pos_sp_triplet_sub, &_pos_sp_triplet);
|
||||
|
||||
//Make sure that the position setpoint is valid
|
||||
if (!isfinite(_pos_sp_triplet.current.lat) ||
|
||||
!isfinite(_pos_sp_triplet.current.lon) ||
|
||||
!isfinite(_pos_sp_triplet.current.alt)) {
|
||||
_pos_sp_triplet.current.valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_pos_sp_triplet.current.valid) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user