navigator: do not set a mode while disarmed

This avoids premature state machine execution, most notably for missions.

In particular this fixes these issues:
- when landed, and the vehicle has a valid mission: switching to mission
  would execute the first item.
- after executing a mission with a land waypoint, the mission is reset
  and the first item is executed.

In case the first waypoint is a takeoff, it would print a user message:
"Takeoff to x meters above home.". If it was a vehicle command, it would
execute that.
Note that because the vehicle is disarmed, the vehicle would not actually
do anything (except for commands that are accepted while disarmed).
This commit is contained in:
Beat Küng
2020-01-23 13:42:22 +01:00
committed by Lorenz Meier
parent e939f60a9e
commit 92aa341c18
+5
View File
@@ -647,6 +647,11 @@ Navigator::run()
break;
}
// Do not execute any state machine while we are disarmed
if (_vstatus.arming_state != vehicle_status_s::ARMING_STATE_ARMED) {
navigation_mode_new = nullptr;
}
// update the vehicle status
_previous_nav_state = _vstatus.nav_state;