From 1e5d9fb2997bea1cc6c80d9a0a1ea15cd0353eac Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Mon, 2 Nov 2020 18:46:48 +0100 Subject: [PATCH] Copter: set initial mode on startup --- ArduCopter/system.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ArduCopter/system.cpp b/ArduCopter/system.cpp index 8c9526dde3..0bea87f0be 100644 --- a/ArduCopter/system.cpp +++ b/ArduCopter/system.cpp @@ -216,6 +216,15 @@ void Copter::init_ardupilot() enable_motor_output(); } + // attempt to switch to RTL, if this fails then switch to Land + if (!set_mode((enum Mode::Number)g.initial_mode.get(), ModeReason::INITIALISED)) { + // set mode to STABILIZE will trigger mode change notification to pilot + set_mode(Mode::Number::STABILIZE, ModeReason::UNAVAILABLE); + } else { + // alert pilot to mode change + AP_Notify::events.failsafe_mode_change = 1; + } + // flag that initialisation has completed ap.initialised = true; }