Browse Source

Refly and camera shot count support

QGC4.4
DonLakeFlyer 7 years ago
parent
commit
b1201f6f2e
  1. 2
      src/MissionManager/CorridorScanComplexItem.cc
  2. 218
      src/MissionManager/SurveyComplexItem.cc
  3. 1
      src/MissionManager/SurveyComplexItem.h

2
src/MissionManager/CorridorScanComplexItem.cc

@ -456,7 +456,7 @@ void CorridorScanComplexItem::_rebuildTransectsPhase2(void)
{ {
// Calculate distance flown for complex item // Calculate distance flown for complex item
_complexDistance = 0; _complexDistance = 0;
for (int i=0; i<_visualTransectPoints.count() - 2; i++) { for (int i=0; i<_visualTransectPoints.count() - 1; i++) {
_complexDistance += _visualTransectPoints[i].value<QGeoCoordinate>().distanceTo(_visualTransectPoints[i+1].value<QGeoCoordinate>()); _complexDistance += _visualTransectPoints[i].value<QGeoCoordinate>().distanceTo(_visualTransectPoints[i+1].value<QGeoCoordinate>());
} }

218
src/MissionManager/SurveyComplexItem.cc

@ -1137,6 +1137,14 @@ bool SurveyComplexItem::_hoverAndCaptureEnabled(void) const
void SurveyComplexItem::_rebuildTransectsPhase1(void) void SurveyComplexItem::_rebuildTransectsPhase1(void)
{ {
_rebuildTransectsPhase1Worker(false /* refly */);
if (_refly90DegreesFact.rawValue().toBool()) {
_rebuildTransectsPhase1Worker(true /* refly */);
}
}
void SurveyComplexItem::_rebuildTransectsPhase1Worker(bool refly)
{
if (_ignoreRecalc) { if (_ignoreRecalc) {
return; return;
} }
@ -1148,15 +1156,16 @@ void SurveyComplexItem::_rebuildTransectsPhase1(void)
_loadedMissionItemsParent = NULL; _loadedMissionItemsParent = NULL;
} }
// First pass will clear old transect data, refly will append to existing data
if (!refly) {
_transects.clear(); _transects.clear();
_transectsPathHeightInfo.clear(); _transectsPathHeightInfo.clear();
}
if (_surveyAreaPolygon.count() < 3) { if (_surveyAreaPolygon.count() < 3) {
return; return;
} }
QList<QList<QPointF>> transectSegments;
// Convert polygon to NED // Convert polygon to NED
QList<QPointF> polygonPoints; QList<QPointF> polygonPoints;
@ -1177,12 +1186,11 @@ void SurveyComplexItem::_rebuildTransectsPhase1(void)
// Generate transects // Generate transects
bool refly = _refly90DegreesFact.rawValue().toBool();
double gridAngle = _gridAngleFact.rawValue().toDouble(); double gridAngle = _gridAngleFact.rawValue().toDouble();
double gridSpacing = _cameraCalc.adjustedFootprintSide()->rawValue().toDouble(); double gridSpacing = _cameraCalc.adjustedFootprintSide()->rawValue().toDouble();
gridAngle = _clampGridAngle90(gridAngle); gridAngle = _clampGridAngle90(gridAngle);
//gridAngle += refly ? 90 : 0; gridAngle += refly ? 90 : 0;
qCDebug(SurveyComplexItemLog) << "_rebuildTransectsPhase1 Clamped grid angle" << gridAngle; qCDebug(SurveyComplexItemLog) << "_rebuildTransectsPhase1 Clamped grid angle" << gridAngle;
qCDebug(SurveyComplexItemLog) << "_rebuildTransectsPhase1 gridSpacing:gridAngle:refly" << gridSpacing << gridAngle << refly; qCDebug(SurveyComplexItemLog) << "_rebuildTransectsPhase1 gridSpacing:gridAngle:refly" << gridSpacing << gridAngle << refly;
@ -1265,47 +1273,18 @@ void SurveyComplexItem::_rebuildTransectsPhase1(void)
_adjustTransectsToEntryPointLocation(transects); _adjustTransectsToEntryPointLocation(transects);
// Convert to CoordInfo transects if (refly) {
foreach (const QList<QGeoCoordinate>& transect, transects) { _optimizeTransectsForShortestDistance(_transects.last().last().coord, transects);
QGeoCoordinate coord;
QList<TransectStyleComplexItem::CoordInfo_t> coordInfoTransect;
TransectStyleComplexItem::CoordInfo_t coordInfo;
coordInfo = { transect[0], CoordTypeSurveyEdge };
coordInfoTransect.append(coordInfo);
coordInfo = { transect[1], CoordTypeSurveyEdge };
coordInfoTransect.append(coordInfo);
// Extend the transect ends for turnaround
if (_hasTurnaround()) {
QGeoCoordinate turnaroundCoord;
double turnAroundDistance = _turnAroundDistanceFact.rawValue().toDouble();
double azimuth = transect[0].azimuthTo(transect[1]);
turnaroundCoord = transect[0].atDistanceAndAzimuth(-turnAroundDistance, azimuth);
turnaroundCoord.setAltitude(qQNaN());
TransectStyleComplexItem::CoordInfo_t coordInfo = { turnaroundCoord, CoordTypeTurnaround };
coordInfoTransect.prepend(coordInfo);
azimuth = transect.last().azimuthTo(transect[transect.count() - 2]);
turnaroundCoord = transect.last().atDistanceAndAzimuth(-turnAroundDistance, azimuth);
turnaroundCoord.setAltitude(qQNaN());
coordInfo = { turnaroundCoord, CoordTypeTurnaround };
coordInfoTransect.append(coordInfo);
}
_transects.append(coordInfoTransect);
} }
// Adjust to lawnmower pattern // Adjust to lawnmower pattern
bool reverseVertices = false; bool reverseVertices = false;
for (int i=0; i<_transects.count(); i++) { for (int i=0; i<transects.count(); i++) {
// We must reverse the vertices for every other transect in order to make a lawnmower pattern // We must reverse the vertices for every other transect in order to make a lawnmower pattern
QList<TransectStyleComplexItem::CoordInfo_t> transectVertices = _transects[i]; QList<QGeoCoordinate> transectVertices = transects[i];
if (reverseVertices) { if (reverseVertices) {
reverseVertices = false; reverseVertices = false;
QList<TransectStyleComplexItem::CoordInfo_t> reversedVertices; QList<QGeoCoordinate> reversedVertices;
for (int j=transectVertices.count()-1; j>=0; j--) { for (int j=transectVertices.count()-1; j>=0; j--) {
reversedVertices.append(transectVertices[j]); reversedVertices.append(transectVertices[j]);
} }
@ -1313,167 +1292,68 @@ void SurveyComplexItem::_rebuildTransectsPhase1(void)
} else { } else {
reverseVertices = true; reverseVertices = true;
} }
_transects[i] = transectVertices; transects[i] = transectVertices;
}
#if 0
CorridorScan code
if (_ignoreRecalc) {
return;
}
// If the transects are getting rebuilt then any previsouly loaded mission items are now invalid
if (_loadedMissionItemsParent) {
_loadedMissionItems.clear();
_loadedMissionItemsParent->deleteLater();
_loadedMissionItemsParent = NULL;
} }
_transects.clear(); // Convert to CoordInfo transects and append to _transects
_transectsPathHeightInfo.clear(); foreach (const QList<QGeoCoordinate>& transect, transects) {
QGeoCoordinate coord;
QList<TransectStyleComplexItem::CoordInfo_t> coordInfoTransect;
TransectStyleComplexItem::CoordInfo_t coordInfo;
double transectSpacing = _cameraCalc.adjustedFootprintSide()->rawValue().toDouble(); coordInfo = { transect[0], CoordTypeSurveyEdge };
double fullWidth = _corridorWidthFact.rawValue().toDouble(); coordInfoTransect.append(coordInfo);
double halfWidth = fullWidth / 2.0; coordInfo = { transect[1], CoordTypeSurveyEdge };
int transectCount = _transectCount(); coordInfoTransect.append(coordInfo);
double normalizedTransectPosition = transectSpacing / 2.0;
if (_corridorPolyline.count() >= 2) {
// First build up the transects all going the same direction
//qDebug() << "_rebuildTransectsPhase1";
for (int i=0; i<transectCount; i++) {
//qDebug() << "start transect";
double offsetDistance;
if (transectCount == 1) {
// Single transect is flown over scan line
offsetDistance = 0;
} else {
// Convert from normalized to absolute transect offset distance
offsetDistance = halfWidth - normalizedTransectPosition;
}
// Turn transect into CoordInfo transect
QList<TransectStyleComplexItem::CoordInfo_t> transect;
QList<QGeoCoordinate> transectCoords = _corridorPolyline.offsetPolyline(offsetDistance);
for (int j=1; j<transectCoords.count() - 1; j++) {
TransectStyleComplexItem::CoordInfo_t coordInfo = { transectCoords[j], CoordTypeInterior };
transect.append(coordInfo);
}
TransectStyleComplexItem::CoordInfo_t coordInfo = { transectCoords.first(), CoordTypeSurveyEdge };
transect.prepend(coordInfo);
coordInfo = { transectCoords.last(), CoordTypeSurveyEdge };
transect.append(coordInfo);
// Extend the transect ends for turnaround // Extend the transect ends for turnaround
if (_hasTurnaround()) { if (_hasTurnaround()) {
QGeoCoordinate turnaroundCoord; QGeoCoordinate turnaroundCoord;
double turnAroundDistance = _turnAroundDistanceFact.rawValue().toDouble(); double turnAroundDistance = _turnAroundDistanceFact.rawValue().toDouble();
double azimuth = transectCoords[0].azimuthTo(transectCoords[1]); double azimuth = transect[0].azimuthTo(transect[1]);
turnaroundCoord = transectCoords[0].atDistanceAndAzimuth(-turnAroundDistance, azimuth); turnaroundCoord = transect[0].atDistanceAndAzimuth(-turnAroundDistance, azimuth);
turnaroundCoord.setAltitude(qQNaN()); turnaroundCoord.setAltitude(qQNaN());
TransectStyleComplexItem::CoordInfo_t coordInfo = { turnaroundCoord, CoordTypeTurnaround }; TransectStyleComplexItem::CoordInfo_t coordInfo = { turnaroundCoord, CoordTypeTurnaround };
transect.prepend(coordInfo); coordInfoTransect.prepend(coordInfo);
azimuth = transectCoords.last().azimuthTo(transectCoords[transectCoords.count() - 2]); azimuth = transect.last().azimuthTo(transect[transect.count() - 2]);
turnaroundCoord = transectCoords.last().atDistanceAndAzimuth(-turnAroundDistance, azimuth); turnaroundCoord = transect.last().atDistanceAndAzimuth(-turnAroundDistance, azimuth);
turnaroundCoord.setAltitude(qQNaN()); turnaroundCoord.setAltitude(qQNaN());
coordInfo = { turnaroundCoord, CoordTypeTurnaround }; coordInfo = { turnaroundCoord, CoordTypeTurnaround };
transect.append(coordInfo); coordInfoTransect.append(coordInfo);
}
#if 0
qDebug() << "transect debug";
foreach (const TransectStyleComplexItem::CoordInfo_t& coordInfo, transect) {
qDebug() << coordInfo.coordType;
}
#endif
_transects.append(transect);
normalizedTransectPosition += transectSpacing;
}
// Now deal with fixing up the entry point:
// 0: Leave alone
// 1: Start at same end, opposite side of center
// 2: Start at opposite end, same side
// 3: Start at opposite end, opposite side
bool reverseTransects = false;
bool reverseVertices = false;
switch (_entryPoint) {
case 0:
reverseTransects = false;
reverseVertices = false;
break;
case 1:
reverseTransects = true;
reverseVertices = false;
break;
case 2:
reverseTransects = false;
reverseVertices = true;
break;
case 3:
reverseTransects = true;
reverseVertices = true;
break;
}
if (reverseTransects) {
QList<QList<TransectStyleComplexItem::CoordInfo_t>> reversedTransects;
foreach (const QList<TransectStyleComplexItem::CoordInfo_t>& transect, _transects) {
reversedTransects.prepend(transect);
}
_transects = reversedTransects;
}
if (reverseVertices) {
for (int i=0; i<_transects.count(); i++) {
QList<TransectStyleComplexItem::CoordInfo_t> reversedVertices;
foreach (const TransectStyleComplexItem::CoordInfo_t& vertex, _transects[i]) {
reversedVertices.prepend(vertex);
}
_transects[i] = reversedVertices;
}
} }
// Adjust to lawnmower pattern _transects.append(coordInfoTransect);
reverseVertices = false;
for (int i=0; i<_transects.count(); i++) {
// We must reverse the vertices for every other transect in order to make a lawnmower pattern
QList<TransectStyleComplexItem::CoordInfo_t> transectVertices = _transects[i];
if (reverseVertices) {
reverseVertices = false;
QList<TransectStyleComplexItem::CoordInfo_t> reversedVertices;
for (int j=transectVertices.count()-1; j>=0; j--) {
reversedVertices.append(transectVertices[j]);
}
transectVertices = reversedVertices;
} else {
reverseVertices = true;
}
_transects[i] = transectVertices;
}
} }
#endif
} }
void SurveyComplexItem::_rebuildTransectsPhase2(void) void SurveyComplexItem::_rebuildTransectsPhase2(void)
{ {
// Calculate distance flown for complex item // Calculate distance flown for complex item
_complexDistance = 0; _complexDistance = 0;
for (int i=0; i<_visualTransectPoints.count() - 2; i++) { for (int i=0; i<_visualTransectPoints.count() - 1; i++) {
_complexDistance += _visualTransectPoints[i].value<QGeoCoordinate>().distanceTo(_visualTransectPoints[i+1].value<QGeoCoordinate>()); _complexDistance += _visualTransectPoints[i].value<QGeoCoordinate>().distanceTo(_visualTransectPoints[i+1].value<QGeoCoordinate>());
} }
#if 0 double triggerDistance = _cameraCalc.adjustedFootprintFrontal()->rawValue().toDouble();
if (_cameraTriggerInTurnAroundFact.rawValue().toBool()) { if (_cameraTriggerInTurnAroundFact.rawValue().toBool()) {
_cameraShots = qCeil(_complexDistance / _cameraCalc.adjustedFootprintFrontal()->rawValue().toDouble()); _cameraShots = qCeil(_complexDistance / triggerDistance);
} else {
_cameraShots = 0;
foreach (const QList<TransectStyleComplexItem::CoordInfo_t>& transect, _transects) {
QGeoCoordinate firstCameraCoord, lastCameraCoord;
if (_hasTurnaround()) {
firstCameraCoord = transect[1].coord;
lastCameraCoord = transect[transect.count() - 2].coord;
} else { } else {
int singleTransectImageCount = qCeil(_corridorPolyline.length() / _cameraCalc.adjustedFootprintFrontal()->rawValue().toDouble()); firstCameraCoord = transect.first().coord;
_cameraShots = singleTransectImageCount * _transectCount(); lastCameraCoord = transect.last().coord;
}
_cameraShots += qCeil(firstCameraCoord.distanceTo(lastCameraCoord) / triggerDistance);
}
} }
#endif
_coordinate = _visualTransectPoints.count() ? _visualTransectPoints.first().value<QGeoCoordinate>() : QGeoCoordinate(); _coordinate = _visualTransectPoints.count() ? _visualTransectPoints.first().value<QGeoCoordinate>() : QGeoCoordinate();
_exitCoordinate = _visualTransectPoints.count() ? _visualTransectPoints.last().value<QGeoCoordinate>() : QGeoCoordinate(); _exitCoordinate = _visualTransectPoints.count() ? _visualTransectPoints.last().value<QGeoCoordinate>() : QGeoCoordinate();

1
src/MissionManager/SurveyComplexItem.h

@ -101,6 +101,7 @@ private:
bool _hoverAndCaptureEnabled(void) const; bool _hoverAndCaptureEnabled(void) const;
bool _loadV3(const QJsonObject& complexObject, int sequenceNumber, QString& errorString); bool _loadV3(const QJsonObject& complexObject, int sequenceNumber, QString& errorString);
bool _loadV4(const QJsonObject& complexObject, int sequenceNumber, QString& errorString); bool _loadV4(const QJsonObject& complexObject, int sequenceNumber, QString& errorString);
void _rebuildTransectsPhase1Worker(bool refly);
QMap<QString, FactMetaData*> _metaDataMap; QMap<QString, FactMetaData*> _metaDataMap;

Loading…
Cancel
Save