Commit 9341d245 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5289 from DonLakeFlyer/TakePhotoPlus

Camera Section: Add support for Take Photo
parents 04a290e8 9e94dae6
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
"name": "CameraAction", "name": "CameraAction",
"shortDescription": "Specify whether the camera should take photos or video", "shortDescription": "Specify whether the camera should take photos or video",
"type": "uint32", "type": "uint32",
"enumStrings": "Continue current action,Take photos (time),Take photos (distance),Stop taking photos,Start recording video,Stop recording video", "enumStrings": "Continue current action,Take photo,Take photos (time),Take photos (distance),Stop taking photos,Start recording video,Stop recording video",
"enumValues": "0,1,2,3,4,5", "enumValues": "0,6,1,2,3,4,5",
"defaultValue": 0 "defaultValue": 0
}, },
{ {
......
...@@ -115,6 +115,19 @@ void CameraSection::appendSectionItems(QList<MissionItem*>& items, QObject* miss ...@@ -115,6 +115,19 @@ void CameraSection::appendSectionItems(QList<MissionItem*>& items, QObject* miss
{ {
// IMPORTANT NOTE: If anything changes here you must also change CameraSection::scanForSection // IMPORTANT NOTE: If anything changes here you must also change CameraSection::scanForSection
if (_specifyCameraMode) {
MissionItem* item = new MissionItem(nextSequenceNumber++,
MAV_CMD_SET_CAMERA_MODE,
MAV_FRAME_MISSION,
0, // camera id, all cameras
_cameraModeFact.rawValue().toDouble(),
NAN, NAN, NAN, NAN, NAN, // param 3-7 unused
true, // autoContinue
false, // isCurrentItem
missionItemParent);
items.append(item);
}
if (_specifyGimbal) { if (_specifyGimbal) {
MissionItem* item = new MissionItem(nextSequenceNumber++, MissionItem* item = new MissionItem(nextSequenceNumber++,
MAV_CMD_DO_MOUNT_CONTROL, MAV_CMD_DO_MOUNT_CONTROL,
...@@ -203,24 +216,26 @@ void CameraSection::appendSectionItems(QList<MissionItem*>& items, QObject* miss ...@@ -203,24 +216,26 @@ void CameraSection::appendSectionItems(QList<MissionItem*>& items, QObject* miss
false, // isCurrentItem false, // isCurrentItem
missionItemParent); missionItemParent);
break; break;
case TakePhoto:
item = new MissionItem(nextSequenceNumber++,
MAV_CMD_IMAGE_START_CAPTURE,
MAV_FRAME_MISSION,
0, // camera id = 0, all cameras
0, // Interval (none)
1, // Take 1 photo
-1, // Max horizontal resolution
-1, // Max vertical resolution
0, 0, // param 6-7 not used
true, // autoContinue
false, // isCurrentItem
missionItemParent);
break;
} }
if (item) { if (item) {
items.append(item); items.append(item);
} }
} }
if (_specifyCameraMode) {
MissionItem* item = new MissionItem(nextSequenceNumber++,
MAV_CMD_SET_CAMERA_MODE,
MAV_FRAME_MISSION,
0, // camera id, all cameras
_cameraModeFact.rawValue().toDouble(),
NAN, NAN, NAN, NAN, NAN, // param 3-7 unused
true, // autoContinue
false, // isCurrentItem
missionItemParent);
items.append(item);
}
} }
bool CameraSection::scanForSection(QmlObjectListModel* visualItems, int scanIndex) bool CameraSection::scanForSection(QmlObjectListModel* visualItems, int scanIndex)
...@@ -264,10 +279,19 @@ bool CameraSection::scanForSection(QmlObjectListModel* visualItems, int scanInde ...@@ -264,10 +279,19 @@ bool CameraSection::scanForSection(QmlObjectListModel* visualItems, int scanInde
break; break;
case MAV_CMD_IMAGE_START_CAPTURE: case MAV_CMD_IMAGE_START_CAPTURE:
if (!foundCameraAction && missionItem.param1() == 0 && missionItem.param2() >= 1 && missionItem.param3() == 0 && missionItem.param4() == -1 && missionItem.param5() == -1 && missionItem.param6() == 0 && missionItem.param7() == 0) { // This could possibly be TakePhotosIntervalTime or TakePhoto
if (!foundCameraAction &&
// TakePhotosIntervalTime matching
((missionItem.param1() == 0 && missionItem.param2() >= 1 && missionItem.param3() == 0 && missionItem.param4() == -1 && missionItem.param5() == -1 && missionItem.param6() == 0 && missionItem.param7() == 0) ||
// TakePhoto matching
(missionItem.param1() == 0 && missionItem.param2() == 0 && missionItem.param3() == 1 && missionItem.param4() == -1 && missionItem.param5() == -1 && missionItem.param6() == 0 && missionItem.param7() == 0))) {
foundCameraAction = true; foundCameraAction = true;
cameraAction()->setRawValue(TakePhotosIntervalTime); if (missionItem.param2() == 0) {
cameraPhotoIntervalTime()->setRawValue(missionItem.param2()); cameraAction()->setRawValue(TakePhoto);
} else {
cameraAction()->setRawValue(TakePhotosIntervalTime);
cameraPhotoIntervalTime()->setRawValue(missionItem.param2());
}
visualItems->removeAt(scanIndex)->deleteLater(); visualItems->removeAt(scanIndex)->deleteLater();
} else { } else {
stopLooking = true; stopLooking = true;
......
...@@ -21,17 +21,25 @@ class CameraSection : public Section ...@@ -21,17 +21,25 @@ class CameraSection : public Section
public: public:
CameraSection(Vehicle* vehicle, QObject* parent = NULL); CameraSection(Vehicle* vehicle, QObject* parent = NULL);
// These nume values must match the json meta data // These enum values must match the json meta data
enum CameraAction { enum CameraAction {
CameraActionNone, CameraActionNone,
TakePhotosIntervalTime, TakePhotosIntervalTime,
TakePhotoIntervalDistance, TakePhotoIntervalDistance,
StopTakingPhotos, StopTakingPhotos,
TakeVideo, TakeVideo,
StopTakingVideo StopTakingVideo,
}; TakePhoto
};
Q_ENUMS(CameraAction) Q_ENUMS(CameraAction)
enum CameraMode {
CameraModePhoto,
CameraModeVideo
};
Q_ENUMS(CameraMode)
Q_PROPERTY(bool specifyGimbal READ specifyGimbal WRITE setSpecifyGimbal NOTIFY specifyGimbalChanged) Q_PROPERTY(bool specifyGimbal READ specifyGimbal WRITE setSpecifyGimbal NOTIFY specifyGimbalChanged)
Q_PROPERTY(Fact* gimbalPitch READ gimbalPitch CONSTANT) Q_PROPERTY(Fact* gimbalPitch READ gimbalPitch CONSTANT)
Q_PROPERTY(Fact* gimbalYaw READ gimbalYaw CONSTANT) Q_PROPERTY(Fact* gimbalYaw READ gimbalYaw CONSTANT)
......
This diff is collapsed.
...@@ -36,6 +36,7 @@ private slots: ...@@ -36,6 +36,7 @@ private slots:
void _testScanForStopVideoSection(void); void _testScanForStopVideoSection(void);
void _testScanForStopImageSection(void); void _testScanForStopImageSection(void);
void _testScanForCameraModeSection(void); void _testScanForCameraModeSection(void);
void _testScanForTakePhotoSection(void);
void _testScanForFullSection(void); void _testScanForFullSection(void);
private: private:
...@@ -69,4 +70,5 @@ private: ...@@ -69,4 +70,5 @@ private:
SimpleMissionItem* _validStopTimeItem; SimpleMissionItem* _validStopTimeItem;
SimpleMissionItem* _validCameraPhotoModeItem; SimpleMissionItem* _validCameraPhotoModeItem;
SimpleMissionItem* _validCameraVideoModeItem; SimpleMissionItem* _validCameraVideoModeItem;
SimpleMissionItem* _validTakePhotoItem;
}; };
...@@ -108,9 +108,10 @@ SurveyMissionItem::SurveyMissionItem(Vehicle* vehicle, QObject* parent) ...@@ -108,9 +108,10 @@ SurveyMissionItem::SurveyMissionItem(Vehicle* vehicle, QObject* parent)
{ {
_editorQml = "qrc:/qml/SurveyItemEditor.qml"; _editorQml = "qrc:/qml/SurveyItemEditor.qml";
// If the user hasn't changed turnaround from the default (which is a fixed wing default) and we are multi-rotor set the multi-rotor default.
// NULL check since object creation during unit testing passes NULL for vehicle // NULL check since object creation during unit testing passes NULL for vehicle
if (_vehicle && _vehicle->multiRotor()) { if (_vehicle && _vehicle->multiRotor() && _turnaroundDistFact.rawValue().toDouble() == _turnaroundDistFact.rawDefaultValue().toDouble()) {
_turnaroundDistFact.setRawValue(0); _turnaroundDistFact.setRawValue(5);
} }
connect(&_gridSpacingFact, &Fact::valueChanged, this, &SurveyMissionItem::_generateGrid); connect(&_gridSpacingFact, &Fact::valueChanged, this, &SurveyMissionItem::_generateGrid);
......
...@@ -33,6 +33,8 @@ void SurveyMissionItemTest::init(void) ...@@ -33,6 +33,8 @@ void SurveyMissionItemTest::init(void)
_offlineVehicle = new Vehicle(MAV_AUTOPILOT_PX4, MAV_TYPE_QUADROTOR, qgcApp()->toolbox()->firmwarePluginManager(), this); _offlineVehicle = new Vehicle(MAV_AUTOPILOT_PX4, MAV_TYPE_QUADROTOR, qgcApp()->toolbox()->firmwarePluginManager(), this);
_surveyItem = new SurveyMissionItem(_offlineVehicle, this); _surveyItem = new SurveyMissionItem(_offlineVehicle, this);
_surveyItem->setTurnaroundDist(0); // Unit test written for no turnaround distance
_surveyItem->setDirty(false);
_mapPolygon = _surveyItem->mapPolygon(); _mapPolygon = _surveyItem->mapPolygon();
// It's important to check that the right signals are emitted at the right time since that drives ui change. // It's important to check that the right signals are emitted at the right time since that drives ui change.
......
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