Commit 296a43ce authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #4895 from DonLakeFlyer/NoImageInTurnaround

Plan: Support for images in turnaround on/off
parents 0f8466d6 827eddf3
......@@ -12,7 +12,7 @@
"shortDescription": "Specify the distance between each photo",
"type": "double",
"units": "m",
"min": 0,
"min": 0.1,
"decimalPlaces": 1,
"defaultValue": 1
},
......
......@@ -229,36 +229,40 @@ bool CameraSection::scanForCameraSection(QmlObjectListModel* visualItems, int sc
cameraAction()->setRawValue(TakePhotosIntervalTime);
cameraPhotoIntervalTime()->setRawValue(missionItem.param1());
visualItems->removeAt(scanIndex)->deleteLater();
} else {
stopLooking = true;
}
stopLooking = true;
break;
case MAV_CMD_DO_SET_CAM_TRIGG_DIST:
if (!foundCameraAction && missionItem.param1() >= 0 && missionItem.param2() == 0 && missionItem.param3() == 0 && missionItem.param4() == 0 && missionItem.param5() == 0 && missionItem.param6() == 0 && missionItem.param7() == 0) {
// At this point we don't know if we have a stop taking photos pair, or a single distance trigger where the user specified 0
// We need to look at the next item to check for the stop taking photos pari
// At this point we don't know if we have a stop taking photos pair, or just a distance trigger
if (missionItem.param1() == 0 && scanIndex < visualItems->count() - 1) {
// Possible stop taking photos pair
SimpleMissionItem* nextItem = visualItems->value<SimpleMissionItem*>(scanIndex + 1);
if (nextItem) {
missionItem = nextItem->missionItem();
if ((MAV_CMD)item->command() == MAV_CMD_IMAGE_STOP_CAPTURE && missionItem.param1() == 0 && missionItem.param2() == 0 && missionItem.param3() == 0 && missionItem.param4() == 0 && missionItem.param5() == 0 && missionItem.param6() == 0 && missionItem.param7() == 0) {
MissionItem& nextMissionItem = nextItem->missionItem();
if (nextMissionItem.command() == MAV_CMD_IMAGE_STOP_CAPTURE && nextMissionItem.param1() == 0 && nextMissionItem.param2() == 0 && nextMissionItem.param3() == 0 && nextMissionItem.param4() == 0 && nextMissionItem.param5() == 0 && nextMissionItem.param6() == 0 && nextMissionItem.param7() == 0) {
// We found a stop taking photos pair
foundCameraAction = true;
cameraAction()->setRawValue(StopTakingPhotos);
visualItems->removeAt(scanIndex)->deleteLater();
visualItems->removeAt(scanIndex)->deleteLater();
stopLooking = true;
break;
}
}
}
// We didn't find a stop taking photos pair, so this is a regular trigger distance item
foundCameraAction = true;
cameraAction()->setRawValue(TakePhotoIntervalDistance);
cameraPhotoIntervalDistance()->setRawValue(missionItem.param1());
visualItems->removeAt(scanIndex)->deleteLater();
break;
// We didn't find a stop taking photos pair, check for trigger distance
if (missionItem.param1() > 0) {
foundCameraAction = true;
cameraAction()->setRawValue(TakePhotoIntervalDistance);
cameraPhotoIntervalDistance()->setRawValue(missionItem.param1());
visualItems->removeAt(scanIndex)->deleteLater();
stopLooking = true;
break;
}
}
stopLooking = true;
break;
......@@ -268,9 +272,8 @@ bool CameraSection::scanForCameraSection(QmlObjectListModel* visualItems, int sc
foundCameraAction = true;
cameraAction()->setRawValue(TakeVideo);
visualItems->removeAt(scanIndex)->deleteLater();
} else {
stopLooking = true;
}
stopLooking = true;
break;
case MAV_CMD_VIDEO_STOP_CAPTURE:
......@@ -278,9 +281,8 @@ bool CameraSection::scanForCameraSection(QmlObjectListModel* visualItems, int sc
foundCameraAction = true;
cameraAction()->setRawValue(StopTakingVideo);
visualItems->removeAt(scanIndex)->deleteLater();
} else {
stopLooking = true;
}
stopLooking = true;
break;
default:
......
......@@ -817,11 +817,11 @@
}
},
{
"id": 206,
"rawName": "MAV_CMD_DO_SET_CAM_TRIGG_DIST",
"friendlyName": "Camera trigger distance",
"description": "Set camera trigger distance.",
"category": "Camera",
"id": 206,
"rawName": "MAV_CMD_DO_SET_CAM_TRIGG_DIST",
"friendlyName": "Camera trigger distance",
"description": "Set camera trigger distance.",
"category": "Camera",
"param1": {
"label": "Distance",
"default": 25,
......
......@@ -1555,10 +1555,8 @@ void MissionController::_scanForAdditionalSettings(QmlObjectListModel* visualIte
}
SimpleMissionItem* simpleItem = qobject_cast<SimpleMissionItem*>(visualItem);
if (simpleItem && simpleItem->cameraSection()->available()) {
scanIndex++;
simpleItem->scanForSections(visualItems, scanIndex, vehicle);
continue;
if (simpleItem) {
simpleItem->scanForSections(visualItems, scanIndex + 1, vehicle);
}
scanIndex++;
......
......@@ -655,16 +655,17 @@ double SimpleMissionItem::specifiedGimbalYaw(void)
return _cameraSection->available() ? _cameraSection->specifiedGimbalYaw() : missionItem().specifiedGimbalYaw();
}
void SimpleMissionItem::scanForSections(QmlObjectListModel* visualItems, int scanIndex, Vehicle* vehicle)
bool SimpleMissionItem::scanForSections(QmlObjectListModel* visualItems, int scanIndex, Vehicle* vehicle)
{
Q_UNUSED(vehicle);
bool sectionFound = false;
qDebug() << "SimpleMissionItem::scanForSections" << scanIndex << _cameraSection->available();
Q_UNUSED(vehicle);
if (_cameraSection->available()) {
bool sectionFound = _cameraSection->scanForCameraSection(visualItems, scanIndex);
qDebug() << sectionFound;
sectionFound = _cameraSection->scanForCameraSection(visualItems, scanIndex);
}
return sectionFound;
}
void SimpleMissionItem::_updateCameraSection(void)
......
......@@ -48,7 +48,8 @@ public:
/// @param visualItems List of all visual items
/// @param scanIndex Index to start scanning from
/// @param vehicle Vehicle associated with this mission
void scanForSections(QmlObjectListModel* visualItems, int scanIndex, Vehicle* vehicle);
/// @return true: section found
bool scanForSections(QmlObjectListModel* visualItems, int scanIndex, Vehicle* vehicle);
// Property accesors
......
......@@ -130,6 +130,18 @@
"units": "m",
"defaultValue": 25
},
{
"name": "CameraTriggerInTurnaround",
"shortDescription": "Camera continues taking images in turnarounds.",
"type": "bool",
"defaultValue": false
},
{
"name": "HoverAndCapture",
"shortDescription": "Hover at each image point and take image",
"type": "bool",
"defaultValue": false
},
{
"name": "CameraOrientationLandscape",
"shortDescription": "Camera on vehicle is in landscape orientation.",
......@@ -140,7 +152,7 @@
"name": "FixedValueIsAltitude",
"shortDescription": "The altitude is kep constant while ground resolution changes.",
"type": "bool",
"defaultValue": 0
"defaultValue": false
},
{
"name": "Camera",
......
This diff is collapsed.
......@@ -32,6 +32,8 @@ public:
Q_PROPERTY(Fact* turnaroundDist READ turnaroundDist CONSTANT)
Q_PROPERTY(Fact* cameraTrigger READ cameraTrigger CONSTANT)
Q_PROPERTY(Fact* cameraTriggerDistance READ cameraTriggerDistance CONSTANT)
Q_PROPERTY(Fact* cameraTriggerInTurnaround READ cameraTriggerInTurnaround CONSTANT)
Q_PROPERTY(Fact* hoverAndCapture READ hoverAndCapture CONSTANT)
Q_PROPERTY(Fact* groundResolution READ groundResolution CONSTANT)
Q_PROPERTY(Fact* frontalOverlap READ frontalOverlap CONSTANT)
Q_PROPERTY(Fact* sideOverlap READ sideOverlap CONSTANT)
......@@ -68,7 +70,7 @@ public:
QVariantList polygonPath (void) { return _polygonPath; }
QmlObjectListModel* polygonModel(void) { return &_polygonModel; }
QVariantList gridPoints (void) { return _gridPoints; }
QVariantList gridPoints (void) { return _simpleGridPoints; }
Fact* manualGrid (void) { return &_manualGridFact; }
Fact* gridAltitude (void) { return &_gridAltitudeFact; }
......@@ -78,6 +80,8 @@ public:
Fact* turnaroundDist (void) { return &_turnaroundDistFact; }
Fact* cameraTrigger (void) { return &_cameraTriggerFact; }
Fact* cameraTriggerDistance (void) { return &_cameraTriggerDistanceFact; }
Fact* cameraTriggerInTurnaround (void) { return &_cameraTriggerInTurnaroundFact; }
Fact* hoverAndCapture (void) { return &_hoverAndCaptureFact; }
Fact* groundResolution (void) { return &_groundResolutionFact; }
Fact* frontalOverlap (void) { return &_frontalOverlapFact; }
Fact* sideOverlap (void) { return &_sideOverlapFact; }
......@@ -141,6 +145,8 @@ public:
static const char* gridSpacingName;
static const char* turnaroundDistName;
static const char* cameraTriggerDistanceName;
static const char* cameraTriggerInTurnaroundName;
static const char* hoverAndCaptureName;
static const char* groundResolutionName;
static const char* frontalOverlapName;
static const char* sideOverlapName;
......@@ -166,14 +172,21 @@ signals:
private slots:
void _cameraTriggerChanged(void);
void _setDirty(void);
private:
enum CameraTriggerCode {
CameraTriggerNone,
CameraTriggerOn,
CameraTriggerOff
};
void _clear(void);
void _setExitCoordinate(const QGeoCoordinate& coordinate);
void _clearGrid(void);
void _generateGrid(void);
void _updateCoordinateAltitude(void);
void _gridGenerator(const QList<QPointF>& polygonPoints, QList<QPointF>& gridPoints);
void _gridGenerator(const QList<QPointF>& polygonPoints, QList<QPointF>& simpleGridPoints, QList<QList<QPointF>>& gridSegments);
QPointF _rotatePoint(const QPointF& point, const QPointF& origin, double angle);
void _intersectLinesWithRect(const QList<QLineF>& lineList, const QRectF& boundRect, QList<QLineF>& resultLines);
void _intersectLinesWithPolygon(const QList<QLineF>& lineList, const QPolygonF& polygon, QList<QLineF>& resultLines);
......@@ -182,15 +195,17 @@ private:
void _setCameraShots(int cameraShots);
void _setCoveredArea(double coveredArea);
void _cameraValueChanged(void);
int _sequenceNumber;
bool _dirty;
QVariantList _polygonPath;
QmlObjectListModel _polygonModel;
QVariantList _gridPoints;
QGeoCoordinate _coordinate;
QGeoCoordinate _exitCoordinate;
bool _cameraOrientationFixed;
int _appendWaypointToMission(QList<MissionItem*>& items, int seqNum, QGeoCoordinate& coord, CameraTriggerCode cameraTrigger, QObject* missionItemParent);
int _sequenceNumber;
bool _dirty;
QVariantList _polygonPath;
QmlObjectListModel _polygonModel;
QVariantList _simpleGridPoints; ///< Grid points for drawing simple grid visuals
QList<QList<QGeoCoordinate>> _gridSegments; ///< Internal grid line segments including grid exit and turnaround point
QGeoCoordinate _coordinate;
QGeoCoordinate _exitCoordinate;
bool _cameraOrientationFixed;
double _surveyDistance;
int _cameraShots;
......@@ -208,6 +223,8 @@ private:
SettingsFact _turnaroundDistFact;
SettingsFact _cameraTriggerFact;
SettingsFact _cameraTriggerDistanceFact;
SettingsFact _cameraTriggerInTurnaroundFact;
SettingsFact _hoverAndCaptureFact;
SettingsFact _groundResolutionFact;
SettingsFact _frontalOverlapFact;
SettingsFact _sideOverlapFact;
......@@ -229,6 +246,8 @@ private:
static const char* _jsonTurnaroundDistKey;
static const char* _jsonCameraTriggerKey;
static const char* _jsonCameraTriggerDistanceKey;
static const char* _jsonCameraTriggerInTurnaroundKey;
static const char* _jsonHoverAndCaptureKey;
static const char* _jsonGroundResolutionKey;
static const char* _jsonFrontalOverlapKey;
static const char* _jsonSideOverlapKey;
......
......@@ -180,40 +180,73 @@ Rectangle {
spacing: _margin
SectionHeader {
id: cameraHeader
text: qsTr("Camera")
showSpacer: false
}
QGCComboBox {
id: gridTypeCombo
Column {
anchors.left: parent.left
anchors.right: parent.right
model: _cameraList
currentIndex: -1
onActivated: {
if (index == _gridTypeManual) {
missionItem.manualGrid.value = true
} else if (index == _gridTypeCustomCamera) {
missionItem.manualGrid.value = false
missionItem.camera.value = gridTypeCombo.textAt(index)
missionItem.cameraOrientationFixed = false
} else {
missionItem.manualGrid.value = false
missionItem.camera.value = gridTypeCombo.textAt(index)
_noCameraValueRecalc = true
var listIndex = index - _gridTypeCamera
missionItem.cameraSensorWidth.rawValue = _vehicleCameraList[listIndex].sensorWidth
missionItem.cameraSensorHeight.rawValue = _vehicleCameraList[listIndex].sensorHeight
missionItem.cameraResolutionWidth.rawValue = _vehicleCameraList[listIndex].imageWidth
missionItem.cameraResolutionHeight.rawValue = _vehicleCameraList[listIndex].imageHeight
missionItem.cameraFocalLength.rawValue = _vehicleCameraList[listIndex].focalLength
missionItem.cameraOrientationLandscape.rawValue = _vehicleCameraList[listIndex].landscape ? 1 : 0
missionItem.cameraOrientationFixed = _vehicleCameraList[listIndex].fixedOrientation
_noCameraValueRecalc = false
recalcFromCameraValues()
spacing: _margin
visible: cameraHeader.checked
QGCComboBox {
id: gridTypeCombo
anchors.left: parent.left
anchors.right: parent.right
model: _cameraList
currentIndex: -1
onActivated: {
if (index == _gridTypeManual) {
missionItem.manualGrid.value = true
} else if (index == _gridTypeCustomCamera) {
missionItem.manualGrid.value = false
missionItem.camera.value = gridTypeCombo.textAt(index)
missionItem.cameraOrientationFixed = false
} else {
missionItem.manualGrid.value = false
missionItem.camera.value = gridTypeCombo.textAt(index)
_noCameraValueRecalc = true
var listIndex = index - _gridTypeCamera
missionItem.cameraSensorWidth.rawValue = _vehicleCameraList[listIndex].sensorWidth
missionItem.cameraSensorHeight.rawValue = _vehicleCameraList[listIndex].sensorHeight
missionItem.cameraResolutionWidth.rawValue = _vehicleCameraList[listIndex].imageWidth
missionItem.cameraResolutionHeight.rawValue = _vehicleCameraList[listIndex].imageHeight
missionItem.cameraFocalLength.rawValue = _vehicleCameraList[listIndex].focalLength
missionItem.cameraOrientationLandscape.rawValue = _vehicleCameraList[listIndex].landscape ? 1 : 0
missionItem.cameraOrientationFixed = _vehicleCameraList[listIndex].fixedOrientation
_noCameraValueRecalc = false
recalcFromCameraValues()
}
}
}
RowLayout {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: missionItem.manualGrid.value == true
FactCheckBox {
anchors.baseline: cameraTriggerDistanceField.baseline
text: qsTr("Trigger Distance")
fact: missionItem.cameraTrigger
}
FactTextField {
id: cameraTriggerDistanceField
Layout.fillWidth: true
fact: missionItem.cameraTriggerDistance
enabled: missionItem.cameraTrigger.value
}
}
FactCheckBox {
text: qsTr("Hover and capture image")
fact: missionItem.hoverAndCapture
}
}
// Camera based grid ui
......@@ -343,7 +376,10 @@ Rectangle {
}
}
SectionHeader { text: qsTr("Grid") }
SectionHeader {
id: gridHeader
text: qsTr("Grid")
}
GridLayout {
anchors.left: parent.left
......@@ -351,6 +387,7 @@ Rectangle {
columnSpacing: _margin
rowSpacing: _margin
columns: 2
visible: gridHeader.checked
QGCLabel { text: qsTr("Angle") }
FactTextField {
......@@ -403,13 +440,17 @@ Rectangle {
}
// Manual grid ui
SectionHeader {
id: manualGridHeader
text: qsTr("Grid")
visible: gridTypeCombo.currentIndex == _gridTypeManual
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: gridTypeCombo.currentIndex == _gridTypeManual
SectionHeader { text: qsTr("Grid") }
visible: manualGridHeader.visible && manualGridHeader.checked
FactTextFieldGrid {
anchors.left: parent.left
......@@ -420,50 +461,21 @@ Rectangle {
factLabels: [ qsTr("Angle"), qsTr("Spacing"), qsTr("Altitude"), qsTr("Turnaround dist")]
}
Item { height: _margin; width: 1; visible: !ScreenTools.isTinyScreen }
FactCheckBox {
anchors.left: parent.left
text: qsTr("Relative altitude")
fact: missionItem.gridAltitudeRelative
}
Item { height: _sectionSpacer; width: 1; visible: !ScreenTools.isTinyScreen }
QGCLabel { text: qsTr("Camera") }
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
height: 1
color: qgcPal.text
}
RowLayout {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
FactCheckBox {
anchors.baseline: cameraTriggerDistanceField.baseline
text: qsTr("Trigger Distance")
fact: missionItem.cameraTrigger
}
FactTextField {
id: cameraTriggerDistanceField
Layout.fillWidth: true
fact: missionItem.cameraTriggerDistance
enabled: missionItem.cameraTrigger.value
}
}
}
SectionHeader { text: qsTr("Statistics") }
SectionHeader {
id: statsHeader
text: qsTr("Statistics") }
Grid {
columns: 2
columnSpacing: ScreenTools.defaultFontPixelWidth
visible: statsHeader.checked
QGCLabel { text: qsTr("Survey area") }
QGCLabel { text: QGroundControl.squareMetersToAppSettingsAreaUnits(missionItem.coveredArea).toFixed(2) + " " + QGroundControl.appSettingsAreaUnitsString }
......
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