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

survey works now

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