From b5d40d3c7e53767d6a57f6b7e652b5720b7c8c9d Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 30 Nov 2018 12:26:49 -0800 Subject: [PATCH] ArduPilot option to not start mavlink streams --- src/FirmwarePlugin/APM/APMFirmwarePlugin.cc | 8 ++++++-- src/Settings/App.SettingsGroup.json | 6 ++++++ src/Settings/AppSettings.cc | 1 + src/Settings/AppSettings.h | 3 +++ src/ui/preferences/MavlinkSettings.qml | 12 ++++++++---- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc b/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc index 94c0545cf..3cf164b01 100644 --- a/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc +++ b/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc @@ -17,6 +17,8 @@ #include "MissionManager.h" #include "ParameterManager.h" #include "QGCFileDownload.h" +#include "SettingsManager.h" +#include "AppSettings.h" #include @@ -641,8 +643,10 @@ void APMFirmwarePlugin::initializeVehicle(Vehicle* vehicle) break; } } else { - // Streams are not started automatically on APM stack - initializeStreamRates(vehicle); + if (qgcApp()->toolbox()->settingsManager()->appSettings()->apmStartMavlinkStreams()->rawValue().toBool()) { + // Streams are not started automatically on APM stack (sort of) + initializeStreamRates(vehicle); + } } } diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index 7daaa6217..928ca9168 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -199,5 +199,11 @@ "enumStrings": "Never,Always,When in Follow Me Flight Mode", "enumValues": "0,1,2", "defaultValue": 0 +}, +{ + "name": "apmStartMavlinkStreams", + "shortDescription": "Request start of MAVLink telemetry streams (ArduPilot only)", + "type": "bool", + "defaultValue": true } ] diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index e4209c16b..f8d005738 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -84,6 +84,7 @@ DECLARE_SETTINGSFACT(AppSettings, esriToken) DECLARE_SETTINGSFACT(AppSettings, defaultFirmwareType) DECLARE_SETTINGSFACT(AppSettings, gstDebugLevel) DECLARE_SETTINGSFACT(AppSettings, followTarget) +DECLARE_SETTINGSFACT(AppSettings, apmStartMavlinkStreams) DECLARE_SETTINGSFACT_NO_FUNC(AppSettings, indoorPalette) { diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index 584ce819d..46e9a61e3 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -44,6 +44,9 @@ public: DEFINE_SETTINGFACT(gstDebugLevel) DEFINE_SETTINGFACT(followTarget) + // Although this is a global setting it only affects ArduPilot vehicle since PX4 automatically starts the stream from the vehicle side + DEFINE_SETTINGFACT(apmStartMavlinkStreams) + Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged) Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged) Q_PROPERTY(QString telemetrySavePath READ telemetrySavePath NOTIFY savePathsChanged) diff --git a/src/ui/preferences/MavlinkSettings.qml b/src/ui/preferences/MavlinkSettings.qml index 5e33a0849..ac4a8d468 100644 --- a/src/ui/preferences/MavlinkSettings.qml +++ b/src/ui/preferences/MavlinkSettings.qml @@ -15,6 +15,7 @@ import QtQuick.Dialogs 1.2 import QGroundControl 1.0 import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.MultiVehicleManager 1.0 @@ -132,8 +133,7 @@ Rectangle { } } } - //----------------------------------------------------------------- - //-- Mavlink Heartbeats + QGCCheckBox { text: qsTr("Emit heartbeat") checked: QGroundControl.multiVehicleManager.gcsHeartBeatEnabled @@ -141,8 +141,12 @@ Rectangle { QGroundControl.multiVehicleManager.gcsHeartBeatEnabled = checked } } - //----------------------------------------------------------------- - //-- Mavlink Version Check + + FactCheckBox { + text: fact.shortDescription + fact: QGroundControl.settingsManager.appSettings.apmStartMavlinkStreams + } + QGCCheckBox { text: qsTr("Only accept MAVs with same protocol version") checked: QGroundControl.isVersionCheckEnabled -- 2.22.0