mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-06 05:01:37 +08:00
mc_pos_control: Protect against NaN and Inf setpoints
This commit is contained in:
committed by
Lorenz Meier
parent
18d756dd59
commit
9cc94fcb2d
@@ -726,11 +726,18 @@ MulticopterPositionControl::control_auto(float dt)
|
|||||||
reset_alt_sp();
|
reset_alt_sp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Poll position setpoint
|
||||||
bool updated;
|
bool updated;
|
||||||
orb_check(_pos_sp_triplet_sub, &updated);
|
orb_check(_pos_sp_triplet_sub, &updated);
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
orb_copy(ORB_ID(position_setpoint_triplet), _pos_sp_triplet_sub, &_pos_sp_triplet);
|
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) {
|
if (_pos_sp_triplet.current.valid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user