Commit 12785a32 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5256 from DonLakeFlyer/EntryLocationChanges

Survey: Entry location changes
parents 6e980ad9 905b33f9
......@@ -350,17 +350,6 @@ const QVariantList& FirmwarePlugin::cameraList(const Vehicle* vehicle)
if (_cameraList.size() == 0) {
CameraMetaData* metaData;
metaData = new CameraMetaData(tr("Typhoon H CGO3+"), // Camera name
6.264, // sensorWidth
4.698, // sensorHeight
4000, // imageWidth
3000, // imageHeight
14, // focalLength
true, // landscape orientation
true, // camera orientation is fixed
this); // parent
_cameraList.append(QVariant::fromValue(metaData));
metaData = new CameraMetaData(tr("Sony ILCE-QX1"), //http://www.sony.co.uk/electronics/interchangeable-lens-cameras/ilce-qx1-body-kit/specifications
23.2, //http://www.sony.com/electronics/camera-lenses/sel16f28/specifications
15.4,
......
......@@ -160,7 +160,7 @@
"name": "GridEntryLocation",
"shortDescription": "Location for entry point into survey area",
"type": "uint32",
"enumStrings": "Top Left, Top Right, Bottom Left, Bottom Right",
"enumStrings": "Position 1, Position 2, Position 3, Position 4",
"enumValues": "0,1,2,3",
"defaultValue": 0
}
......
......@@ -129,6 +129,14 @@ public:
void setTurnaroundDist (double dist) { _turnaroundDistFact.setRawValue(dist); }
void save (QJsonArray& missionItems) final;
// Must match json spec for GridEntryLocation
enum EntryLocation {
EntryLocationTopLeft,
EntryLocationTopRight,
EntryLocationBottomLeft,
EntryLocationBottomRight,
};
static const char* jsonComplexItemTypeValue;
static const char* settingsGroup;
......@@ -178,14 +186,6 @@ private:
CameraTriggerHoverAndCapture
};
// Must match json spec for GridEntryLocation
enum EntryLocation {
EntryLocationTopLeft,
EntryLocationTopRight,
EntryLocationBottomLeft,
EntryLocationBottomRight,
};
void _setExitCoordinate(const QGeoCoordinate& coordinate);
void _generateGrid(void);
void _updateCoordinateAltitude(void);
......
......@@ -178,3 +178,74 @@ void SurveyMissionItemTest::_testCameraTrigger(void)
QCOMPARE(_multiSpy->pullIntFromSignalIndex(lastSequenceNumberChangedIndex), lastSeq);
#endif
}
// Clamp expected grid angle from 0<->180. We don't care about opposite angles like 90/270
double SurveyMissionItemTest::_clampGridAngle180(double gridAngle)
{
if (gridAngle >= 0.0) {
if (gridAngle == 360.0) {
gridAngle = 0.0;
} else if (gridAngle >= 180.0) {
gridAngle -= 180.0;
}
} else {
if (gridAngle < -180.0) {
gridAngle += 360.0;
} else {
gridAngle += 180.0;
}
}
return gridAngle;
}
void SurveyMissionItemTest::_testGridAngle(void)
{
QGCMapPolygon* mapPolygon = _surveyItem->mapPolygon();
for (int i=0; i<_polyPoints.count(); i++) {
QGeoCoordinate& vertex = _polyPoints[i];
mapPolygon->appendVertex(vertex);
}
for (double gridAngle=-360.0; gridAngle<=360.0; gridAngle++) {
_surveyItem->gridAngle()->setRawValue(gridAngle);
QVariantList gridPoints = _surveyItem->gridPoints();
QGeoCoordinate firstTransectEntry = gridPoints[0].value<QGeoCoordinate>();
QGeoCoordinate firstTransectExit = gridPoints[1].value<QGeoCoordinate>();
double azimuth = firstTransectEntry.azimuthTo(firstTransectExit);
//qDebug() << gridAngle << azimuth << _clampGridAngle180(gridAngle) << _clampGridAngle180(azimuth);
QCOMPARE((int)_clampGridAngle180(gridAngle), (int)_clampGridAngle180(azimuth));
}
}
void SurveyMissionItemTest::_testEntryLocation(void)
{
QGCMapPolygon* mapPolygon = _surveyItem->mapPolygon();
for (int i=0; i<_polyPoints.count(); i++) {
QGeoCoordinate& vertex = _polyPoints[i];
mapPolygon->appendVertex(vertex);
}
for (double gridAngle=-360.0; gridAngle<=360.0; gridAngle++) {
_surveyItem->gridAngle()->setRawValue(gridAngle);
QList<QGeoCoordinate> rgSeenEntryCoords;
QList<int> rgEntryLocation;
rgEntryLocation << SurveyMissionItem::EntryLocationTopLeft
<< SurveyMissionItem::EntryLocationTopRight
<< SurveyMissionItem::EntryLocationBottomLeft
<< SurveyMissionItem::EntryLocationBottomRight;
// Validate that each entry location is unique
for (int i=0; i<rgEntryLocation.count(); i++) {
int entryLocation = rgEntryLocation[i];
_surveyItem->gridEntryLocation()->setRawValue(entryLocation);
QVERIFY(!rgSeenEntryCoords.contains(_surveyItem->coordinate()));
rgSeenEntryCoords << _surveyItem->coordinate();
}
rgSeenEntryCoords.clear();
}
}
......@@ -34,8 +34,12 @@ private slots:
void _testDirty(void);
void _testCameraValueChanged(void);
void _testCameraTrigger(void);
void _testGridAngle(void);
void _testEntryLocation(void);
private:
double _clampGridAngle180(double gridAngle);
enum {
gridPointsChangedIndex = 0,
cameraShotsChangedIndex,
......
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