Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/FactSystem/ParameterManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,26 @@ void ParameterManager::_ftpDownloadProgress(float progress)
}
}

void ParameterManager::skipParameterDownload()
{
if (_parametersReady) {
return;
}

if (_tryftp) {
_vehicle->ftpManager()->cancelDownload();
}
_initialRequestTimeoutTimer.stop();
_waitingParamTimeoutTimer.stop();
_parametersReady = true;
_missingParameters = true;
_initialLoadComplete = true;
_waitingForDefaultComponent = false;
_setLoadProgress(1.0);
emit missingParametersChanged(_missingParameters);
emit parametersReadyChanged(_parametersReady);
}

void ParameterManager::refreshAllParameters(uint8_t componentId)
{
const SharedLinkInterfacePtr sharedLink = _vehicle->vehicleLinkManager()->primaryLink().lock();
Expand Down
1 change: 1 addition & 0 deletions src/FactSystem/ParameterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ParameterManager : public QObject

/// Re-request the full set of parameters from the autopilot
void refreshAllParameters(uint8_t componentID = MAV_COMP_ID_ALL);
Q_INVOKABLE void skipParameterDownload();

/// Request a refresh on the specific parameter
void refreshParameter(int componentId, const QString &paramName);
Expand Down
18 changes: 18 additions & 0 deletions src/MissionManager/PlanManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,24 @@ bool PlanManager::inProgress(void) const
return _transactionInProgress != TransactionNone;
}

bool PlanManager::readInProgress(void) const
{
return _transactionInProgress == TransactionRead;
}

void PlanManager::cancelTransaction(void)
{
if (!inProgress()) {
return;
}

qCDebug(PlanManagerLog) << QStringLiteral("cancelTransaction %1").arg(_planTypeString());
_ackTimeoutTimer->stop();
_expectedAck = AckNone;
_retryCount = 0;
_finishTransaction(false);
}

void PlanManager::_removeAllWorker(void)
{
qCDebug(PlanManagerLog) << "_removeAllWorker";
Expand Down
4 changes: 4 additions & 0 deletions src/MissionManager/PlanManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PlanManager : public QObject
~PlanManager();

bool inProgress(void) const;
bool readInProgress(void) const;
const QList<MissionItem*>& missionItems(void) { return _missionItems; }

/// Current mission item as reported by MISSION_CURRENT
Expand All @@ -34,6 +35,9 @@ class PlanManager : public QObject
/// Signals newMissionItemsAvailable when done
void loadFromVehicle(void);

/// Cancel any in-progress plan transaction.
void cancelTransaction(void);

/// Writes the specified set of mission items to the vehicle
/// IMPORTANT NOTE: PlanManager will take control of the MissionItem objects with the missionItems list. It will free them when done.
/// @param missionItems Items to send to vehicle
Expand Down
20 changes: 20 additions & 0 deletions src/QmlControls/FlyViewToolBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Item {
property color _mainStatusBGColor: qgcPal.brandingPurple
property real _leftRightMargin: ScreenTools.defaultFontPixelWidth * 0.75
property var _guidedController: globals.guidedControllerFlyView
property bool _parameterDownloadInProgress: _activeVehicle && _activeVehicle.parameterManager && !_activeVehicle.parameterManager.parametersReady
property bool _missionDownloadInProgress: _activeVehicle && _activeVehicle.missionDownloadInProgress
property bool _showStopDownloadButton: _parameterDownloadInProgress || _missionDownloadInProgress

function dropMainStatusIndicatorTool() {
mainStatusIndicator.dropMainStatusIndicator();
Expand Down Expand Up @@ -100,6 +103,23 @@ Item {
Layout.fillHeight: true
visible: _activeVehicle
}

QGCButton {
Layout.fillHeight: true
text: _missionDownloadInProgress ? qsTr("Skip mission download") : qsTr("Skip parameter download")
visible: _showStopDownloadButton

onClicked: {
if (!_activeVehicle) {
return
}
if (_missionDownloadInProgress) {
_activeVehicle.cancelMissionDownload()
} else if (_activeVehicle.parameterManager) {
_activeVehicle.parameterManager.skipParameterDownload()
}
}
}
}
}
Item {
Expand Down
14 changes: 14 additions & 0 deletions src/Settings/App.SettingsGroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@
"type": "bool",
"default": false
},
{
"name": "disableParameterDownload",
"shortDesc": "Disable parameter download on connect",
"longDesc": "If enabled, QGroundControl will not request parameters when a vehicle connects. This can help preserve low-bandwidth telemetry links.",
"type": "bool",
"default": false
},
{
"name": "disableMissionDownload",
"shortDesc": "Disable mission download on connect",
"longDesc": "If enabled, QGroundControl will not request the current mission when a vehicle connects. This can help preserve low-bandwidth telemetry links.",
"type": "bool",
"default": false
},
{
"name": "firstRunPromptIdsShown",
"shortDesc": "Comma separated list of first run prompt ids which have already been shown.",
Expand Down
2 changes: 2 additions & 0 deletions src/Settings/AppSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ DECLARE_SETTINGSFACT(AppSettings, openaipToken)
DECLARE_SETTINGSFACT(AppSettings, gstDebugLevel)
DECLARE_SETTINGSFACT(AppSettings, followTarget)
DECLARE_SETTINGSFACT(AppSettings, disableAllPersistence)
DECLARE_SETTINGSFACT(AppSettings, disableParameterDownload)
DECLARE_SETTINGSFACT(AppSettings, disableMissionDownload)
DECLARE_SETTINGSFACT(AppSettings, firstRunPromptIdsShown)
DECLARE_SETTINGSFACT(AppSettings, loginAirLink)
DECLARE_SETTINGSFACT(AppSettings, passAirLink)
Expand Down
2 changes: 2 additions & 0 deletions src/Settings/AppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class AppSettings : public SettingsGroup
DEFINE_SETTINGFACT(followTarget)
DEFINE_SETTINGFACT(qLocaleLanguage)
DEFINE_SETTINGFACT(disableAllPersistence)
DEFINE_SETTINGFACT(disableParameterDownload)
DEFINE_SETTINGFACT(disableMissionDownload)
DEFINE_SETTINGFACT(firstRunPromptIdsShown)
DEFINE_SETTINGFACT(loginAirLink)
DEFINE_SETTINGFACT(passAirLink)
Expand Down
19 changes: 19 additions & 0 deletions src/UI/AppSettings/TelemetrySettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ SettingsPage {
}
}

SettingsGroupLayout {
Layout.fillWidth: true
heading: qsTr("Skip download")

FactCheckBoxSlider {
Layout.fillWidth: true
text: qsTr("Skip parameter download")
fact: _appSettings.disableParameterDownload
visible: fact.visible
}

FactCheckBoxSlider {
Layout.fillWidth: true
text: qsTr("Skip mission download")
fact: _appSettings.disableMissionDownload
visible: fact.visible
}
}

SettingsGroupLayout {
Layout.fillWidth: true
heading: qsTr("Logging")
Expand Down
13 changes: 13 additions & 0 deletions src/Vehicle/InitialConnectStateMachine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "StandardModes.h"
#include "GeoFenceManager.h"
#include "RallyPointManager.h"
#include "SettingsManager.h"
#include "AppSettings.h"
#include "QGCLoggingCategory.h"

QGC_LOGGING_CATEGORY(InitialConnectStateMachineLog, "Vehicle.InitialConnectStateMachine")
Expand Down Expand Up @@ -220,6 +222,11 @@ void InitialConnectStateMachine::_stateRequestParameters(StateMachine* stateMach
Vehicle* vehicle = connectMachine->_vehicle;

qCDebug(InitialConnectStateMachineLog) << "_stateRequestParameters";
if (SettingsManager::instance()->appSettings()->disableParameterDownload()->rawValue().toBool()) {
qCDebug(InitialConnectStateMachineLog) << "Skipping parameter download on connect due to settings";
vehicle->_parameterManager->skipParameterDownload();
return;
}
connect(vehicle->_parameterManager, &ParameterManager::loadProgressChanged, connectMachine,
&InitialConnectStateMachine::gotProgressUpdate);
vehicle->_parameterManager->refreshAllParameters();
Expand All @@ -234,6 +241,12 @@ void InitialConnectStateMachine::_stateRequestMission(StateMachine* stateMachine
disconnect(vehicle->_parameterManager, &ParameterManager::loadProgressChanged, connectMachine,
&InitialConnectStateMachine::gotProgressUpdate);

if (SettingsManager::instance()->appSettings()->disableMissionDownload()->rawValue().toBool()) {
qCDebug(InitialConnectStateMachineLog) << "_stateRequestMission: Skipping first mission load request due to settings";
vehicle->_firstMissionLoadComplete();
return;
}

if (!sharedLink) {
qCDebug(InitialConnectStateMachineLog) << "_stateRequestMission: Skipping first mission load request due to no primary link";
connectMachine->advance();
Expand Down
15 changes: 14 additions & 1 deletion src/Vehicle/Vehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ void Vehicle::_commonInit(LinkInterface* link)
connect(_missionManager, &MissionManager::sendComplete, this, &Vehicle::_clearCameraTriggerPoints);
connect(_missionManager, &MissionManager::currentIndexChanged, this, &Vehicle::_updateHeadingToNextWP);
connect(_missionManager, &MissionManager::currentIndexChanged, this, &Vehicle::_updateMissionItemIndex);
connect(_missionManager, &MissionManager::inProgressChanged, this, &Vehicle::missionDownloadInProgressChanged);

connect(_missionManager, &MissionManager::sendComplete, _trajectoryPoints, &TrajectoryPoints::clear);
connect(_missionManager, &MissionManager::newMissionItemsAvailable, _trajectoryPoints, &TrajectoryPoints::clear);
Expand Down Expand Up @@ -1396,7 +1397,7 @@ void Vehicle::_handleRCChannels(mavlink_message_t& message)
channels.chan18_raw,
});

// The internals of radio calibration can ony deal with contiguous channels (other stuff as well!)
// The internals of radio calibration can only deal with contiguous channels (other stuff as well!)
int validChannelCount = 0;
int firstUnusedChannelIndex = -1;
for (int i=0; i<rawChannelValues.size(); i++) {
Expand Down Expand Up @@ -2307,6 +2308,18 @@ void Vehicle::sendCommand(int compId, int command, bool showError, double param1
static_cast<float>(param7));
}

bool Vehicle::missionDownloadInProgress() const
{
return _missionManager && _missionManager->readInProgress();
}

void Vehicle::cancelMissionDownload()
{
if (_missionManager) {
_missionManager->cancelTransaction();
}
}

void Vehicle::sendMavCommandWithHandler(const MavCmdAckHandlerInfo_t* ackHandlerInfo, int compId, MAV_CMD command, float param1, float param2, float param3, float param4, float param5, float param6, float param7)
{
_sendMavCommandWorker(false, // commandInt
Expand Down
4 changes: 4 additions & 0 deletions src/Vehicle/Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class Vehicle : public VehicleFactGroup
Q_PROPERTY(bool haveFWSpeedLimits READ haveFWSpeedLimits NOTIFY haveFWSpeedLimChanged)

Q_PROPERTY(ParameterManager* parameterManager READ parameterManager CONSTANT)
Q_PROPERTY(bool missionDownloadInProgress READ missionDownloadInProgress NOTIFY missionDownloadInProgressChanged)
Q_PROPERTY(VehicleLinkManager* vehicleLinkManager READ vehicleLinkManager CONSTANT)
Q_PROPERTY(VehicleObjectAvoidance* objectAvoidance READ objectAvoidance CONSTANT)
Q_PROPERTY(Autotune* autotune READ autotune CONSTANT)
Expand Down Expand Up @@ -598,6 +599,7 @@ class Vehicle : public VehicleFactGroup
VehicleObjectAvoidance* objectAvoidance () { return _objectAvoidance; }
Autotune* autotune () const { return _autotune; }
RemoteIDManager* remoteIDManager () { return _remoteIDManager; }
bool missionDownloadInProgress() const;

static void showCommandAckError(const mavlink_command_ack_t& ack);

Expand Down Expand Up @@ -629,6 +631,7 @@ class Vehicle : public VehicleFactGroup

/// Same as sendMavCommand but available from Qml.
Q_INVOKABLE void sendCommand(int compId, int command, bool showError, double param1 = 0.0, double param2 = 0.0, double param3 = 0.0, double param4 = 0.0, double param5 = 0.0, double param6 = 0.0, double param7 = 0.0);
Q_INVOKABLE void cancelMissionDownload();

typedef enum {
MavCmdResultCommandResultOnly, ///< commandResult specifies full success/fail info
Expand Down Expand Up @@ -850,6 +853,7 @@ public slots:
void gitHashChanged (QString hash);
void vehicleUIDChanged ();
void loadProgressChanged (float value);
void missionDownloadInProgressChanged();

/// New RC channel values coming from RC_CHANNELS message
/// @param channelValues The current values for rc channels
Expand Down
64 changes: 64 additions & 0 deletions test/FactSystem/ParameterManagerTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,70 @@ void ParameterManagerTest::_requestListNoResponse(void)
QCOMPARE(spyParamsReady.wait(40000), false);
}

void ParameterManagerTest::_skipParameterDownload(void)
{
Q_ASSERT(!_mockLink);
_mockLink = MockLink::startPX4MockLink(false, MockConfiguration::FailParamNoReponseToRequestList);

MultiVehicleManager* vehicleMgr = MultiVehicleManager::instance();
QVERIFY(vehicleMgr);

// Wait for the Vehicle to get created
QSignalSpy spyVehicle(vehicleMgr, SIGNAL(activeVehicleAvailableChanged(bool)));
QCOMPARE(spyVehicle.wait(5000), true);
QCOMPARE(spyVehicle.count(), 1);
QList<QVariant> arguments = spyVehicle.takeFirst();
QCOMPARE(arguments.count(), 1);
QCOMPARE(arguments.at(0).toBool(), true);

Vehicle* vehicle = vehicleMgr->activeVehicle();
QVERIFY(vehicle);

ParameterManager *const paramManager = vehicle->parameterManager();
QVERIFY(paramManager);

QSignalSpy paramsReadySpy(paramManager, &ParameterManager::parametersReadyChanged);
QSignalSpy missingSpy(paramManager, &ParameterManager::missingParametersChanged);
QSignalSpy progressSpy(paramManager, &ParameterManager::loadProgressChanged);
QSignalSpy vehicleReadySpy(vehicleMgr, SIGNAL(parameterReadyVehicleAvailableChanged(bool)));

QVERIFY(paramsReadySpy.isValid());
QVERIFY(missingSpy.isValid());
QVERIFY(progressSpy.isValid());
QVERIFY(vehicleReadySpy.isValid());

// Trigger skip of parameter download
paramManager->skipParameterDownload();

QTRY_VERIFY(paramManager->parametersReady());
QTRY_VERIFY(paramManager->missingParameters());
QTRY_COMPARE(paramManager->loadProgress(), 1.0);

if (paramsReadySpy.count() > 0) {
arguments = paramsReadySpy.takeFirst();
QCOMPARE(arguments.count(), 1);
QCOMPARE(arguments.at(0).toBool(), true);
}

if (missingSpy.count() > 0) {
arguments = missingSpy.takeFirst();
QCOMPARE(arguments.count(), 1);
QCOMPARE(arguments.at(0).toBool(), true);
}

if (progressSpy.count() > 0) {
arguments = progressSpy.takeLast();
QCOMPARE(arguments.count(), 1);
QCOMPARE(arguments.at(0).toFloat(), 1.0f);
}

if (vehicleReadySpy.count() > 0) {
arguments = vehicleReadySpy.takeFirst();
QCOMPARE(arguments.count(), 1);
QCOMPARE(arguments.at(0).toBool(), true);
}
}

// MockLink will fail to send a param on initial request, it will also fail to send it on subsequent
// param_read requests.
void ParameterManagerTest::_requestListMissingParamFail(void)
Expand Down
1 change: 1 addition & 0 deletions test/FactSystem/ParameterManagerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ private slots:
void _paramWriteNoAckPermanent(void);
void _paramReadFirstAttemptNoResponseRetry(void);
void _paramReadNoResponse(void);
void _skipParameterDownload(void);
// void _FTPnoFailure(void);
// void _FTPChangeParam(void);

Expand Down
Loading
Loading