From 95f9b8fb524a7ccad9ef2080a340771807702029 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 11 Jun 2016 16:36:12 -0700 Subject: [PATCH] Fix flight mode channel not set bug --- src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc index 5ed00d31b..8f0bebfd5 100644 --- a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc +++ b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc @@ -51,6 +51,12 @@ void PX4SimpleFlightModesController::_rcChannelsChanged(int channelCount, int pw } int flightModeChannel = pFact->rawValue().toInt() - 1; + if (flightModeChannel == -1) { + // Flight mode channel not set, can't track active flight mode + _activeFlightMode = 0; + emit activeFlightModeChanged(_activeFlightMode); + return; + } pFact = getParameterFact(-1, QString("RC%1_REV").arg(flightModeChannel + 1)); if(!pFact) { -- 2.22.0