Commit 8484008f authored by Don Gagne's avatar Don Gagne

Add camera trigger support

parent 0eb66765
...@@ -71,6 +71,36 @@ Rectangle { ...@@ -71,6 +71,36 @@ Rectangle {
} }
} }
QGCCheckBox {
id: cameraTrigger
anchors.left: parent.left
text: "Camera trigger:"
checked: missionItem.cameraTrigger
onClicked: missionItem.cameraTrigger = !missionItem.cameraTrigger
}
Item {
id: distanceItem
anchors.left: parent.left
anchors.right: parent.right
height: textField.height
enabled: cameraTrigger.checked
QGCLabel {
anchors.baseline: textField.baseline
anchors.left: parent.left
text: "Distance:"
}
FactTextField {
id: textField
anchors.right: parent.right
width: _editFieldWidth
showUnits: true
fact: missionItem.cameraTriggerDistance
}
}
QGCButton { QGCButton {
text: _addPointsMode ? "Finished" : "Draw Polygon" text: _addPointsMode ? "Finished" : "Draw Polygon"
onClicked: { onClicked: {
......
...@@ -34,6 +34,8 @@ const char* ComplexMissionItem::_jsonIdKey = "id"; ...@@ -34,6 +34,8 @@ const char* ComplexMissionItem::_jsonIdKey = "id";
const char* ComplexMissionItem::_jsonGridAltitudeKey = "gridAltitude"; const char* ComplexMissionItem::_jsonGridAltitudeKey = "gridAltitude";
const char* ComplexMissionItem::_jsonGridAngleKey = "gridAngle"; const char* ComplexMissionItem::_jsonGridAngleKey = "gridAngle";
const char* ComplexMissionItem::_jsonGridSpacingKey = "gridSpacing"; const char* ComplexMissionItem::_jsonGridSpacingKey = "gridSpacing";
const char* ComplexMissionItem::_jsonCameraTriggerKey = "cameraTrigger";
const char* ComplexMissionItem::_jsonCameraTriggerDistanceKey = "cameraTriggerDistance";
const char* ComplexMissionItem::_complexType = "survey"; const char* ComplexMissionItem::_complexType = "survey";
...@@ -41,23 +43,31 @@ ComplexMissionItem::ComplexMissionItem(Vehicle* vehicle, QObject* parent) ...@@ -41,23 +43,31 @@ ComplexMissionItem::ComplexMissionItem(Vehicle* vehicle, QObject* parent)
: VisualMissionItem(vehicle, parent) : VisualMissionItem(vehicle, parent)
, _sequenceNumber(0) , _sequenceNumber(0)
, _dirty(false) , _dirty(false)
, _cameraTrigger(false)
, _gridAltitudeFact (0, "Altitude:", FactMetaData::valueTypeDouble) , _gridAltitudeFact (0, "Altitude:", FactMetaData::valueTypeDouble)
, _gridAngleFact (0, "Grid angle:", FactMetaData::valueTypeDouble) , _gridAngleFact (0, "Grid angle:", FactMetaData::valueTypeDouble)
, _gridSpacingFact (0, "Grid spacing:", FactMetaData::valueTypeDouble) , _gridSpacingFact (0, "Grid spacing:", FactMetaData::valueTypeDouble)
, _cameraTriggerDistanceFact(0, "Camera trigger distance", FactMetaData::valueTypeDouble)
{ {
_gridAltitudeFact.setRawValue(25); _gridAltitudeFact.setRawValue(25);
_gridSpacingFact.setRawValue(5); _gridSpacingFact.setRawValue(10);
_cameraTriggerDistanceFact.setRawValue(25);
connect(&_gridSpacingFact, &Fact::valueChanged, this, &ComplexMissionItem::_generateGrid); connect(&_gridSpacingFact, &Fact::valueChanged, this, &ComplexMissionItem::_generateGrid);
connect(&_gridAngleFact, &Fact::valueChanged, this, &ComplexMissionItem::_generateGrid); connect(&_gridAngleFact, &Fact::valueChanged, this, &ComplexMissionItem::_generateGrid);
connect(this, &ComplexMissionItem::cameraTriggerChanged, this, &ComplexMissionItem::_signalLastSequenceNumberChanged);
} }
ComplexMissionItem::ComplexMissionItem(const ComplexMissionItem& other, QObject* parent) ComplexMissionItem::ComplexMissionItem(const ComplexMissionItem& other, QObject* parent)
: VisualMissionItem(other, parent) : VisualMissionItem(other, parent)
, _sequenceNumber(other.sequenceNumber()) , _sequenceNumber(other.sequenceNumber())
, _dirty(false) , _dirty(false)
, _cameraTrigger(other._cameraTrigger)
{ {
_gridAltitudeFact.setRawValue(other._gridAltitudeFact.rawValue());
_gridAngleFact.setRawValue(other._gridAngleFact.rawValue());
_gridSpacingFact.setRawValue(other._gridSpacingFact.rawValue());
_cameraTriggerDistanceFact.setRawValue(other._cameraTriggerDistanceFact.rawValue());
} }
void ComplexMissionItem::clearPolygon(void) void ComplexMissionItem::clearPolygon(void)
...@@ -102,6 +112,11 @@ int ComplexMissionItem::lastSequenceNumber(void) const ...@@ -102,6 +112,11 @@ int ComplexMissionItem::lastSequenceNumber(void) const
if (_gridPoints.count()) { if (_gridPoints.count()) {
lastSeq += _gridPoints.count() - 1; lastSeq += _gridPoints.count() - 1;
} }
if (_cameraTrigger) {
// Account for two trigger messages
lastSeq += 2;
}
return lastSeq; return lastSeq;
} }
...@@ -130,6 +145,8 @@ void ComplexMissionItem::save(QJsonObject& saveObject) const ...@@ -130,6 +145,8 @@ void ComplexMissionItem::save(QJsonObject& saveObject) const
saveObject[_jsonGridAltitudeKey] = _gridAltitudeFact.rawValue().toDouble(); saveObject[_jsonGridAltitudeKey] = _gridAltitudeFact.rawValue().toDouble();
saveObject[_jsonGridAngleKey] = _gridAngleFact.rawValue().toDouble(); saveObject[_jsonGridAngleKey] = _gridAngleFact.rawValue().toDouble();
saveObject[_jsonGridSpacingKey] = _gridSpacingFact.rawValue().toDouble(); saveObject[_jsonGridSpacingKey] = _gridSpacingFact.rawValue().toDouble();
saveObject[_jsonCameraTriggerKey] = _cameraTrigger;
saveObject[_jsonCameraTriggerDistanceKey] = _cameraTriggerDistanceFact.rawValue().toDouble();
// Polygon shape // Polygon shape
...@@ -168,7 +185,8 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt ...@@ -168,7 +185,8 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt
// Validate requires keys // Validate requires keys
QStringList requiredKeys; QStringList requiredKeys;
requiredKeys << _jsonVersionKey << _jsonTypeKey << _jsonIdKey << _jsonPolygonKey << _jsonGridAltitudeKey << _jsonGridAngleKey << _jsonGridSpacingKey; requiredKeys << _jsonVersionKey << _jsonTypeKey << _jsonIdKey << _jsonPolygonKey << _jsonGridAltitudeKey << _jsonGridAngleKey << _jsonGridSpacingKey <<
_jsonCameraTriggerKey << _jsonCameraTriggerDistanceKey;
if (!JsonHelper::validateRequiredKeys(complexObject, requiredKeys, errorString)) { if (!JsonHelper::validateRequiredKeys(complexObject, requiredKeys, errorString)) {
_clear(); _clear();
return false; return false;
...@@ -177,8 +195,10 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt ...@@ -177,8 +195,10 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt
// Validate types // Validate types
QStringList keyList; QStringList keyList;
QList<QJsonValue::Type> typeList; QList<QJsonValue::Type> typeList;
keyList << _jsonVersionKey << _jsonTypeKey << _jsonIdKey << _jsonPolygonKey << _jsonGridAltitudeKey << _jsonGridAngleKey << _jsonGridSpacingKey; keyList << _jsonVersionKey << _jsonTypeKey << _jsonIdKey << _jsonPolygonKey << _jsonGridAltitudeKey << _jsonGridAngleKey << _jsonGridSpacingKey <<
typeList << QJsonValue::Double << QJsonValue::String << QJsonValue::Double << QJsonValue::Array << QJsonValue::Double << QJsonValue::Double<< QJsonValue::Double; _jsonCameraTriggerKey << _jsonCameraTriggerDistanceKey;
typeList << QJsonValue::Double << QJsonValue::String << QJsonValue::Double << QJsonValue::Array << QJsonValue::Double << QJsonValue::Double<< QJsonValue::Double <<
QJsonValue::Bool << QJsonValue::Double;
if (!JsonHelper::validateKeyTypes(complexObject, keyList, typeList, errorString)) { if (!JsonHelper::validateKeyTypes(complexObject, keyList, typeList, errorString)) {
_clear(); _clear();
return false; return false;
...@@ -198,9 +218,11 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt ...@@ -198,9 +218,11 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt
} }
setSequenceNumber(complexObject[_jsonIdKey].toInt()); setSequenceNumber(complexObject[_jsonIdKey].toInt());
_gridAltitudeFact.setRawValue(complexObject[_jsonGridAltitudeKey].toDouble()); _cameraTrigger = complexObject[_jsonCameraTriggerKey].toBool();
_gridAngleFact.setRawValue(complexObject[_jsonGridAngleKey].toDouble()); _gridAltitudeFact.setRawValue (complexObject[_jsonGridAltitudeKey].toDouble());
_gridSpacingFact.setRawValue(complexObject[_jsonGridSpacingKey].toDouble()); _gridAngleFact.setRawValue (complexObject[_jsonGridAngleKey].toDouble());
_gridSpacingFact.setRawValue (complexObject[_jsonGridSpacingKey].toDouble());
_cameraTriggerDistanceFact.setRawValue(complexObject[_jsonCameraTriggerDistanceKey].toDouble());
// Polygon shape // Polygon shape
QJsonArray polygonArray(complexObject[_jsonPolygonKey].toArray()); QJsonArray polygonArray(complexObject[_jsonPolygonKey].toArray());
...@@ -444,7 +466,7 @@ void ComplexMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QL ...@@ -444,7 +466,7 @@ void ComplexMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QL
} }
} }
QmlObjectListModel* ComplexMissionItem::getMissionItems(void) const QmlObjectListModel* ComplexMissionItem::getMissionItems(void) const
{ {
QmlObjectListModel* pMissionItems = new QmlObjectListModel; QmlObjectListModel* pMissionItems = new QmlObjectListModel;
...@@ -464,7 +486,36 @@ QmlObjectListModel* ComplexMissionItem::getMissionItems(void) const ...@@ -464,7 +486,36 @@ QmlObjectListModel* ComplexMissionItem::getMissionItems(void) const
false, // isCurrentItem false, // isCurrentItem
pMissionItems); // parent - allow delete on pMissionItems to delete everthing pMissionItems); // parent - allow delete on pMissionItems to delete everthing
pMissionItems->append(item); pMissionItems->append(item);
if (_cameraTrigger && i == 0) {
MissionItem* item = new MissionItem(seqNum++, // sequence number
MAV_CMD_DO_SET_CAM_TRIGG_DIST, // MAV_CMD
MAV_FRAME_MISSION, // MAV_FRAME
_cameraTriggerDistanceFact.rawValue().toDouble(), // trigger distance
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, // param 2-7
true, // autoContinue
false, // isCurrentItem
pMissionItems); // parent - allow delete on pMissionItems to delete everthing
pMissionItems->append(item);
}
}
if (_cameraTrigger) {
MissionItem* item = new MissionItem(seqNum++, // sequence number
MAV_CMD_DO_SET_CAM_TRIGG_DIST, // MAV_CMD
MAV_FRAME_MISSION, // MAV_FRAME
0.0, // trigger distance
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, // param 2-7
true, // autoContinue
false, // isCurrentItem
pMissionItems); // parent - allow delete on pMissionItems to delete everthing
pMissionItems->append(item);
} }
return pMissionItems; return pMissionItems;
} }
void ComplexMissionItem::_signalLastSequenceNumberChanged(void)
{
emit lastSequenceNumberChanged(lastSequenceNumber());
}
...@@ -39,6 +39,8 @@ public: ...@@ -39,6 +39,8 @@ public:
Q_PROPERTY(Fact* gridAltitude READ gridAltitude CONSTANT) Q_PROPERTY(Fact* gridAltitude READ gridAltitude CONSTANT)
Q_PROPERTY(Fact* gridAngle READ gridAngle CONSTANT) Q_PROPERTY(Fact* gridAngle READ gridAngle CONSTANT)
Q_PROPERTY(Fact* gridSpacing READ gridSpacing CONSTANT) Q_PROPERTY(Fact* gridSpacing READ gridSpacing CONSTANT)
Q_PROPERTY(bool cameraTrigger MEMBER _cameraTrigger NOTIFY cameraTriggerChanged)
Q_PROPERTY(Fact* cameraTriggerDistance READ cameraTriggerDistance CONSTANT)
Q_PROPERTY(QVariantList polygonPath READ polygonPath NOTIFY polygonPathChanged) Q_PROPERTY(QVariantList polygonPath READ polygonPath NOTIFY polygonPathChanged)
Q_PROPERTY(int lastSequenceNumber READ lastSequenceNumber NOTIFY lastSequenceNumberChanged) Q_PROPERTY(int lastSequenceNumber READ lastSequenceNumber NOTIFY lastSequenceNumberChanged)
Q_PROPERTY(QVariantList gridPoints READ gridPoints NOTIFY gridPointsChanged) Q_PROPERTY(QVariantList gridPoints READ gridPoints NOTIFY gridPointsChanged)
...@@ -52,6 +54,7 @@ public: ...@@ -52,6 +54,7 @@ public:
Fact* gridAltitude(void) { return &_gridAltitudeFact; } Fact* gridAltitude(void) { return &_gridAltitudeFact; }
Fact* gridAngle(void) { return &_gridAngleFact; } Fact* gridAngle(void) { return &_gridAngleFact; }
Fact* gridSpacing(void) { return &_gridSpacingFact; } Fact* gridSpacing(void) { return &_gridSpacingFact; }
Fact* cameraTriggerDistance(void) { return &_cameraTriggerDistanceFact; }
/// @return The last sequence number used by this item. Takes into account child items of the complex item /// @return The last sequence number used by this item. Takes into account child items of the complex item
int lastSequenceNumber(void) const; int lastSequenceNumber(void) const;
...@@ -93,6 +96,10 @@ signals: ...@@ -93,6 +96,10 @@ signals:
void altitudeChanged(double altitude); void altitudeChanged(double altitude);
void gridAngleChanged(double gridAngle); void gridAngleChanged(double gridAngle);
void gridPointsChanged(void); void gridPointsChanged(void);
void cameraTriggerChanged(bool cameraTrigger);
private slots:
void _signalLastSequenceNumberChanged(void);
private: private:
void _clear(void); void _clear(void);
...@@ -112,10 +119,12 @@ private: ...@@ -112,10 +119,12 @@ private:
QGeoCoordinate _exitCoordinate; QGeoCoordinate _exitCoordinate;
double _altitude; double _altitude;
double _gridAngle; double _gridAngle;
bool _cameraTrigger;
Fact _gridAltitudeFact; Fact _gridAltitudeFact;
Fact _gridAngleFact; Fact _gridAngleFact;
Fact _gridSpacingFact; Fact _gridSpacingFact;
Fact _cameraTriggerDistanceFact;
static const char* _jsonVersionKey; static const char* _jsonVersionKey;
static const char* _jsonTypeKey; static const char* _jsonTypeKey;
...@@ -124,6 +133,8 @@ private: ...@@ -124,6 +133,8 @@ private:
static const char* _jsonGridAltitudeKey; static const char* _jsonGridAltitudeKey;
static const char* _jsonGridAngleKey; static const char* _jsonGridAngleKey;
static const char* _jsonGridSpacingKey; static const char* _jsonGridSpacingKey;
static const char* _jsonCameraTriggerKey;
static const char* _jsonCameraTriggerDistanceKey;
static const char* _complexType; static const char* _complexType;
}; };
......
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