Browse Source

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.
sbg
Beat Küng 5 years ago committed by Julian Oes
parent
commit
80f0892de5
  1. 7
      src/modules/commander/Commander.cpp
  2. 1
      src/modules/commander/Commander.hpp

7
src/modules/commander/Commander.cpp

@ -1552,6 +1552,8 @@ Commander::run() @@ -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() @@ -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;
}

1
src/modules/commander/Commander.hpp

@ -362,7 +362,6 @@ private: @@ -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};

Loading…
Cancel
Save