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