Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
8484008f
Commit
8484008f
authored
Feb 27, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add camera trigger support
parent
0eb66765
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
9 deletions
+101
-9
SurveyItemEditor.qml
src/MissionEditor/SurveyItemEditor.qml
+30
-0
ComplexMissionItem.cc
src/MissionManager/ComplexMissionItem.cc
+60
-9
ComplexMissionItem.h
src/MissionManager/ComplexMissionItem.h
+11
-0
No files found.
src/MissionEditor/SurveyItemEditor.qml
View file @
8484008f
...
...
@@ -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
{
text
:
_addPointsMode
?
"
Finished
"
:
"
Draw Polygon
"
onClicked
:
{
...
...
src/MissionManager/ComplexMissionItem.cc
View file @
8484008f
...
...
@@ -34,6 +34,8 @@ const char* ComplexMissionItem::_jsonIdKey = "id";
const
char
*
ComplexMissionItem
::
_jsonGridAltitudeKey
=
"gridAltitude"
;
const
char
*
ComplexMissionItem
::
_jsonGridAngleKey
=
"gridAngle"
;
const
char
*
ComplexMissionItem
::
_jsonGridSpacingKey
=
"gridSpacing"
;
const
char
*
ComplexMissionItem
::
_jsonCameraTriggerKey
=
"cameraTrigger"
;
const
char
*
ComplexMissionItem
::
_jsonCameraTriggerDistanceKey
=
"cameraTriggerDistance"
;
const
char
*
ComplexMissionItem
::
_complexType
=
"survey"
;
...
...
@@ -41,23 +43,31 @@ ComplexMissionItem::ComplexMissionItem(Vehicle* vehicle, QObject* parent)
:
VisualMissionItem
(
vehicle
,
parent
)
,
_sequenceNumber
(
0
)
,
_dirty
(
false
)
,
_cameraTrigger
(
false
)
,
_gridAltitudeFact
(
0
,
"Altitude:"
,
FactMetaData
::
valueTypeDouble
)
,
_gridAngleFact
(
0
,
"Grid angle:"
,
FactMetaData
::
valueTypeDouble
)
,
_gridSpacingFact
(
0
,
"Grid spacing:"
,
FactMetaData
::
valueTypeDouble
)
,
_cameraTriggerDistanceFact
(
0
,
"Camera trigger distance"
,
FactMetaData
::
valueTypeDouble
)
{
_gridAltitudeFact
.
setRawValue
(
25
);
_gridSpacingFact
.
setRawValue
(
5
);
_gridSpacingFact
.
setRawValue
(
10
);
_cameraTriggerDistanceFact
.
setRawValue
(
25
);
connect
(
&
_gridSpacingFact
,
&
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
)
:
VisualMissionItem
(
other
,
parent
)
,
_sequenceNumber
(
other
.
sequenceNumber
())
,
_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
)
...
...
@@ -102,6 +112,11 @@ int ComplexMissionItem::lastSequenceNumber(void) const
if
(
_gridPoints
.
count
())
{
lastSeq
+=
_gridPoints
.
count
()
-
1
;
}
if
(
_cameraTrigger
)
{
// Account for two trigger messages
lastSeq
+=
2
;
}
return
lastSeq
;
}
...
...
@@ -130,6 +145,8 @@ void ComplexMissionItem::save(QJsonObject& saveObject) const
saveObject
[
_jsonGridAltitudeKey
]
=
_gridAltitudeFact
.
rawValue
().
toDouble
();
saveObject
[
_jsonGridAngleKey
]
=
_gridAngleFact
.
rawValue
().
toDouble
();
saveObject
[
_jsonGridSpacingKey
]
=
_gridSpacingFact
.
rawValue
().
toDouble
();
saveObject
[
_jsonCameraTriggerKey
]
=
_cameraTrigger
;
saveObject
[
_jsonCameraTriggerDistanceKey
]
=
_cameraTriggerDistanceFact
.
rawValue
().
toDouble
();
// Polygon shape
...
...
@@ -168,7 +185,8 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt
// Validate requires keys
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
))
{
_clear
();
return
false
;
...
...
@@ -177,8 +195,10 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt
// Validate types
QStringList
keyList
;
QList
<
QJsonValue
::
Type
>
typeList
;
keyList
<<
_jsonVersionKey
<<
_jsonTypeKey
<<
_jsonIdKey
<<
_jsonPolygonKey
<<
_jsonGridAltitudeKey
<<
_jsonGridAngleKey
<<
_jsonGridSpacingKey
;
typeList
<<
QJsonValue
::
Double
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
<<
QJsonValue
::
Array
<<
QJsonValue
::
Double
<<
QJsonValue
::
Double
<<
QJsonValue
::
Double
;
keyList
<<
_jsonVersionKey
<<
_jsonTypeKey
<<
_jsonIdKey
<<
_jsonPolygonKey
<<
_jsonGridAltitudeKey
<<
_jsonGridAngleKey
<<
_jsonGridSpacingKey
<<
_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
))
{
_clear
();
return
false
;
...
...
@@ -198,9 +218,11 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt
}
setSequenceNumber
(
complexObject
[
_jsonIdKey
].
toInt
());
_gridAltitudeFact
.
setRawValue
(
complexObject
[
_jsonGridAltitudeKey
].
toDouble
());
_gridAngleFact
.
setRawValue
(
complexObject
[
_jsonGridAngleKey
].
toDouble
());
_gridSpacingFact
.
setRawValue
(
complexObject
[
_jsonGridSpacingKey
].
toDouble
());
_cameraTrigger
=
complexObject
[
_jsonCameraTriggerKey
].
toBool
();
_gridAltitudeFact
.
setRawValue
(
complexObject
[
_jsonGridAltitudeKey
].
toDouble
());
_gridAngleFact
.
setRawValue
(
complexObject
[
_jsonGridAngleKey
].
toDouble
());
_gridSpacingFact
.
setRawValue
(
complexObject
[
_jsonGridSpacingKey
].
toDouble
());
_cameraTriggerDistanceFact
.
setRawValue
(
complexObject
[
_jsonCameraTriggerDistanceKey
].
toDouble
());
// Polygon shape
QJsonArray
polygonArray
(
complexObject
[
_jsonPolygonKey
].
toArray
());
...
...
@@ -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
;
...
...
@@ -464,7 +486,36 @@ QmlObjectListModel* ComplexMissionItem::getMissionItems(void) const
false
,
// isCurrentItem
pMissionItems
);
// parent - allow delete on pMissionItems to delete everthing
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
;
}
void
ComplexMissionItem
::
_signalLastSequenceNumberChanged
(
void
)
{
emit
lastSequenceNumberChanged
(
lastSequenceNumber
());
}
src/MissionManager/ComplexMissionItem.h
View file @
8484008f
...
...
@@ -39,6 +39,8 @@ public:
Q_PROPERTY
(
Fact
*
gridAltitude
READ
gridAltitude
CONSTANT
)
Q_PROPERTY
(
Fact
*
gridAngle
READ
gridAngle
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
(
int
lastSequenceNumber
READ
lastSequenceNumber
NOTIFY
lastSequenceNumberChanged
)
Q_PROPERTY
(
QVariantList
gridPoints
READ
gridPoints
NOTIFY
gridPointsChanged
)
...
...
@@ -52,6 +54,7 @@ public:
Fact
*
gridAltitude
(
void
)
{
return
&
_gridAltitudeFact
;
}
Fact
*
gridAngle
(
void
)
{
return
&
_gridAngleFact
;
}
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
int
lastSequenceNumber
(
void
)
const
;
...
...
@@ -93,6 +96,10 @@ signals:
void
altitudeChanged
(
double
altitude
);
void
gridAngleChanged
(
double
gridAngle
);
void
gridPointsChanged
(
void
);
void
cameraTriggerChanged
(
bool
cameraTrigger
);
private
slots
:
void
_signalLastSequenceNumberChanged
(
void
);
private:
void
_clear
(
void
);
...
...
@@ -112,10 +119,12 @@ private:
QGeoCoordinate
_exitCoordinate
;
double
_altitude
;
double
_gridAngle
;
bool
_cameraTrigger
;
Fact
_gridAltitudeFact
;
Fact
_gridAngleFact
;
Fact
_gridSpacingFact
;
Fact
_cameraTriggerDistanceFact
;
static
const
char
*
_jsonVersionKey
;
static
const
char
*
_jsonTypeKey
;
...
...
@@ -124,6 +133,8 @@ private:
static
const
char
*
_jsonGridAltitudeKey
;
static
const
char
*
_jsonGridAngleKey
;
static
const
char
*
_jsonGridSpacingKey
;
static
const
char
*
_jsonCameraTriggerKey
;
static
const
char
*
_jsonCameraTriggerDistanceKey
;
static
const
char
*
_complexType
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment