Commit f0f3912e authored by Valentin Platzgummer's avatar Valentin Platzgummer

z order in flight view fixed

parent accb2ed3
...@@ -58,6 +58,10 @@ FlightMap { ...@@ -58,6 +58,10 @@ FlightMap {
property bool _disableVehicleTracking: false property bool _disableVehicleTracking: false
property bool _keepVehicleCentered: _mainIsMap ? false : true property bool _keepVehicleCentered: _mainIsMap ? false : true
property bool _wimaEnabled: wimaController.enableWimaController.value
property bool _showAllWimaItems: wimaController.showAllMissionItems.value
property bool _showCurrentWimaItems: wimaController.showCurrentMissionItems.value
function updateAirspace(reset) { function updateAirspace(reset) {
if(_airspaceEnabled) { if(_airspaceEnabled) {
var coordinateNW = flightMap.toCoordinate(Qt.point(0,0), false /* clipToViewPort */) var coordinateNW = flightMap.toCoordinate(Qt.point(0,0), false /* clipToViewPort */)
...@@ -193,13 +197,6 @@ FlightMap { ...@@ -193,13 +197,6 @@ FlightMap {
property real leftToolWidth: toolStrip.x + toolStrip.width property real leftToolWidth: toolStrip.x + toolStrip.width
} }
// Add mission items generated by wima planer to the map
WimaPlanMapItems {
map: flightMap
largeMapView: _mainIsMap
wimaController: flightMap.wimaController
}
// Add wima Areas to the Map // Add wima Areas to the Map
MapItemView { MapItemView {
property bool _enableWima: wimaController.enableWimaController.value property bool _enableWima: wimaController.enableWimaController.value
...@@ -214,10 +211,33 @@ FlightMap { ...@@ -214,10 +211,33 @@ FlightMap {
: object.type === "WimaMeasurementAreaData" ? "green" : object.type === "WimaMeasurementAreaData" ? "green"
: "transparent" : "transparent"
opacity: 0.25 opacity: 0.25
z: QGroundControl.zOrderWaypointLines-2 z: 0
} }
} }
// Add mission items generated by wima planer to the map
WimaPlanMapItems {
map: flightMap
largeMapView: _mainIsMap
missionItems: wimaController.missionItems
path: wimaController.waypointPath
showItems: _wimaEnabled && _showAllWimaItems
zOrderWP: QGroundControl.zOrderWaypointIndicators-2
zOrderLines: QGroundControl.zOrderWaypointLines-2
color: "#B4808080" // gray with alpha 0.7
}
WimaPlanMapItems {
map: flightMap
largeMapView: _mainIsMap
missionItems: wimaController.currentMissionItems
path: wimaController.currentWaypointPath
showItems: _wimaEnabled && _showCurrentWimaItems
zOrderWP: QGroundControl.zOrderWaypointIndicators-1
zOrderLines: QGroundControl.zOrderWaypointLines-1
color: "green" // gray with alpha 0.7
}
// Add trajectory points to the map // Add trajectory points to the map
MapItemView { MapItemView {
model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0 model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0
......
...@@ -444,16 +444,11 @@ Item { ...@@ -444,16 +444,11 @@ Item {
wimaController.forceUploadToVehicle() wimaController.forceUploadToVehicle()
break break
case actionInitSmartRTL: case actionInitSmartRTL:
_activeVehicle.pauseVehicle() wimaController.initSmartRTL()
wimaController.calcReturnPath()
break break
case actionUploadAndExecute: case actionUploadAndExecute:
wimaController.forceUploadToVehicle()
_activeVehicle.startMission()
break
case actionReturnBatteryLow: case actionReturnBatteryLow:
wimaController.forceUploadToVehicle() wimaController.executeSmartRTL()
_activeVehicle.startMission()
break break
default: default:
console.warn(qsTr("Internal error: unknown actionCode"), actionCode) console.warn(qsTr("Internal error: unknown actionCode"), actionCode)
......
...@@ -21,85 +21,51 @@ Item { ...@@ -21,85 +21,51 @@ Item {
property var map ///< Map control to show items on property var map ///< Map control to show items on
property bool largeMapView ///< true: map takes up entire view, false: map is in small window property bool largeMapView ///< true: map takes up entire view, false: map is in small window
property var wimaController property string color: "green" // Mission Items Color
property string mIColor: "#B4808080" // Mission Items Color, gray with alpha 0.7 #AARRGGBB property var missionItems
property string mIlineColor: mIColor property var path
property string cMIColor: "orangered" // Current Mission Items Color property var zOrderWP
property string cMIlineColor: cMIColor property var zOrderLines
property var _map: map property var _map: map
property var _missionLineViewComponent property var _missionLineViewComponent
property var _currentMissionLineViewComponent
property bool _showAllItems: wimaController.showAllMissionItems.value property bool showItems: true
property bool _showCurrentItems: wimaController.showCurrentMissionItems.value
property bool _wimaEnabled: wimaController.enableWimaController.value
// Add the mission item visuals to the map Component {
Repeater { id: missionLineViewComponent
model: largeMapView ? (_showAllItems ? (_wimaEnabled ? wimaController.missionItems : 0) : 0) : 0
z: QGroundControl.zOrderWaypointIndicators-2
delegate: WimaMissionItemMapVisual { MapPolyline {
map: _map line.width: 3
color: _root.mIColor line.color: showItems ? _root.color : "transparent"
// onClicked: { path: _root.path
// if (isActiveVehicle) { z: _root.zOrderLines
// // Only active vehicle supports click to change current mission item
// guidedActionsController.confirmAction(guidedActionsController.actionSetWaypoint, Math.max(object.sequenceNumber, 1))
// }
// }
} }
} }
// Add the current mission item visuals to the map
Repeater { Repeater {
model: largeMapView ? (_showCurrentItems ? (_wimaEnabled ? wimaController.currentMissionItems :0 ) : 0) : 0 model: largeMapView ? ( showItems ? missionItems : 0) : 0
z: QGroundControl.zOrderWaypointIndicators-1
delegate: WimaMissionItemMapVisual { delegate: WimaMissionItemMapVisual {
map: _map map: _map
color: _root.cMIColor color: _root.color
zOrder: _root.zOrderWP
} }
} }
Component.onCompleted: { Component.onCompleted: {
_missionLineViewComponent = missionLineViewComponent.createObject(map) _missionLineViewComponent = missionLineViewComponent.createObject(map)
if (_missionLineViewComponent.status === Component.Error) if (_missionLineViewComponent.status === Component.Error)
console.log(_missionLineViewComponent.errorString()) console.log(_missionLineViewComponent.errorString())
map.addMapItem(_missionLineViewComponent) map.addMapItem(_missionLineViewComponent)
_currentMissionLineViewComponent = currentMissionLineViewComponent.createObject(map)
if (_currentMissionLineViewComponent.status === Component.Error)
console.log(_currentMissionLineViewComponent.errorString())
map.addMapItem(_currentMissionLineViewComponent)
} }
Component.onDestruction: { Component.onDestruction: {
_missionLineViewComponent.destroy() _missionLineViewComponent.destroy()
_currentMissionLineViewComponent.destroy()
}
Component {
id: missionLineViewComponent
MapPolyline {
line.width: 3
line.color: _showAllItems ? (_wimaEnabled ? mIlineColor : "transparent"): "transparent"
z: QGroundControl.zOrderWaypointLines-2
path: wimaController.waypointPath
}
} }
Component {
id: currentMissionLineViewComponent
MapPolyline {
line.width: 3
line.color: _showCurrentItems ? (_wimaEnabled ? cMIlineColor : "transparent") : "transparent"
z: QGroundControl.zOrderWaypointLines-1
path: wimaController.currentWaypointPath
}
}
} }
...@@ -24,6 +24,7 @@ Item { ...@@ -24,6 +24,7 @@ Item {
property var map ///< Map control to place item in property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs property var qgcView ///< QGCView to use for popping dialogs
property int zOrder
property var color property var color
property var _missionItem: object property var _missionItem: object
...@@ -107,7 +108,7 @@ Item { ...@@ -107,7 +108,7 @@ Item {
MissionItemIndicator { MissionItemIndicator {
coordinate: _missionItem.coordinate coordinate: _missionItem.coordinate
visible: _missionItem.specifiesCoordinate visible: _missionItem.specifiesCoordinate
z: QGroundControl.zOrderMapItems z: _root.zOrder
missionItem: _missionItem missionItem: _missionItem
sequenceNumber: _missionItem.sequenceNumber sequenceNumber: _missionItem.sequenceNumber
color: _root.color color: _root.color
......
...@@ -37,6 +37,7 @@ WimaController::WimaController(QObject *parent) ...@@ -37,6 +37,7 @@ WimaController::WimaController(QObject *parent)
, _phaseDuration(-1) , _phaseDuration(-1)
, _vehicleHasLowBattery(false) , _vehicleHasLowBattery(false)
, _lowBatteryHandlingTriggered(false) , _lowBatteryHandlingTriggered(false)
, _executingSmartRTL(false)
{ {
_nextPhaseStartWaypointIndex.setRawValue(int(1)); _nextPhaseStartWaypointIndex.setRawValue(int(1));
...@@ -50,7 +51,6 @@ WimaController::WimaController(QObject *parent) ...@@ -50,7 +51,6 @@ WimaController::WimaController(QObject *parent)
// battery timer // battery timer
connect(&_checkBatteryTimer, &QTimer::timeout, this, &WimaController::checkBatteryLevel); connect(&_checkBatteryTimer, &QTimer::timeout, this, &WimaController::checkBatteryLevel);
_checkBatteryTimer.setInterval(500); _checkBatteryTimer.setInterval(500);
_checkBatteryTimer.start(); _checkBatteryTimer.start();
} }
...@@ -290,6 +290,27 @@ bool WimaController::calcReturnPath() ...@@ -290,6 +290,27 @@ bool WimaController::calcReturnPath()
return true; return true;
} }
bool WimaController::executeSmartRTL()
{
QString errorString;
bool retValue = _executeSmartRTL(errorString);
if (!retValue) {
qgcApp()->showMessage(errorString);
}
return retValue;
}
bool WimaController::initSmartRTL()
{
masterController()->managerVehicle()->pauseVehicle();
QString errorString;
bool retValue = calcReturnPath();
if (!retValue)
return false;
return true;
}
void WimaController::saveToCurrent() void WimaController::saveToCurrent()
{ {
...@@ -734,14 +755,14 @@ void WimaController::checkBatteryLevel() ...@@ -734,14 +755,14 @@ void WimaController::checkBatteryLevel()
QString errorString; QString errorString;
if (_checkSmartRTLPreCondition(errorString) == true) { if (_checkSmartRTLPreCondition(errorString) == true) {
managerVehicle->pauseVehicle(); managerVehicle->pauseVehicle();
if (_calcReturnPath(errorString)) { if (_calcReturnPath(errorString)) {
_lowBatteryHandlingTriggered = true;
emit returnBatteryLowConfirmRequired(); emit returnBatteryLowConfirmRequired();
} else { } else {
qgcApp()->showMessage(tr("Battery level is low. Smart RTL not possible.")); qgcApp()->showMessage(tr("Battery level is low. Smart RTL not possible."));
qgcApp()->showMessage(errorString); qgcApp()->showMessage(errorString);
} }
} }
_lowBatteryHandlingTriggered = true;
} }
} }
else { else {
...@@ -752,6 +773,19 @@ void WimaController::checkBatteryLevel() ...@@ -752,6 +773,19 @@ void WimaController::checkBatteryLevel()
} }
} }
void WimaController::smartRTLCleanUp(bool flying)
{
if ( !flying) { // vehicle has landed
if (_executingSmartRTL) {
_executingSmartRTL = false;
_loadCurrentMissionItemsFromBuffer();
_showAllMissionItems.setRawValue(true);
disconnect(masterController()->managerVehicle(), &Vehicle::flyingChanged, this, &WimaController::smartRTLCleanUp);
}
}
}
void WimaController::_setPhaseDistance(double distance) void WimaController::_setPhaseDistance(double distance)
{ {
if (!qFuzzyCompare(distance, _phaseDistance)) { if (!qFuzzyCompare(distance, _phaseDistance)) {
...@@ -781,6 +815,8 @@ bool WimaController::_checkSmartRTLPreCondition(QString &errorString) ...@@ -781,6 +815,8 @@ bool WimaController::_checkSmartRTLPreCondition(QString &errorString)
errorString.append(tr("Vehicle is not flying. Smart RTL not available.")); errorString.append(tr("Vehicle is not flying. Smart RTL not available."));
return false; return false;
} }
return true;
} }
bool WimaController::_calcReturnPath(QString &errorSring) bool WimaController::_calcReturnPath(QString &errorSring)
...@@ -807,15 +843,7 @@ bool WimaController::_calcReturnPath(QString &errorSring) ...@@ -807,15 +843,7 @@ bool WimaController::_calcReturnPath(QString &errorSring)
} }
// qWarning() << "returnPath.size()" << returnPath.size(); // qWarning() << "returnPath.size()" << returnPath.size();
// buffer _currentMissionItems _saveCurrentMissionItemsToBuffer();
//qWarning() << "_currentMissionItems.count()" << _currentMissionItems.count();
//qWarning() << "_missionItemsBuffer.count()" << _missionItemsBuffer.count();
_missionItemsBuffer.clear();
int numCurrentMissionItems = _currentMissionItems.count();
for (int i = 0; i < numCurrentMissionItems; i++)
_missionItemsBuffer.append(_currentMissionItems.removeAt(0));
//qWarning() << "_currentMissionItems.count()" << _currentMissionItems.count();
//qWarning() << "_missionItemsBuffer.count()" << _missionItemsBuffer.count();
// create Mission Items // create Mission Items
removeFromVehicle(); removeFromVehicle();
...@@ -904,9 +932,36 @@ void WimaController::_setVehicleHasLowBattery(bool batteryLow) ...@@ -904,9 +932,36 @@ void WimaController::_setVehicleHasLowBattery(bool batteryLow)
_vehicleHasLowBattery = batteryLow; _vehicleHasLowBattery = batteryLow;
emit vehicleHasLowBatteryChanged(); emit vehicleHasLowBatteryChanged();
qWarning() << "WimaController::_setVehicleHasLowBattery(bool batteryLow)" << _vehicleHasLowBattery;
} }
} }
bool WimaController::_executeSmartRTL(QString &errorSring)
{
Q_UNUSED(errorSring);
_executingSmartRTL = true;
connect(masterController()->managerVehicle(), &Vehicle::flyingChanged, this, &WimaController::smartRTLCleanUp);
forceUploadToVehicle();
masterController()->managerVehicle()->startMission();
return true;
}
void WimaController::_loadCurrentMissionItemsFromBuffer()
{
_currentMissionItems.clear();
int numItems = _missionItemsBuffer.count();
for (int i = 0; i < numItems; i++)
_currentMissionItems.append(_missionItemsBuffer.removeAt(0));
}
void WimaController::_saveCurrentMissionItemsToBuffer()
{
_missionItemsBuffer.clear();
int numCurrentMissionItems = _currentMissionItems.count();
for (int i = 0; i < numCurrentMissionItems; i++)
_missionItemsBuffer.append(_currentMissionItems.removeAt(0));
}
...@@ -102,7 +102,9 @@ public: ...@@ -102,7 +102,9 @@ public:
Q_INVOKABLE bool forceUploadToVehicle(); Q_INVOKABLE bool forceUploadToVehicle();
Q_INVOKABLE void removeFromVehicle(); Q_INVOKABLE void removeFromVehicle();
Q_INVOKABLE bool checkSmartRTLPreCondition(); // wrapper for _checkSmartRTLPreCondition(QString &errorString) Q_INVOKABLE bool checkSmartRTLPreCondition(); // wrapper for _checkSmartRTLPreCondition(QString &errorString)
Q_INVOKABLE bool calcReturnPath(); // wrapper for _calcReturnPath(QString &errorSring) Q_INVOKABLE bool calcReturnPath(); // wrapper for _calcReturnPath(QString &errorSring)#
Q_INVOKABLE bool executeSmartRTL(); // wrapper for _executeSmartRTL(QString &errorSring)
Q_INVOKABLE bool initSmartRTL();
Q_INVOKABLE void saveToCurrent (); Q_INVOKABLE void saveToCurrent ();
...@@ -168,6 +170,7 @@ private slots: ...@@ -168,6 +170,7 @@ private slots:
void updateSpeed (void); void updateSpeed (void);
void updateAltitude (void); void updateAltitude (void);
void checkBatteryLevel (void); void checkBatteryLevel (void);
void smartRTLCleanUp (bool flying); // cleans up after successfull smart RTL
private: private:
void _setPhaseDistance(double distance); void _setPhaseDistance(double distance);
...@@ -175,10 +178,9 @@ private: ...@@ -175,10 +178,9 @@ private:
bool _checkSmartRTLPreCondition(QString &errorString); // should be called from gui, befor calcReturnPath() bool _checkSmartRTLPreCondition(QString &errorString); // should be called from gui, befor calcReturnPath()
bool _calcReturnPath(QString &errorSring); // Calculates return path (destination: service area center) for a flying vehicle bool _calcReturnPath(QString &errorSring); // Calculates return path (destination: service area center) for a flying vehicle
void _setVehicleHasLowBattery(bool batteryLow); void _setVehicleHasLowBattery(bool batteryLow);
bool _executeSmartRTL(QString &errorSring);
void _loadCurrentMissionItemsFromBuffer();
void _saveCurrentMissionItemsToBuffer();
private: private:
PlanMasterController *_masterController; PlanMasterController *_masterController;
...@@ -224,6 +226,9 @@ private: ...@@ -224,6 +226,9 @@ private:
QTimer _checkBatteryTimer; QTimer _checkBatteryTimer;
bool _vehicleHasLowBattery; bool _vehicleHasLowBattery;
bool _lowBatteryHandlingTriggered; bool _lowBatteryHandlingTriggered;
bool _executingSmartRTL;
}; };
...@@ -35,6 +35,11 @@ WimaPlaner::WimaPlaner(QObject *parent) ...@@ -35,6 +35,11 @@ WimaPlaner::WimaPlaner(QObject *parent)
_updateTimer.setInterval(500); // 250 ms means: max update time 2*250 ms _updateTimer.setInterval(500); // 250 ms means: max update time 2*250 ms
_updateTimer.start(); _updateTimer.start();
// for debugging and testing purpose
connect(&_autoLoadTimer, &QTimer::timeout, this, &WimaPlaner::autoLoadMission);
_autoLoadTimer.setSingleShot(true);
_autoLoadTimer.start(300);
} }
QmlObjectListModel* WimaPlaner::visualItems() QmlObjectListModel* WimaPlaner::visualItems()
...@@ -381,8 +386,7 @@ bool WimaPlaner::loadFromFile(const QString &filename) ...@@ -381,8 +386,7 @@ bool WimaPlaner::loadFromFile(const QString &filename)
errorString += QString(tr("Invalid or non existing entry for %s.\n").arg(WimaArea::areaTypeName)); errorString += QString(tr("Invalid or non existing entry for %s.\n").arg(WimaArea::areaTypeName));
return false; return false;
} }
} }
recalcJoinedArea();
_currentFile.sprintf("%s/%s.%s", fileInfo.path().toLocal8Bit().data(), fileInfo.completeBaseName().toLocal8Bit().data(), wimaFileExtension); _currentFile.sprintf("%s/%s.%s", fileInfo.path().toLocal8Bit().data(), fileInfo.completeBaseName().toLocal8Bit().data(), wimaFileExtension);
...@@ -442,7 +446,8 @@ bool WimaPlaner::loadFromFile(const QString &filename) ...@@ -442,7 +446,8 @@ bool WimaPlaner::loadFromFile(const QString &filename)
} }
} }
//if (_circularSurvey == nullptr) //if (_circularSurvey == nullptr)
recalcJoinedArea();
updateMission(); updateMission();
// remove temporary file // remove temporary file
...@@ -808,6 +813,12 @@ void WimaPlaner::setSyncronizedWithControllerFalse() ...@@ -808,6 +813,12 @@ void WimaPlaner::setSyncronizedWithControllerFalse()
setSyncronizedWithController(false); setSyncronizedWithController(false);
} }
void WimaPlaner::autoLoadMission()
{
loadFromFile("/home/valentin/Desktop/drones/build-qgroundcontrol-Desktop_Qt_5_11_3_GCC_64bit-Release/release/345.wima");
pushToContainer();
}
QJsonDocument WimaPlaner::saveToJson(FileType fileType) QJsonDocument WimaPlaner::saveToJson(FileType fileType)
{ {
/// This function save all areas (of WimaPlaner) and all mission items (of MissionController) to a QJsonDocument /// This function save all areas (of WimaPlaner) and all mission items (of MissionController) to a QJsonDocument
......
...@@ -133,6 +133,7 @@ private slots: ...@@ -133,6 +133,7 @@ private slots:
// called by _updateTimer::timeout signal, updates different mission parts, if parameters (e.g. survey or areas) have changed // called by _updateTimer::timeout signal, updates different mission parts, if parameters (e.g. survey or areas) have changed
void updateTimerSlot (); void updateTimerSlot ();
void setSyncronizedWithControllerFalse (void); void setSyncronizedWithControllerFalse (void);
void autoLoadMission (void);
private: private:
signals: signals:
void joinedAreaValidChanged(); void joinedAreaValidChanged();
...@@ -174,4 +175,6 @@ private: ...@@ -174,4 +175,6 @@ private:
// sync stuff // sync stuff
bool _syncronizedWithController; // true if planData is syncronized with wimaController bool _syncronizedWithController; // true if planData is syncronized with wimaController
bool _readyForSync; // gets set by updateMission and calcArrivalAndReturnPath bool _readyForSync; // gets set by updateMission and calcArrivalAndReturnPath
QTimer _autoLoadTimer; // timer to auto load mission after some time, prevents seg. faults
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment