From df489c3ee961d1e38317ffdfec19712ec2d6b6e9 Mon Sep 17 00:00:00 2001 From: Valentin Platzgummer Date: Thu, 27 Feb 2020 14:15:39 +0100 Subject: [PATCH] Phase duration and time after smart RTL now displayed correctly --- src/FlightDisplay/FlightDisplayView.qml | 5 +++-- src/FlightDisplay/FlightDisplayWimaMenu.qml | 5 +++++ src/Wima/WimaController.cc | 23 ++++++++++++++------- src/Wima/WimaController.h | 2 ++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 98e48f2ce..2c41ff26b 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -608,7 +608,8 @@ QGCView { anchors.leftMargin: ScreenTools.defaultFontPixelWidth anchors.bottomMargin: ScreenTools.defaultFontPixelWidth maxWidth: singleMultiSelector.x - ScreenTools.defaultFontPixelHeight*4 - maxHeight: parent.height - toolStrip.height - toolStrip.y - ScreenTools.defaultFontPixelHeight*4 + maxHeight: _flightMap.height - toolStrip.height - toolStrip.y + - ScreenTools.defaultFontPixelHeight*4 wimaController: _wimaController @@ -679,7 +680,7 @@ QGCView { maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y buttonVisible: [ _useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true ] buttonEnabled: [ _useChecklist && _activeVehicle, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable ] - horizontal: false + horizontal: true enableSwitchButton: true property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort diff --git a/src/FlightDisplay/FlightDisplayWimaMenu.qml b/src/FlightDisplay/FlightDisplayWimaMenu.qml index 471279ec8..02f55e884 100644 --- a/src/FlightDisplay/FlightDisplayWimaMenu.qml +++ b/src/FlightDisplay/FlightDisplayWimaMenu.qml @@ -21,6 +21,7 @@ Item { id: _root height: mainFrame.height width: mainFrame.width + clip: true property int maxHeight: 500 property int maxWidth: 300 @@ -36,6 +37,10 @@ Item { signal initSmartRTL(); + DeadMouseArea { + anchors.fill: parent + } + Item { id: _private property bool missionReadyForStart: true diff --git a/src/Wima/WimaController.cc b/src/Wima/WimaController.cc index b89c684d1..53db29486 100644 --- a/src/Wima/WimaController.cc +++ b/src/Wima/WimaController.cc @@ -42,6 +42,8 @@ WimaController::WimaController(QObject *parent) , _returnPathLength (-1) , _phaseDistance (-1) , _phaseDuration (-1) + , _phaseDistanceBuffer (-1) + , _phaseDurationBuffer (-1) , _vehicleHasLowBattery (false) , _lowBatteryHandlingTriggered(false) , _executingSmartRTL (false) @@ -807,10 +809,12 @@ bool WimaController::calcNextPhase() _currentMissionItems.append(visualItemCopy); } - _setPhaseDistance(_measurementPathLength + _arrivalPathLength + _returnPathLength); - _setPhaseDuration(_measurementPathLength/_flightSpeed.rawValue().toDouble() - + (_arrivalPathLength + _returnPathLength) - / _arrivalReturnSpeed.rawValue().toDouble()); + double dist = 0; + double time = 0; + if (!_missionController->distanceTimeToMissionEnd(dist, time, 1, false)) + qWarning("WimaController::calcNextPhase: distanceTimeToMissionEnd returned false!"); + _setPhaseDistance(dist); + _setPhaseDuration(time); _missionController->removeAll(); // remove items from _missionController, will be added on upload updateAltitude(); @@ -978,6 +982,8 @@ void WimaController::smartRTLCleanUp(bool flying) if (_executingSmartRTL) { _executingSmartRTL = false; _loadCurrentMissionItemsFromBuffer(); + _setPhaseDistance(_phaseDistanceBuffer); + _setPhaseDuration(_phaseDurationBuffer); _showAllMissionItems.setRawValue(true); _missionController->removeAllFromVehicle(); _missionController->removeAll(); @@ -1062,6 +1068,9 @@ bool WimaController::_calcReturnPath(QString &errorSring) // qWarning() << "returnPath.size()" << returnPath.size(); _saveCurrentMissionItemsToBuffer(); + _phaseDistanceBuffer = _phaseDistance; + _phaseDurationBuffer = _phaseDuration; + // create Mission Items removeFromVehicle(); @@ -1127,10 +1136,8 @@ bool WimaController::_calcReturnPath(QString &errorSring) } //qWarning() << "_currentMissionItems.count()" << _currentMissionItems.count(); - _setPhaseDistance(_phaseDistance + _arrivalPathLength + _returnPathLength); - _setPhaseDuration(_phaseDistance/_flightSpeed.rawValue().toDouble() - + (_arrivalPathLength + _returnPathLength) - / _arrivalReturnSpeed.rawValue().toDouble()); + _setPhaseDistance(-1); + _setPhaseDuration(-1); _missionController->removeAll(); // remove items from _missionController, will be added on upload updateAltitude(); diff --git a/src/Wima/WimaController.h b/src/Wima/WimaController.h index 2c2cb2871..4a4a085fb 100644 --- a/src/Wima/WimaController.h +++ b/src/Wima/WimaController.h @@ -238,6 +238,8 @@ private: double _returnPathLength; // the length of the arrival and return path in meters double _phaseDistance; // the lenth in meters of the current phase double _phaseDuration; // the phase duration in seconds + double _phaseDistanceBuffer; // buffer for storing _phaseDistance when doing smart RTL + double _phaseDurationBuffer; // buffer for storing _phaseDuration when doing smart RTL QTimer _checkBatteryTimer; bool _vehicleHasLowBattery; -- 2.22.0