Commit 8cf21ae7 authored by Valentin Platzgummer's avatar Valentin Platzgummer
Browse files

survey works now

parent 887e51f1
optimize circular survey optimize circular survey
remove Reference artefacts profile survey
solve Dijkstra issue (path not found, or not minimal) add dijkstra to flight view
...@@ -11,6 +11,7 @@ CircularSurveyComplexItem::CircularSurveyComplexItem(Vehicle *vehicle, bool flyV ...@@ -11,6 +11,7 @@ CircularSurveyComplexItem::CircularSurveyComplexItem(Vehicle *vehicle, bool flyV
, _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/CircularSurvey.SettingsGroup.json"), this)) , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/CircularSurvey.SettingsGroup.json"), this))
, _deltaR (settingsGroup, _metaDataMap[deltaRName]) , _deltaR (settingsGroup, _metaDataMap[deltaRName])
, _deltaAlpha (settingsGroup, _metaDataMap[deltaAlphaName]) , _deltaAlpha (settingsGroup, _metaDataMap[deltaAlphaName])
, _autoGenerated (false)
{ {
_editorQml = "qrc:/qml/CircularSurveyItemEditor.qml"; _editorQml = "qrc:/qml/CircularSurveyItemEditor.qml";
...@@ -37,6 +38,15 @@ void CircularSurveyComplexItem::setRefPoint(const QGeoCoordinate &refPt) ...@@ -37,6 +38,15 @@ void CircularSurveyComplexItem::setRefPoint(const QGeoCoordinate &refPt)
} }
} }
void CircularSurveyComplexItem::setAutoGenerated(bool autoGen)
{
if (autoGen != _autoGenerated) {
_autoGenerated = autoGen;
emit autoGeneratedChanged();
}
}
QGeoCoordinate CircularSurveyComplexItem::refPoint() const QGeoCoordinate CircularSurveyComplexItem::refPoint() const
{ {
return _referencePoint; return _referencePoint;
...@@ -52,6 +62,11 @@ Fact *CircularSurveyComplexItem::deltaAlpha() ...@@ -52,6 +62,11 @@ Fact *CircularSurveyComplexItem::deltaAlpha()
return &_deltaAlpha; return &_deltaAlpha;
} }
bool CircularSurveyComplexItem::autoGenerated()
{
return _autoGenerated;
}
bool CircularSurveyComplexItem::load(const QJsonObject &complexObject, int sequenceNumber, QString &errorString) bool CircularSurveyComplexItem::load(const QJsonObject &complexObject, int sequenceNumber, QString &errorString)
{ {
return false; return false;
......
...@@ -20,14 +20,19 @@ public: ...@@ -20,14 +20,19 @@ public:
Q_PROPERTY(QGeoCoordinate refPoint READ refPoint WRITE setRefPoint NOTIFY refPointChanged) Q_PROPERTY(QGeoCoordinate refPoint READ refPoint WRITE setRefPoint NOTIFY refPointChanged)
Q_PROPERTY(Fact* deltaR READ deltaR CONSTANT) Q_PROPERTY(Fact* deltaR READ deltaR CONSTANT)
Q_PROPERTY(Fact* deltaAlpha READ deltaAlpha CONSTANT) Q_PROPERTY(Fact* deltaAlpha READ deltaAlpha CONSTANT)
Q_PROPERTY(bool autoGenerated READ autoGenerated NOTIFY autoGeneratedChanged)
// Property setters // Property setters
void setRefPoint(const QGeoCoordinate &refPt); void setRefPoint(const QGeoCoordinate &refPt);
// Set this to true if survey was automatically generated, prevents initialisation from gui.
void setAutoGenerated(bool autoGen);
// Property getters // Property getters
QGeoCoordinate refPoint() const; QGeoCoordinate refPoint() const;
Fact *deltaR(); Fact *deltaR();
Fact *deltaAlpha(); Fact *deltaAlpha();
// Is true if survey was automatically generated, prevents initialisation from gui.
bool autoGenerated();
// Overrides from ComplexMissionItem // Overrides from ComplexMissionItem
bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final; bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final;
...@@ -53,6 +58,7 @@ public: ...@@ -53,6 +58,7 @@ public:
signals: signals:
void refPointChanged(); void refPointChanged();
void autoGeneratedChanged();
private slots: private slots:
// Overrides from TransectStyleComplexItem // Overrides from TransectStyleComplexItem
...@@ -72,6 +78,8 @@ private: ...@@ -72,6 +78,8 @@ private:
SettingsFact _deltaAlpha; SettingsFact _deltaAlpha;
QTimer _updateTimer; QTimer _updateTimer;
bool _autoGenerated; // set to true if survey was automatically generated, prevents initialisation from gui
}; };
......
...@@ -46,6 +46,10 @@ namespace OptimisationTools { ...@@ -46,6 +46,10 @@ namespace OptimisationTools {
workingSet.append(&nodeList[i]); workingSet.append(&nodeList[i]);
} }
// double d1 = distanceDij(elements[0], elements[1]);
// double d2 = distanceDij(elements[0], elements[5]);
// double d3 = distanceDij(elements[5], elements[1]);
nodeList[startIndex].distance = 0; nodeList[startIndex].distance = 0;
// Dijkstra Algorithm // Dijkstra Algorithm
...@@ -67,6 +71,9 @@ namespace OptimisationTools { ...@@ -67,6 +71,9 @@ namespace OptimisationTools {
Node* u = workingSet.takeAt(minDistIndex); Node* u = workingSet.takeAt(minDistIndex);
if (u->element == elements[endIndex]) // shortest path found
break;
//update distance //update distance
for (int i = 0; i < workingSet.size(); i++) { for (int i = 0; i < workingSet.size(); i++) {
Node* v = workingSet[i]; Node* v = workingSet[i];
......
...@@ -215,9 +215,30 @@ bool WimaPlaner::updateMission() ...@@ -215,9 +215,30 @@ bool WimaPlaner::updateMission()
_visualItems.append(&_joinedArea); _visualItems.append(&_joinedArea);
#endif #endif
// extract old survey data
QmlObjectListModel* missionItems = _missionController->visualItems();
CircularSurveyComplexItem* OldSurveyPt = nullptr;
QGeoCoordinate oldSurveyRef;
double oldSurveyDeltaR = 0;
double oldSurveyDeltaAlpha = 0;
bool oldSurveyExists = false;
for (int i = 0; i < _missionController->visualItems()->count(); i++) {
OldSurveyPt = qobject_cast<CircularSurveyComplexItem*>(missionItems->get(i));
if ( OldSurveyPt != nullptr) {
oldSurveyRef = OldSurveyPt->refPoint();
oldSurveyDeltaR = OldSurveyPt->deltaR()->rawValue().toDouble();
oldSurveyDeltaAlpha = OldSurveyPt->deltaAlpha()->rawValue().toDouble();
oldSurveyExists = true;
break;
}
}
// reset visual items // reset visual items
_missionController->removeAll(); _missionController->removeAll();
QmlObjectListModel* missionItems = _missionController->visualItems(); missionItems = _missionController->visualItems();
// set home position to serArea center // set home position to serArea center
MissionSettingsItem* settingsItem= qobject_cast<MissionSettingsItem*>(missionItems->get(0)); MissionSettingsItem* settingsItem= qobject_cast<MissionSettingsItem*>(missionItems->get(0));
if (settingsItem == nullptr){ if (settingsItem == nullptr){
...@@ -248,21 +269,36 @@ bool WimaPlaner::updateMission() ...@@ -248,21 +269,36 @@ bool WimaPlaner::updateMission()
// create survey item, will be extened with more()-> mission types in the future // create survey item, will be extened with more()-> mission types in the future
_missionController->insertComplexMissionItem(_missionController->circularSurveyComplexItemName(), _measurementArea.center(), missionItems->count()); _missionController->insertComplexMissionItem(_missionController->circularSurveyComplexItemName(), _measurementArea.center(), missionItems->count());
CircularSurveyComplexItem* survey = qobject_cast<CircularSurveyComplexItem*>(missionItems->get(missionItems->count()-1)); CircularSurveyComplexItem* survey = qobject_cast<CircularSurveyComplexItem*>(missionItems->get(missionItems->count()-1));
if (survey == nullptr){ if (survey == nullptr){
qWarning("WimaPlaner::updateMission(): survey == nullptr"); qWarning("WimaPlaner::updateMission(): survey == nullptr");
return false; return false;
} else { } else {
if ( oldSurveyExists ) {
survey->setRefPoint(oldSurveyRef);
survey->deltaR()->setRawValue(oldSurveyDeltaR);
survey->deltaAlpha()->setRawValue(oldSurveyDeltaAlpha);
} else {
survey->setRefPoint(_measurementArea.center());
}
survey->setAutoGenerated(true); // prevents reinitialisation from gui
survey->surveyAreaPolygon()->clear(); survey->surveyAreaPolygon()->clear();
survey->surveyAreaPolygon()->appendVertices(_measurementArea.coordinateList()); survey->surveyAreaPolygon()->appendVertices(_measurementArea.coordinateList());
} }
// calculate path from take off to opArea // calculate path from take off to opArea
if (survey->visualTransectPoints().size() == 0) { if (survey->visualTransectPoints().size() == 0) {
qWarning("WimaPlaner::updateMission(): survey no points."); qWarning("WimaPlaner::updateMission(): survey no points.");
return false; return false;
} }
QGeoCoordinate start = _serviceArea.center(); QGeoCoordinate start = _serviceArea.center();
QGeoCoordinate end = survey->visualTransectPoints().first().value<QGeoCoordinate>(); QGeoCoordinate end = survey->coordinate();
if (!_visualItems.contains(&_joinedArea)) if (!_visualItems.contains(&_joinedArea))
_visualItems.append(&_joinedArea); _visualItems.append(&_joinedArea);
...@@ -271,19 +307,29 @@ bool WimaPlaner::updateMission() ...@@ -271,19 +307,29 @@ bool WimaPlaner::updateMission()
qgcApp()->showMessage( QString(tr("Not able to calculate the path from takeoff position to measurement area.")).toLocal8Bit().data()); qgcApp()->showMessage( QString(tr("Not able to calculate the path from takeoff position to measurement area.")).toLocal8Bit().data());
return false; return false;
} }
// path.clear();
// path.append(end);
// path.append(start);
// path.append(end);
// path.append(end);
for (int i = 1; i < path.count()-1; i++) { for (int i = 1; i < path.count()-1; i++) {
sequenceNumber = _missionController->insertSimpleMissionItem(path.value(i), missionItems->count()-1); sequenceNumber = _missionController->insertSimpleMissionItem(path.value(i), missionItems->count()-1);
_missionController->setCurrentPlanViewIndex(sequenceNumber, true); _missionController->setCurrentPlanViewIndex(sequenceNumber, true);
} }
// calculate return path // calculate return path
start = survey->visualTransectPoints().last().value<QGeoCoordinate>(); start = survey->exitCoordinate();
end = _serviceArea.center(); end = _serviceArea.center();
path.clear(); path.clear();
if ( !calcShortestPath(start, end, path)) { if ( !calcShortestPath(start, end, path)) {
qgcApp()->showMessage(QString(tr("Not able to calculate the path from measurement area to landing position.")).toLocal8Bit().data()); qgcApp()->showMessage(QString(tr("Not able to calculate the path from measurement area to landing position.")).toLocal8Bit().data());
return false; return false;
} }
// path.clear();
// path.append(end);
// path.append(start);
// path.append(end);
// path.append(end);
for (int i = 1; i < path.count()-1; i++) { for (int i = 1; i < path.count()-1; i++) {
sequenceNumber = _missionController->insertSimpleMissionItem(path.value(i), missionItems->count()); sequenceNumber = _missionController->insertSimpleMissionItem(path.value(i), missionItems->count());
_missionController->setCurrentPlanViewIndex(sequenceNumber, true); _missionController->setCurrentPlanViewIndex(sequenceNumber, true);
...@@ -583,7 +629,7 @@ bool WimaPlaner::calcShortestPath(const QGeoCoordinate &start, const QGeoCoordin ...@@ -583,7 +629,7 @@ bool WimaPlaner::calcShortestPath(const QGeoCoordinate &start, const QGeoCoordin
/*start point*/ QPointF(0,0), /*start point*/ QPointF(0,0),
/*destination*/ toCartesian2D(destination, start), /*destination*/ toCartesian2D(destination, start),
/*shortest path*/ path2D); /*shortest path*/ path2D);
path.append(toGeo(path2D, /*origin*/start)); path.append(toGeo(path2D, /*origin*/ start));
return retVal; return retVal;
} }
......
...@@ -90,9 +90,12 @@ Item { ...@@ -90,9 +90,12 @@ Item {
} }
Component.onCompleted: { Component.onCompleted: {
_addInitialPolygon() if ( !_missionItem.autoGenerated ) {
_addInitialPolygon()
_setRefPoint()
}
_addVisualElements() _addVisualElements()
_setRefPoint()
} }
Component.onDestruction: { Component.onDestruction: {
......
Supports Markdown
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