Commit ae16d99f authored by Valentin Platzgummer's avatar Valentin Platzgummer

clear trajectory added to wima menu, zLevel of mission items in flight view fixed

parent 3b25253b
...@@ -223,8 +223,8 @@ FlightMap { ...@@ -223,8 +223,8 @@ FlightMap {
missionItems: wimaController.missionItems missionItems: wimaController.missionItems
path: wimaController.waypointPath path: wimaController.waypointPath
showItems: _wimaEnabled && _showAllWimaItems showItems: _wimaEnabled && _showAllWimaItems
zOrderWP: QGroundControl.zOrderWaypointIndicators-3 zOrderWP: QGroundControl.zOrderWaypointIndicators-2
zOrderLines: QGroundControl.zOrderWaypointLines-1 zOrderLines: QGroundControl.zOrderWaypointLines-2
color: "gray" color: "gray"
} }
// current Items // current Items
...@@ -235,8 +235,8 @@ FlightMap { ...@@ -235,8 +235,8 @@ FlightMap {
path: wimaController.currentWaypointPath path: wimaController.currentWaypointPath
showItems: _wimaEnabled && _showCurrentWimaItems showItems: _wimaEnabled && _showCurrentWimaItems
zOrderWP: QGroundControl.zOrderWaypointIndicators-1 zOrderWP: QGroundControl.zOrderWaypointIndicators-1
zOrderLines: QGroundControl.zOrderWaypointIndicators-2 zOrderLines: QGroundControl.zOrderWaypointLines-1
color: "green" // gray with alpha 0.7 color: "green"
} }
// Add trajectory points to the map // Add trajectory points to the map
......
...@@ -310,6 +310,14 @@ Item { ...@@ -310,6 +310,14 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
} }
QGCButton {
id: buttonRemoveTrajectoryHistory
text: qsTr("Clear Trajectory")
onClicked: wimaController.removeVehicleTrajectoryHistory()
Layout.columnSpan: 2
Layout.fillWidth: true
}
// progess bar // progess bar
Rectangle { Rectangle {
......
...@@ -1051,7 +1051,7 @@ public: ...@@ -1051,7 +1051,7 @@ public:
QGCCameraManager* dynamicCameras () { return _cameras; } QGCCameraManager* dynamicCameras () { return _cameras; }
QString hobbsMeter (); QString hobbsMeter ();
/// @true: When flying a mission the vehicle is always facing towards the next waypoint /// @true: When flying a mission the vehicle is always facing towards the next setCurrentMissionSequence
bool vehicleYawsToNextWaypointInMission(void) const; bool vehicleYawsToNextWaypointInMission(void) const;
/// The vehicle is responsible for making the initial request for the Plan. /// The vehicle is responsible for making the initial request for the Plan.
......
...@@ -292,24 +292,20 @@ bool WimaController::forceUploadToVehicle() ...@@ -292,24 +292,20 @@ bool WimaController::forceUploadToVehicle()
SimpleMissionItem *item = _currentMissionItems.value<SimpleMissionItem *>(i); SimpleMissionItem *item = _currentMissionItems.value<SimpleMissionItem *>(i);
_missionController->insertSimpleMissionItem(*item, visuals->count()); _missionController->insertSimpleMissionItem(*item, visuals->count());
if (item->command() == MAV_CMD_DO_CHANGE_SPEED) { if (item->command() == MAV_CMD_DO_CHANGE_SPEED) {
qWarning() << item->missionItem().param2();
} }
} }
qWarning("blah");
for (int i = 0; i < _missionController->visualItems()->count(); i++){ for (int i = 0; i < _missionController->visualItems()->count(); i++){
SimpleMissionItem *item = _missionController->visualItems()->value<SimpleMissionItem*>(i); SimpleMissionItem *item = _missionController->visualItems()->value<SimpleMissionItem*>(i);
if (item == nullptr) if (item == nullptr)
continue; continue;
if (item->command() == MAV_CMD_DO_CHANGE_SPEED) { if (item->command() == MAV_CMD_DO_CHANGE_SPEED) {
qWarning() << item->missionItem().param2();
} }
} }
for (int i = 0; i < _missionController->visualItems()->count(); i++){ for (int i = 0; i < _missionController->visualItems()->count(); i++){
SimpleMissionItem *item = _missionController->visualItems()->value<SimpleMissionItem*>(i); SimpleMissionItem *item = _missionController->visualItems()->value<SimpleMissionItem*>(i);
if (item == nullptr) if (item == nullptr)
continue; continue;
qWarning() << i << ":" << item->command();
} }
_masterController->sendToVehicle(); _masterController->sendToVehicle();
...@@ -363,9 +359,16 @@ bool WimaController::initSmartRTL() ...@@ -363,9 +359,16 @@ bool WimaController::initSmartRTL()
bool retValue = calcReturnPath(); bool retValue = calcReturnPath();
if (!retValue) if (!retValue)
return false; return false;
emit uploadAndExecuteConfirmRequired();
return true; return true;
} }
void WimaController::removeVehicleTrajectoryHistory()
{
Vehicle *managerVehicle = masterController()->managerVehicle();
managerVehicle->trajectoryPoints()->clear();
}
void WimaController::saveToCurrent() void WimaController::saveToCurrent()
{ {
...@@ -939,20 +942,24 @@ void WimaController::checkBatteryLevel() ...@@ -939,20 +942,24 @@ void WimaController::checkBatteryLevel()
_setVehicleHasLowBattery(true); _setVehicleHasLowBattery(true);
if (!_lowBatteryHandlingTriggered) { if (!_lowBatteryHandlingTriggered) {
QString errorString; QString errorString;
attemptCounter++; attemptCounter++;
if (attemptCounter > 3) {
_lowBatteryHandlingTriggered = true;
attemptCounter = 0;
}
if (_checkSmartRTLPreCondition(errorString) == true) { if (_checkSmartRTLPreCondition(errorString) == true) {
managerVehicle->pauseVehicle(); managerVehicle->pauseVehicle();
if (_calcReturnPath(errorString)) { if (_calcReturnPath(errorString)) {
_lowBatteryHandlingTriggered = true;
attemptCounter = 0;
emit returnBatteryLowConfirmRequired(); emit returnBatteryLowConfirmRequired();
} else { } else {
qgcApp()->showMessage(tr("Battery level is low. Smart RTL not possible.")); if (attemptCounter > 3) {
qgcApp()->showMessage(errorString); qgcApp()->showMessage(tr("Battery level is low. Smart RTL not possible."));
qgcApp()->showMessage(errorString);
}
} }
} }
if (attemptCounter > 3) { // try 3 times, somtimes vehicle is outside joined area
_lowBatteryHandlingTriggered = true;
attemptCounter = 0;
}
} }
} }
else { else {
...@@ -971,6 +978,8 @@ void WimaController::smartRTLCleanUp(bool flying) ...@@ -971,6 +978,8 @@ void WimaController::smartRTLCleanUp(bool flying)
_executingSmartRTL = false; _executingSmartRTL = false;
_loadCurrentMissionItemsFromBuffer(); _loadCurrentMissionItemsFromBuffer();
_showAllMissionItems.setRawValue(true); _showAllMissionItems.setRawValue(true);
_missionController->removeAllFromVehicle();
_missionController->removeAll();
disconnect(masterController()->managerVehicle(), &Vehicle::flyingChanged, this, &WimaController::smartRTLCleanUp); disconnect(masterController()->managerVehicle(), &Vehicle::flyingChanged, this, &WimaController::smartRTLCleanUp);
} }
} }
...@@ -1132,7 +1141,6 @@ bool WimaController::_calcReturnPath(QString &errorSring) ...@@ -1132,7 +1141,6 @@ bool WimaController::_calcReturnPath(QString &errorSring)
_showAllMissionItems.setRawValue(false); _showAllMissionItems.setRawValue(false);
managerVehicle->trajectoryPoints()->clear(); managerVehicle->trajectoryPoints()->clear();
emit uploadAndExecuteConfirmRequired();
return true; return true;
} }
...@@ -1160,6 +1168,7 @@ void WimaController::_loadCurrentMissionItemsFromBuffer() ...@@ -1160,6 +1168,7 @@ void WimaController::_loadCurrentMissionItemsFromBuffer()
{ {
_currentMissionItems.clear(); _currentMissionItems.clear();
int numItems = _missionItemsBuffer.count(); int numItems = _missionItemsBuffer.count();
qWarning() << "WimaController::_loadCurrentMissionItemsFromBuffer: numItems" << numItems;
for (int i = 0; i < numItems; i++) for (int i = 0; i < numItems; i++)
_currentMissionItems.append(_missionItemsBuffer.removeAt(0)); _currentMissionItems.append(_missionItemsBuffer.removeAt(0));
...@@ -1170,8 +1179,9 @@ void WimaController::_loadCurrentMissionItemsFromBuffer() ...@@ -1170,8 +1179,9 @@ void WimaController::_loadCurrentMissionItemsFromBuffer()
void WimaController::_saveCurrentMissionItemsToBuffer() void WimaController::_saveCurrentMissionItemsToBuffer()
{ {
_missionItemsBuffer.clear(); _missionItemsBuffer.clear();
int numCurrentMissionItems = _currentMissionItems.count(); int numItems = _currentMissionItems.count();
for (int i = 0; i < numCurrentMissionItems; i++) qWarning() << "WimaController::_saveCurrentMissionItemsToBuffer: numItems" << numItems;
for (int i = 0; i < numItems; i++)
_missionItemsBuffer.append(_currentMissionItems.removeAt(0)); _missionItemsBuffer.append(_currentMissionItems.removeAt(0));
} }
......
...@@ -111,6 +111,7 @@ public: ...@@ -111,6 +111,7 @@ public:
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 executeSmartRTL(); // wrapper for _executeSmartRTL(QString &errorSring)
Q_INVOKABLE bool initSmartRTL(); Q_INVOKABLE bool initSmartRTL();
Q_INVOKABLE void removeVehicleTrajectoryHistory();
Q_INVOKABLE void saveToCurrent (); Q_INVOKABLE void saveToCurrent ();
......
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