mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
mc_pos_control: set curr_pos_sp(0:1) to pos(0:1) if non-finite
This commit is contained in:
committed by
Lorenz Meier
parent
22be99da3e
commit
a398dc09c7
@@ -737,6 +737,9 @@ MulticopterPositionControl::poll_subscriptions()
|
|||||||
&& PX4_ISFINITE(_pos_sp_triplet.current.alt) && _pos_sp_triplet.current.valid) {
|
&& PX4_ISFINITE(_pos_sp_triplet.current.alt) && _pos_sp_triplet.current.valid) {
|
||||||
_pos_sp_triplet.current.valid = true;
|
_pos_sp_triplet.current.valid = true;
|
||||||
|
|
||||||
|
} else if (PX4_ISFINITE(_pos_sp_triplet.current.alt) && _pos_sp_triplet.current.valid) {
|
||||||
|
_pos_sp_triplet.current.valid = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_pos_sp_triplet.current.valid = false;
|
_pos_sp_triplet.current.valid = false;
|
||||||
}
|
}
|
||||||
@@ -1402,7 +1405,7 @@ void MulticopterPositionControl::control_auto(float dt)
|
|||||||
|
|
||||||
if (_pos_sp_triplet.current.valid) {
|
if (_pos_sp_triplet.current.valid) {
|
||||||
|
|
||||||
math::Vector<3> curr_pos_sp;
|
math::Vector<3> curr_pos_sp = _curr_pos_sp;
|
||||||
|
|
||||||
//only project setpoints if they are finite, else use current position
|
//only project setpoints if they are finite, else use current position
|
||||||
if (PX4_ISFINITE(_pos_sp_triplet.current.lat) &&
|
if (PX4_ISFINITE(_pos_sp_triplet.current.lat) &&
|
||||||
@@ -1438,9 +1441,16 @@ void MulticopterPositionControl::control_auto(float dt)
|
|||||||
|
|
||||||
/* check if triplets have been updated
|
/* check if triplets have been updated
|
||||||
* note: we only can look at xy since navigator applies slewrate to z */
|
* note: we only can look at xy since navigator applies slewrate to z */
|
||||||
matrix::Vector2f diff((_curr_pos_sp(0) - curr_pos_sp(0)), (_curr_pos_sp(1) - curr_pos_sp(1)));
|
float diff;
|
||||||
|
|
||||||
if (diff.length() > FLT_EPSILON) {
|
if (_triplet_lat_lon_finite) {
|
||||||
|
diff = matrix::Vector2f((_curr_pos_sp(0) - curr_pos_sp(0)), (_curr_pos_sp(1) - curr_pos_sp(1))).length();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
diff = fabsf(_curr_pos_sp(2) - curr_pos_sp(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diff > FLT_EPSILON) {
|
||||||
triplet_updated = true;
|
triplet_updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user