mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-22 10:27:36 +08:00
fix commander: set _was_landed before _land_detector topic update
Before _was_landed was set to the same value as the current _land_detector.landed, thus outside of the update condition, _was_landed && !_land_detector.landed could never be true. This affects setting the home position, which is now set upon arming AND upon takeoff.
This commit is contained in:
@@ -1552,6 +1552,8 @@ Commander::run()
|
||||
|
||||
/* Update land detector */
|
||||
if (_land_detector_sub.updated()) {
|
||||
_was_landed = _land_detector.landed;
|
||||
bool was_falling = _land_detector.freefall;
|
||||
_land_detector_sub.copy(&_land_detector);
|
||||
|
||||
// Only take actions if armed
|
||||
@@ -1573,15 +1575,12 @@ Commander::run()
|
||||
}
|
||||
}
|
||||
|
||||
if (_was_falling != _land_detector.freefall) {
|
||||
if (was_falling != _land_detector.freefall) {
|
||||
if (_land_detector.freefall) {
|
||||
mavlink_and_console_log_info(&mavlink_log_pub, "Freefall detected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_was_landed = _land_detector.landed;
|
||||
_was_falling = _land_detector.freefall;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -362,7 +362,6 @@ private:
|
||||
bool _status_changed{true};
|
||||
bool _arm_tune_played{false};
|
||||
bool _was_landed{true};
|
||||
bool _was_falling{false};
|
||||
bool _was_armed{false};
|
||||
bool _failsafe_old{false}; ///< check which state machines for changes, clear "changed" flag
|
||||
bool _have_taken_off_since_arming{false};
|
||||
|
||||
Reference in New Issue
Block a user