Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove need for restart after mission upload #60

Merged
merged 14 commits into from
Nov 1, 2024
Merged
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
40 changes: 39 additions & 1 deletion src/FlightDisplay/GuidedActionsController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ Item {
readonly property int actionStepAlt: 25

property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _planMasterController: globals.planMasterControllerPlanView
property bool _syncInProgress: _planMasterController.syncInProgress
property bool _dirty: _planMasterController.dirty
property bool _useChecklist: QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length
property bool _enforceChecklist: _useChecklist && QGroundControl.settingsManager.appSettings.enforceChecklist.rawValue
property bool _canArm: _activeVehicle ? (_useChecklist ? (_enforceChecklist ? _activeVehicle.checkListState === Vehicle.CheckListPassed : true) : true) : false
property bool _canArm: canArm()
Fredrikbjornland marked this conversation as resolved.
Show resolved Hide resolved

property bool showEmergenyStop: _guidedActionsEnabled && !_hideEmergenyStop && _vehicleArmed && _vehicleFlying
property bool showArm: _guidedActionsEnabled && !_vehicleArmed && _canArm
Expand Down Expand Up @@ -283,6 +286,41 @@ Item {
function onVtolTransitionToMRFlightRequest() { vtolTransitionToMRFlightRequest() }
}

Connections {
target: _activeVehicle
function onRallyPointManagerErrorChanged() {
_canArm = canArm()
}
function onGeoFenceManagerErrorChanged() {
_canArm = canArm()
}
function onMissionManagerErrorChanged() {
_canArm = canArm()
}
}

Connections {
target: _planMasterController
function onSyncInProgressChanged() {
_syncInProgress = _planMasterController.syncInProgress
_canArm = canArm()
}
function onDirtyChanged() {
_dirty = _planMasterController.dirty
_canArm = canArm()
}
}



function planError() {
return _activeVehicle && (_activeVehicle.missionManagerError != "" || _activeVehicle.geoFenceManagerError != "" || _activeVehicle.rallyPointManagerError != "")
}

function canArm() {
return _activeVehicle ? !planError() && !_dirty && (_useChecklist ? (_enforceChecklist ? _activeVehicle.checkListState === Vehicle.CheckListPassed : true) : true) && !_syncInProgress : false
}

function armVehicleRequest() {
confirmAction(actionArm)
}
Expand Down
6 changes: 5 additions & 1 deletion src/MissionManager/AviantMissionTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,11 @@ void AviantMissionTools::_parseAndLoadMissionResponse(const QByteArray &bytes)
tr("Mission Tools - ") + _getOperationName(_currentOperation));
return;
}


if (_currentOperation == FetchKyteOrderMissionFile) {
_masterController->clearCurrentPlanFile();
}

qgcApp()->showAppMessage(tr("Operation successful"), tr("Mission Tools - ") + _getOperationName(_currentOperation));
}

Expand Down
10 changes: 10 additions & 0 deletions src/MissionManager/GeoFenceController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void GeoFenceController::_managerVehicleChanged(Vehicle* managerVehicle)
connect(_geoFenceManager, &GeoFenceManager::sendComplete, this, &GeoFenceController::_managerSendComplete);
connect(_geoFenceManager, &GeoFenceManager::removeAllComplete, this, &GeoFenceController::_managerRemoveAllComplete);
connect(_geoFenceManager, &GeoFenceManager::inProgressChanged, this, &GeoFenceController::syncInProgressChanged);
connect(_geoFenceManager, &GeoFenceManager::progressPct, this, &GeoFenceController::_progressPctChanged);

//-- GeoFenceController::supported() tests both the capability bit AND the protocol version.
connect(_managerVehicle, &Vehicle::capabilityBitsChanged, this, &GeoFenceController::supportedChanged);
Expand Down Expand Up @@ -352,6 +353,7 @@ void GeoFenceController::_managerLoadComplete(void)
emit loadComplete();
}
_itemsRequested = false;
_managerVehicle->clearGeoFenceManagerError();
}

void GeoFenceController::_managerSendComplete(bool error)
Expand Down Expand Up @@ -522,6 +524,14 @@ void GeoFenceController::_parametersReady(void)
emit paramCircularFenceChanged();
}

void GeoFenceController::_progressPctChanged(double progressPct)
{
if (!QGC::fuzzyCompare(progressPct, _progressPct)) {
_progressPct = progressPct;
emit progressPctChanged(progressPct);
}
}

bool GeoFenceController::isEmpty(void) const
{
return _polygons.count() == 0 && _circles.count() == 0 && !_breachReturnPoint.isValid();
Expand Down
11 changes: 8 additions & 3 deletions src/MissionManager/GeoFenceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class GeoFenceController : public PlanElementController
Q_PROPERTY(QGeoCoordinate breachReturnPoint READ breachReturnPoint WRITE setBreachReturnPoint NOTIFY breachReturnPointChanged)
Q_PROPERTY(Fact* breachReturnAltitude READ breachReturnAltitude CONSTANT)
Q_PROPERTY(QStringList fenceActions READ fenceActions CONSTANT)
Q_PROPERTY(double progressPct READ progressPct NOTIFY progressPctChanged)

// Hack to expose PX4 circular fence controlled by GF_MAX_HOR_DIST
Q_PROPERTY(double paramCircularFence READ paramCircularFence NOTIFY paramCircularFenceChanged)
Expand Down Expand Up @@ -83,14 +84,16 @@ class GeoFenceController : public PlanElementController
QmlObjectListModel* circles (void) { return &_circles; }
QGeoCoordinate breachReturnPoint (void) const { return _breachReturnPoint; }

void setBreachReturnPoint (const QGeoCoordinate& breachReturnPoint);
bool isEmpty (void) const;
void setBreachReturnPoint (const QGeoCoordinate& breachReturnPoint);
bool isEmpty (void) const;
double progressPct (void) const { return _progressPct; }

signals:
void breachReturnPointChanged (QGeoCoordinate breachReturnPoint);
void editorQmlChanged (QString editorQml);
void loadComplete (void);
void paramCircularFenceChanged (void);
void progressPctChanged (double progressPct);

private slots:
void _polygonDirtyChanged (bool dirty);
Expand All @@ -102,7 +105,8 @@ private slots:
void _managerSendComplete (bool error);
void _managerRemoveAllComplete (bool error);
void _parametersReady (void);
void _managerVehicleChanged (Vehicle* managerVehicle);
void _managerVehicleChanged (Vehicle* managerVehicle);
void _progressPctChanged (double progressPct);

private:
void _init(void);
Expand All @@ -117,6 +121,7 @@ private slots:
double _breachReturnDefaultAltitude = qQNaN();
bool _itemsRequested = false;
Fact* _px4ParamCircularFenceFact = nullptr;
double _progressPct = 0;

static QMap<QString, FactMetaData*> _metaDataMap;

Expand Down
2 changes: 1 addition & 1 deletion src/MissionManager/MissionController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void MissionController::_newMissionItemsAvailableFromVehicle(bool removeAllReque

_visualItems = newControllerMissionItems;
_settingsItem = settingsItem;

_managerVehicle->clearMissionManagerError();
MissionController::_scanForAdditionalSettings(_visualItems, _masterController);

_initAllVisualItems();
Expand Down
7 changes: 7 additions & 0 deletions src/MissionManager/PlanMasterController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,12 @@ void PlanMasterController::loadFromFile(const QString& filename)
}
}

void PlanMasterController::clearCurrentPlanFile()
{
_currentPlanFile.clear();
emit currentPlanFileChanged();
}

QJsonDocument PlanMasterController::saveToJson()
{
QJsonObject planJson;
Expand Down Expand Up @@ -588,6 +594,7 @@ void PlanMasterController::removeAllFromVehicle(void)
if (_rallyPointController.supported()) {
_rallyPointController.removeAllFromVehicle();
}
_currentPlanFile.clear();
setDirty(false);
} else {
qWarning() << "PlanMasterController::removeAllFromVehicle called while offline";
Expand Down
2 changes: 2 additions & 0 deletions src/MissionManager/PlanMasterController.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class PlanMasterController : public QObject
QJsonDocument saveToJson ();
bool loadFromJson (QJsonDocument jsonDoc, QString &errorString);

void clearCurrentPlanFile ();

Vehicle* controllerVehicle(void) { return _controllerVehicle; }
Vehicle* managerVehicle(void) { return _managerVehicle; }

Expand Down
10 changes: 10 additions & 0 deletions src/MissionManager/RallyPointController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void RallyPointController::_managerVehicleChanged(Vehicle* managerVehicle)
connect(_rallyPointManager, &RallyPointManager::sendComplete, this, &RallyPointController::_managerSendComplete);
connect(_rallyPointManager, &RallyPointManager::removeAllComplete, this, &RallyPointController::_managerRemoveAllComplete);
connect(_rallyPointManager, &RallyPointManager::inProgressChanged, this, &RallyPointController::syncInProgressChanged);
connect(_rallyPointManager, &RallyPointManager::progressPct, this, &RallyPointController::_progressPctChanged);

//-- RallyPointController::supported() tests both the capability bit AND the protocol version.
connect(_managerVehicle, &Vehicle::capabilityBitsChanged, this, &RallyPointController::supportedChanged);
Expand Down Expand Up @@ -246,6 +247,7 @@ void RallyPointController::_managerLoadComplete(void)
setDirty(false);
_setFirstPointCurrent();
emit loadComplete();
_managerVehicle->clearRallyPointManagerError();
}
_itemsRequested = false;
}
Expand Down Expand Up @@ -357,6 +359,14 @@ bool RallyPointController::showPlanFromManagerVehicle (void)
}
}

void RallyPointController::_progressPctChanged(double progressPct)
{
if (!QGC::fuzzyCompare(progressPct, _progressPct)) {
_progressPct = progressPct;
emit progressPctChanged(progressPct);
}
}

bool RallyPointController::isEmpty(void) const
{
return _points.count() == 0;
Expand Down
9 changes: 7 additions & 2 deletions src/MissionManager/RallyPointController.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class RallyPointController : public PlanElementController
Q_PROPERTY(QmlObjectListModel* points READ points CONSTANT)
Q_PROPERTY(QString editorQml READ editorQml CONSTANT)
Q_PROPERTY(QObject* currentRallyPoint READ currentRallyPoint WRITE setCurrentRallyPoint NOTIFY currentRallyPointChanged)
Q_PROPERTY(double progressPct READ progressPct NOTIFY progressPctChanged)

Q_INVOKABLE void addPoint (QGeoCoordinate point);
Q_INVOKABLE void removePoint (QObject* rallyPoint);
Expand All @@ -54,12 +55,14 @@ class RallyPointController : public PlanElementController
QString editorQml (void) const;
QObject* currentRallyPoint (void) const { return _currentRallyPoint; }

void setCurrentRallyPoint (QObject* rallyPoint);
bool isEmpty (void) const;
void setCurrentRallyPoint (QObject* rallyPoint);
bool isEmpty (void) const;
double progressPct (void) const { return _progressPct; }

signals:
void currentRallyPointChanged(QObject* rallyPoint);
void loadComplete(void);
void progressPctChanged (double progressPct);

private slots:
void _managerLoadComplete (void);
Expand All @@ -68,6 +71,7 @@ private slots:
void _setFirstPointCurrent (void);
void _updateContainsItems (void);
void _managerVehicleChanged (Vehicle* managerVehicle);
void _progressPctChanged (double progressPct);

private:
Vehicle* _managerVehicle = nullptr;
Expand All @@ -76,6 +80,7 @@ private slots:
QmlObjectListModel _points;
QObject* _currentRallyPoint = nullptr;
bool _itemsRequested = false;
double _progressPct = 0;

static const int _jsonCurrentVersion = 2;
static const int _jsonCurrentVersionWithRPType = 102;
Expand Down
Loading
Loading