diff --git a/src/MissionManager/CorridorScanComplexItem.cc b/src/MissionManager/CorridorScanComplexItem.cc index b6be33a3a53947c7c30ca80bf8b26619e2ab7eb2..c6a8a787c2f68c50a07c0f5196beaf7e33a0080b 100644 --- a/src/MissionManager/CorridorScanComplexItem.cc +++ b/src/MissionManager/CorridorScanComplexItem.cc @@ -59,7 +59,17 @@ void CorridorScanComplexItem::_polylineCountChanged(int count) int CorridorScanComplexItem::lastSequenceNumber(void) const { - return _sequenceNumber + ((_corridorPolyline.count() + 2 /* trigger start/stop */ + (_hasTurnaround() ? 2 : 0)) * _transectCount()); + int itemCount = _transectPoints.count(); // Each transpect point represents a waypoint item + + if (_cameraTriggerInTurnAroundFact.rawValue().toDouble()) { + // Only one camera start and on camera stop + itemCount += 2; + } else { + // Each transect will have a camera start and stop in it + itemCount += _transectCount() * 2; + } + + return _sequenceNumber + itemCount - 1; } void CorridorScanComplexItem::save(QJsonArray& missionItems) @@ -144,11 +154,12 @@ int CorridorScanComplexItem::_transectCount(void) const void CorridorScanComplexItem::appendMissionItems(QList& items, QObject* missionItemParent) { - int seqNum = _sequenceNumber; - int pointIndex = 0; + int seqNum = _sequenceNumber; + int pointIndex = 0; + bool imagesEverywhere = _cameraTriggerInTurnAroundFact.rawValue().toDouble(); while (pointIndex < _transectPoints.count()) { - if (_hasTurnaround()) { + if (pointIndex != 0 && _hasTurnaround()) { QGeoCoordinate vertexCoord = _transectPoints[pointIndex++].value(); MissionItem* item = new MissionItem(seqNum++, MAV_CMD_NAV_WAYPOINT, @@ -166,7 +177,7 @@ void CorridorScanComplexItem::appendMissionItems(QList& items, QOb items.append(item); } - bool addTrigger = true; + bool addTrigger = imagesEverywhere ? pointIndex == 0 : true; for (int i=0; i<_corridorPolyline.count(); i++) { QGeoCoordinate vertexCoord = _transectPoints[pointIndex++].value(); MissionItem* item = new MissionItem(seqNum++, @@ -200,19 +211,21 @@ void CorridorScanComplexItem::appendMissionItems(QList& items, QOb } } - MissionItem* item = new MissionItem(seqNum++, - MAV_CMD_DO_SET_CAM_TRIGG_DIST, - MAV_FRAME_MISSION, - 0, // stop triggering - 0, // shutter integration (ignore) - 0, // trigger immediately when starting - 0, 0, 0, 0, // param 4-7 unused - true, // autoContinue - false, // isCurrentItem - missionItemParent); - items.append(item); + if (!imagesEverywhere) { + MissionItem* item = new MissionItem(seqNum++, + MAV_CMD_DO_SET_CAM_TRIGG_DIST, + MAV_FRAME_MISSION, + 0, // stop triggering + 0, // shutter integration (ignore) + 0, // trigger immediately when starting + 0, 0, 0, 0, // param 4-7 unused + true, // autoContinue + false, // isCurrentItem + missionItemParent); + items.append(item); + } - if (_hasTurnaround()) { + if (_hasTurnaround() && pointIndex < _transectPoints.count()) { QGeoCoordinate vertexCoord = _transectPoints[pointIndex++].value(); MissionItem* item = new MissionItem(seqNum++, MAV_CMD_NAV_WAYPOINT, @@ -230,6 +243,20 @@ void CorridorScanComplexItem::appendMissionItems(QList& items, QOb items.append(item); } } + + if (imagesEverywhere) { + MissionItem* item = new MissionItem(seqNum++, + MAV_CMD_DO_SET_CAM_TRIGG_DIST, + MAV_FRAME_MISSION, + 0, // stop triggering + 0, // shutter integration (ignore) + 0, // trigger immediately when starting + 0, 0, 0, 0, // param 4-7 unused + true, // autoContinue + false, // isCurrentItem + missionItemParent); + items.append(item); + } } void CorridorScanComplexItem::applyNewAltitude(double newAltitude) @@ -388,6 +415,21 @@ void CorridorScanComplexItem::_rebuildTransects(void) normalizedTransectPosition += transectSpacing; } + + // At this point _transectPoints has an extra turnaround segment at the beginning and end. + // These must be remove for the correcvt flight pattern. + _transectPoints.takeFirst(); + _transectPoints.takeLast(); + } + + // Calculate distance flown for complex item + _complexDistance = 0; + for (int i=0; i<_transectPoints.count() - 2; i++) { + _complexDistance += _transectPoints[i].value().distanceTo(_transectPoints[i+1].value()); + } + + if (_cameraTriggerInTurnAroundFact.rawValue().toDouble()) { + _cameraShots = qCeil(_complexDistance / _cameraCalc.adjustedFootprintFrontal()->rawValue().toDouble()); } _coordinate = _transectPoints.count() ? _transectPoints.first().value() : QGeoCoordinate(); @@ -395,6 +437,7 @@ void CorridorScanComplexItem::_rebuildTransects(void) emit transectPointsChanged(); emit cameraShotsChanged(); + emit complexDistanceChanged(); emit coordinateChanged(_coordinate); emit exitCoordinateChanged(_exitCoordinate); } diff --git a/src/MissionManager/TransectStyleComplexItem.cc b/src/MissionManager/TransectStyleComplexItem.cc index 8e6a95e95c7d6067a0d753d9510ffcd525df0fd5..27c1f54018ff3df37873a45df5a86ffbe5fd83b7 100644 --- a/src/MissionManager/TransectStyleComplexItem.cc +++ b/src/MissionManager/TransectStyleComplexItem.cc @@ -35,7 +35,7 @@ TransectStyleComplexItem::TransectStyleComplexItem(Vehicle* vehicle, QString set , _sequenceNumber (0) , _dirty (false) , _ignoreRecalc (false) - , _scanDistance (0.0) + , _complexDistance (0) , _cameraShots (0) , _cameraMinTriggerInterval (0) , _cameraCalc (vehicle) @@ -61,14 +61,6 @@ TransectStyleComplexItem::TransectStyleComplexItem(Vehicle* vehicle, QString set connect(_cameraCalc.adjustedFootprintSide(), &Fact::valueChanged, this, &TransectStyleComplexItem::_signalLastSequenceNumberChanged); connect(_cameraCalc.adjustedFootprintFrontal(), &Fact::valueChanged, this, &TransectStyleComplexItem::_signalLastSequenceNumberChanged); - connect(&_turnAroundDistanceFact, &Fact::valueChanged, this, &TransectStyleComplexItem::cameraShotsChanged); - connect(&_hoverAndCaptureFact, &Fact::valueChanged, this, &TransectStyleComplexItem::cameraShotsChanged); - connect(&_refly90DegreesFact, &Fact::valueChanged, this, &TransectStyleComplexItem::cameraShotsChanged); - connect(&_surveyAreaPolygon, &QGCMapPolygon::pathChanged, this, &TransectStyleComplexItem::cameraShotsChanged); - connect(&_cameraTriggerInTurnAroundFact, &Fact::valueChanged, this, &TransectStyleComplexItem::cameraShotsChanged); - connect(_cameraCalc.adjustedFootprintSide(), &Fact::valueChanged, this, &TransectStyleComplexItem::cameraShotsChanged); - connect(_cameraCalc.adjustedFootprintFrontal(), &Fact::valueChanged, this, &TransectStyleComplexItem::cameraShotsChanged); - connect(&_turnAroundDistanceFact, &Fact::valueChanged, this, &TransectStyleComplexItem::complexDistanceChanged); connect(&_hoverAndCaptureFact, &Fact::valueChanged, this, &TransectStyleComplexItem::complexDistanceChanged); connect(&_refly90DegreesFact, &Fact::valueChanged, this, &TransectStyleComplexItem::complexDistanceChanged); @@ -94,14 +86,6 @@ TransectStyleComplexItem::TransectStyleComplexItem(Vehicle* vehicle, QString set connect(this, &TransectStyleComplexItem::transectPointsChanged, this, &TransectStyleComplexItem::greatestDistanceToChanged); } -void TransectStyleComplexItem::_setScanDistance(double scanDistance) -{ - if (!qFuzzyCompare(_scanDistance, scanDistance)) { - _scanDistance = scanDistance; - emit complexDistanceChanged(); - } -} - void TransectStyleComplexItem::_setCameraShots(int cameraShots) { if (_cameraShots != cameraShots) { diff --git a/src/MissionManager/TransectStyleComplexItem.h b/src/MissionManager/TransectStyleComplexItem.h index 1fa540255d255056dfc40f6fc64d9d702e0e6cbb..d624557eb4509d5736600147aa364a7b1253bb29 100644 --- a/src/MissionManager/TransectStyleComplexItem.h +++ b/src/MissionManager/TransectStyleComplexItem.h @@ -61,7 +61,7 @@ public: QString mapVisualQML (void) const override = 0; bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) override = 0; - double complexDistance (void) const final { return _scanDistance; } + double complexDistance (void) const final { return _complexDistance; } double greatestDistanceTo (const QGeoCoordinate &other) const final; // Overrides from VisualMissionItem @@ -119,7 +119,6 @@ protected: void _save (QJsonObject& saveObject); bool _load (const QJsonObject& complexObject, QString& errorString); void _setExitCoordinate (const QGeoCoordinate& coordinate); - void _setScanDistance (double scanDistance); void _setCameraShots (int cameraShots); double _triggerDistance (void) const; int _transectCount (void) const; @@ -135,7 +134,7 @@ protected: QGCMapPolygon _surveyAreaPolygon; bool _ignoreRecalc; - double _scanDistance; + double _complexDistance; int _cameraShots; double _timeBetweenShots; double _cameraMinTriggerInterval; diff --git a/src/MissionManager/TransectStyleComplexItemTest.cc b/src/MissionManager/TransectStyleComplexItemTest.cc index 75c6113975d96322de4ac7a460e36333b9a5f1fa..a9f2372af32e32225d8bfdbf1612ce063f09f790 100644 --- a/src/MissionManager/TransectStyleComplexItemTest.cc +++ b/src/MissionManager/TransectStyleComplexItemTest.cc @@ -110,10 +110,9 @@ void TransectStyleComplexItemTest::_testRebuildTransects(void) // _rebuildTransects call // coveredAreaChanged signal // lastSequenceNumberChanged signal - // cameraShotsChanged signal _adjustSurveAreaPolygon(); QVERIFY(_transectStyleItem->rebuildTransectsCalled); - QVERIFY(_multiSpy->checkSignalsByMask(coveredAreaChangedMask | lastSequenceNumberChangedMask | cameraShotsChangedMask)); + QVERIFY(_multiSpy->checkSignalsByMask(coveredAreaChangedMask | lastSequenceNumberChangedMask)); _transectStyleItem->rebuildTransectsCalled = false; _transectStyleItem->setDirty(false); _multiSpy->clearAllSignals(); @@ -121,7 +120,6 @@ void TransectStyleComplexItemTest::_testRebuildTransects(void) // Changes to these facts should trigger: // _rebuildTransects call // lastSequenceNumberChanged signal - // cameraShotsChanged signal QList rgFacts; rgFacts << _transectStyleItem->turnAroundDistance() << _transectStyleItem->cameraTriggerInTurnAround() @@ -133,7 +131,7 @@ void TransectStyleComplexItemTest::_testRebuildTransects(void) qDebug() << fact->name(); changeFactValue(fact); QVERIFY(_transectStyleItem->rebuildTransectsCalled); - QVERIFY(_multiSpy->checkSignalsByMask(lastSequenceNumberChangedMask | cameraShotsChangedMask)); + QVERIFY(_multiSpy->checkSignalsByMask(lastSequenceNumberChangedMask)); _transectStyleItem->setDirty(false); _multiSpy->clearAllSignals(); _transectStyleItem->rebuildTransectsCalled = false;