From 92aa341c18474593a4c78ea15cab949ca80cf94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Thu, 23 Jan 2020 13:42:22 +0100 Subject: [PATCH] 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). --- src/modules/navigator/navigator_main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/navigator/navigator_main.cpp b/src/modules/navigator/navigator_main.cpp index 29ef7edc09..907f8c2181 100644 --- a/src/modules/navigator/navigator_main.cpp +++ b/src/modules/navigator/navigator_main.cpp @@ -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;