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
0778e3ba
Commit
0778e3ba
authored
Feb 26, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add complex mission item exit coordinate support
Plus many load/save fixes
parent
2fcdda7f
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
193 additions
and
100 deletions
+193
-100
MissionItemIndicator.qml
src/FlightMap/MapItems/MissionItemIndicator.qml
+2
-2
MissionItemView.qml
src/FlightMap/MapItems/MissionItemView.qml
+1
-0
VibrationWidget.qml
src/FlightMap/Widgets/VibrationWidget.qml
+0
-2
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+43
-25
ComplexMissionItem.cc
src/MissionManager/ComplexMissionItem.cc
+37
-11
ComplexMissionItem.h
src/MissionManager/ComplexMissionItem.h
+8
-4
MissionController.cc
src/MissionManager/MissionController.cc
+94
-36
MissionController.h
src/MissionManager/MissionController.h
+2
-1
SimpleMissionItem.cc
src/MissionManager/SimpleMissionItem.cc
+3
-2
SimpleMissionItem.h
src/MissionManager/SimpleMissionItem.h
+1
-0
VisualMissionItem.cc
src/MissionManager/VisualMissionItem.cc
+0
-11
VisualMissionItem.h
src/MissionManager/VisualMissionItem.h
+2
-6
No files found.
src/FlightMap/MapItems/MissionItemIndicator.qml
View file @
0778e3ba
...
...
@@ -33,6 +33,7 @@ MapQuickItem {
id
:
_item
property
var
missionItem
property
int
sequenceNumber
signal
clicked
...
...
@@ -43,10 +44,9 @@ MapQuickItem {
MissionItemIndexLabel
{
id
:
_label
isCurrentItem
:
_isCurrentItem
label
:
_sequenceNumber
==
0
?
"
H
"
:
missionItem
.
sequenceNumber
label
:
sequenceNumber
==
0
?
"
H
"
:
sequenceNumber
onClicked
:
_item
.
clicked
()
property
bool
_isCurrentItem
:
missionItem
?
missionItem
.
isCurrentItem
:
false
property
bool
_sequenceNumber
:
missionItem
?
missionItem
.
sequenceNumber
:
0
}
}
src/FlightMap/MapItems/MissionItemView.qml
View file @
0778e3ba
...
...
@@ -41,6 +41,7 @@ MapItemView {
visible
:
object
.
specifiesCoordinate
&&
(
index
!=
0
||
object
.
showHomePosition
)
z
:
QGroundControl
.
zOrderMapItems
missionItem
:
object
sequenceNumber
:
object
.
sequenceNumber
// These are the non-coordinate child mission items attached to this item
Row
{
...
...
src/FlightMap/Widgets/VibrationWidget.qml
View file @
0778e3ba
...
...
@@ -134,8 +134,6 @@ QGCFlickable {
width
:
barRow
.
width
height
:
1
color
:
"
red
"
Component.onCompleted
:
console
.
log
(
anchors
.
topMargin
,
xBar
.
height
,
_barBadValue
,
_barMaximum
,
_barMinimum
)
}
QGCLabel
{
...
...
src/MissionEditor/MissionEditor.qml
View file @
0778e3ba
...
...
@@ -366,8 +366,42 @@ QGCView {
// Add the simple mission items to the map
MapItemView
{
model
:
controller
.
visualItems
delegate
:
missionItemComponent
model
:
controller
.
visualItems
delegate
:
missionItemComponent
}
// Add the complex mission items to the map
MapItemView
{
model
:
controller
.
complexVisualItems
delegate
:
polygonItemComponent
}
Component
{
id
:
polygonItemComponent
MapPolygon
{
color
:
'
green
'
path
:
object
.
polygonPath
opacity
:
0.5
}
}
// Add the complex mission item exit coordinates
MapItemView
{
model
:
controller
.
complexVisualItems
delegate
:
exitCoordinateComponent
}
Component
{
id
:
exitCoordinateComponent
MissionItemIndicator
{
coordinate
:
object
.
exitCoordinate
z
:
QGroundControl
.
zOrderMapItems
missionItem
:
object
sequenceNumber
:
object
.
lastSequenceNumber
visible
:
object
.
specifiesCoordinate
}
}
Component
{
...
...
@@ -379,18 +413,18 @@ QGCView {
visible
:
object
.
specifiesCoordinate
z
:
QGroundControl
.
zOrderMapItems
missionItem
:
object
sequenceNumber
:
object
.
sequenceNumber
onClicked
:
setCurrentItem
(
object
.
sequenceNumber
)
function
updateItemIndicator
()
{
if
(
object
.
isCurrentItem
&&
itemIndicator
.
visible
)
{
if
(
object
.
specifiesCoordinate
)
{
// Setup our drag item
itemDragger
.
visible
=
true
itemDragger
.
missionItem
=
Qt
.
binding
(
function
()
{
return
object
})
itemDragger
.
missionItemIndicator
=
Qt
.
binding
(
function
()
{
return
itemIndicator
})
}
if
(
object
.
isCurrentItem
&&
itemIndicator
.
visible
&&
object
.
specifiesCoordinate
&&
object
.
isSimpleItem
)
{
// Setup our drag item
itemDragger
.
visible
=
true
itemDragger
.
missionItem
=
Qt
.
binding
(
function
()
{
return
object
})
itemDragger
.
missionItemIndicator
=
Qt
.
binding
(
function
()
{
return
itemIndicator
})
}
}
...
...
@@ -421,22 +455,6 @@ QGCView {
}
}
// Add the complex mission items to the map
MapItemView
{
model
:
controller
.
complexVisualItems
delegate
:
polygonItemComponent
}
Component
{
id
:
polygonItemComponent
MapPolygon
{
color
:
'
green
'
path
:
object
.
polygonPath
opacity
:
0.5
}
}
// Add lines between waypoints
MissionLineView
{
model
:
controller
.
waypointLines
...
...
src/MissionManager/ComplexMissionItem.cc
View file @
0778e3ba
...
...
@@ -33,6 +33,7 @@ const char* ComplexMissionItem::_complexType = "survey";
ComplexMissionItem
::
ComplexMissionItem
(
Vehicle
*
vehicle
,
QObject
*
parent
)
:
VisualMissionItem
(
vehicle
,
parent
)
,
_sequenceNumber
(
0
)
,
_dirty
(
false
)
{
MissionItem
missionItem
;
...
...
@@ -44,6 +45,7 @@ ComplexMissionItem::ComplexMissionItem(Vehicle* vehicle, QObject* parent)
ComplexMissionItem
::
ComplexMissionItem
(
const
ComplexMissionItem
&
other
,
QObject
*
parent
)
:
VisualMissionItem
(
other
,
parent
)
,
_sequenceNumber
(
other
.
sequenceNumber
())
,
_dirty
(
false
)
{
...
...
@@ -51,8 +53,18 @@ ComplexMissionItem::ComplexMissionItem(const ComplexMissionItem& other, QObject*
void
ComplexMissionItem
::
clearPolygon
(
void
)
{
_polygonPath
.
clear
();
// Bug workaround, see below
while
(
_polygonPath
.
count
()
>
1
)
{
_polygonPath
.
takeLast
();
}
emit
polygonPathChanged
();
// Although this code should remove the polygon from the map it doesn't. There appears
// to be a bug in MapPolygon which causes it to not be redrawn if the list is empty. So
// we work around it by using the code above to remove all bu the last point which in turn
// will cause the polygon to go away.
_polygonPath
.
clear
();
emit
specifiesCoordinateChanged
();
}
void
ComplexMissionItem
::
addPolygonCoordinate
(
const
QGeoCoordinate
coordinate
)
...
...
@@ -60,15 +72,18 @@ void ComplexMissionItem::addPolygonCoordinate(const QGeoCoordinate coordinate)
_polygonPath
<<
QVariant
::
fromValue
(
coordinate
);
emit
polygonPathChanged
();
// FIXME: Hack, first polygon point sets entry coordinate
if
(
_polygonPath
.
count
()
==
1
)
{
int
pointCount
=
_polygonPath
.
count
();
if
(
pointCount
==
1
)
{
setCoordinate
(
coordinate
);
}
else
if
(
pointCount
==
3
)
{
emit
specifiesCoordinateChanged
();
}
_setExitCoordinate
(
coordinate
);
}
int
ComplexMissionItem
::
nex
tSequenceNumber
(
void
)
const
int
ComplexMissionItem
::
las
tSequenceNumber
(
void
)
const
{
return
_sequenceNumber
+
_missionItems
.
count
();
return
_sequenceNumber
+
_missionItems
.
count
()
-
1
;
}
void
ComplexMissionItem
::
setCoordinate
(
const
QGeoCoordinate
&
coordinate
)
...
...
@@ -126,11 +141,15 @@ void ComplexMissionItem::save(QJsonObject& saveObject) const
void
ComplexMissionItem
::
setSequenceNumber
(
int
sequenceNumber
)
{
VisualMissionItem
::
setSequenceNumber
(
sequenceNumber
);
if
(
_sequenceNumber
!=
sequenceNumber
)
{
_sequenceNumber
=
sequenceNumber
;
// Update internal mission items to new numbering
for
(
int
i
=
0
;
i
<
_missionItems
.
count
();
i
++
)
{
_missionItems
[
i
]
->
setSequenceNumber
(
sequenceNumber
++
);
// Update internal mission items to new numbering
for
(
int
i
=
0
;
i
<
_missionItems
.
count
();
i
++
)
{
_missionItems
[
i
]
->
setSequenceNumber
(
sequenceNumber
++
);
}
emit
sequenceNumberChanged
(
sequenceNumber
);
}
}
...
...
@@ -217,10 +236,12 @@ bool ComplexMissionItem::load(const QJsonObject& complexObject, QString& errorSt
int
itemCount
=
_missionItems
.
count
();
if
(
itemCount
>
0
)
{
setCoordinate
(
_missionItems
[
0
]
->
coordinate
()
);
_
setExitCoordinate
(
_missionItems
[
itemCount
-
1
]
->
coordinate
()
);
_coordinate
=
_missionItems
[
0
]
->
coordinate
(
);
_
exitCoordinate
=
_missionItems
[
itemCount
-
1
]
->
coordinate
(
);
}
qDebug
()
<<
coordinate
()
<<
exitCoordinate
()
<<
_missionItems
[
0
]
->
coordinate
()
<<
_missionItems
[
1
]
->
coordinate
();
return
true
;
}
...
...
@@ -236,3 +257,8 @@ void ComplexMissionItem::_setExitCoordinate(const QGeoCoordinate& coordinate)
}
}
}
bool
ComplexMissionItem
::
specifiesCoordinate
(
void
)
const
{
return
_polygonPath
.
count
()
>
2
;
}
src/MissionManager/ComplexMissionItem.h
View file @
0778e3ba
...
...
@@ -35,7 +35,8 @@ public:
ComplexMissionItem
(
Vehicle
*
vehicle
,
QObject
*
parent
=
NULL
);
ComplexMissionItem
(
const
ComplexMissionItem
&
other
,
QObject
*
parent
=
NULL
);
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_INVOKABLE
void
clearPolygon
(
void
);
Q_INVOKABLE
void
addPolygonCoordinate
(
const
QGeoCoordinate
coordinate
);
...
...
@@ -44,8 +45,8 @@ public:
QList
<
MissionItem
*>&
missionItems
(
void
)
{
return
_missionItems
;
}
/// @return The
next sequence number to use after
this item. Takes into account child items of the complex item
int
nex
tSequenceNumber
(
void
)
const
;
/// @return The
last sequence number used by
this item. Takes into account child items of the complex item
int
las
tSequenceNumber
(
void
)
const
;
/// Load the complex mission item from Json
/// @param complexObject Complex mission item json object
...
...
@@ -58,11 +59,12 @@ public:
bool
dirty
(
void
)
const
final
{
return
_dirty
;
}
bool
isSimpleItem
(
void
)
const
final
{
return
false
;
}
bool
isStandaloneCoordinate
(
void
)
const
final
{
return
false
;
}
bool
specifiesCoordinate
(
void
)
const
final
{
return
true
;
}
bool
specifiesCoordinate
(
void
)
const
final
;
QString
commandDescription
(
void
)
const
final
{
return
"Survey"
;
}
QString
commandName
(
void
)
const
final
{
return
"Survey"
;
}
QGeoCoordinate
coordinate
(
void
)
const
final
{
return
_coordinate
;
}
QGeoCoordinate
exitCoordinate
(
void
)
const
final
{
return
_exitCoordinate
;
}
int
sequenceNumber
(
void
)
const
final
{
return
_sequenceNumber
;
}
bool
coordinateHasRelativeAltitude
(
void
)
const
final
{
return
true
;
}
bool
exitCoordinateHasRelativeAltitude
(
void
)
const
final
{
return
true
;
}
...
...
@@ -75,11 +77,13 @@ public:
signals:
void
polygonPathChanged
(
void
);
void
lastSequenceNumberChanged
(
int
lastSequenceNumber
);
private:
void
_clear
(
void
);
void
_setExitCoordinate
(
const
QGeoCoordinate
&
coordinate
);
int
_sequenceNumber
;
bool
_dirty
;
QVariantList
_polygonPath
;
QList
<
MissionItem
*>
_missionItems
;
...
...
src/MissionManager/MissionController.cc
View file @
0778e3ba
This diff is collapsed.
Click to expand it.
src/MissionManager/MissionController.h
View file @
0778e3ba
...
...
@@ -113,10 +113,11 @@ private:
void
_addPlannedHomePosition
(
QmlObjectListModel
*
visualItems
,
bool
addToCenter
);
double
_normalizeLat
(
double
lat
);
double
_normalizeLon
(
double
lon
);
bool
_loadJsonMissionFile
(
const
QByteArray
&
bytes
,
QmlObjectListModel
*
visualItems
,
QString
&
errorString
);
bool
_loadJsonMissionFile
(
const
QByteArray
&
bytes
,
QmlObjectListModel
*
visualItems
,
Q
mlObjectListModel
*
complexItems
,
Q
String
&
errorString
);
bool
_loadTextMissionFile
(
QTextStream
&
stream
,
QmlObjectListModel
*
visualItems
,
QString
&
errorString
);
void
_loadMissionFromFile
(
const
QString
&
file
);
void
_saveMissionToFile
(
const
QString
&
file
);
int
_nextSequenceNumber
(
void
);
private:
bool
_editMode
;
...
...
src/MissionManager/SimpleMissionItem.cc
View file @
0778e3ba
...
...
@@ -190,6 +190,9 @@ void SimpleMissionItem::_connectSignals(void)
// These fact signals must alway signal out through SimpleMissionItem signals
connect
(
&
_missionItem
.
_commandFact
,
&
Fact
::
valueChanged
,
this
,
&
SimpleMissionItem
::
_sendCommandChanged
);
connect
(
&
_missionItem
.
_frameFact
,
&
Fact
::
valueChanged
,
this
,
&
SimpleMissionItem
::
_sendFrameChanged
);
// Sequence number is kept in mission iteem, so we need to propogate signal up as well
connect
(
&
_missionItem
,
&
MissionItem
::
sequenceNumberChanged
,
this
,
&
SimpleMissionItem
::
sequenceNumberChanged
);
}
void
SimpleMissionItem
::
_setupMetaData
(
void
)
...
...
@@ -574,7 +577,6 @@ void SimpleMissionItem::setCommand(MavlinkQmlSingleton::Qml_MAV_CMD command)
void
SimpleMissionItem
::
setCoordinate
(
const
QGeoCoordinate
&
coordinate
)
{
if
(
_missionItem
.
coordinate
()
!=
coordinate
)
{
qDebug
()
<<
_missionItem
.
coordinate
()
<<
coordinate
;
_missionItem
.
setCoordinate
(
coordinate
);
}
}
...
...
@@ -582,5 +584,4 @@ void SimpleMissionItem::setCoordinate(const QGeoCoordinate& coordinate)
void
SimpleMissionItem
::
setSequenceNumber
(
int
sequenceNumber
)
{
_missionItem
.
setSequenceNumber
(
sequenceNumber
);
VisualMissionItem
::
setSequenceNumber
(
sequenceNumber
);
}
src/MissionManager/SimpleMissionItem.h
View file @
0778e3ba
...
...
@@ -101,6 +101,7 @@ public:
QString
commandName
(
void
)
const
final
;
QGeoCoordinate
coordinate
(
void
)
const
final
{
return
_missionItem
.
coordinate
();
}
QGeoCoordinate
exitCoordinate
(
void
)
const
final
{
return
coordinate
();
}
int
sequenceNumber
(
void
)
const
final
{
return
_missionItem
.
sequenceNumber
();
}
bool
coordinateHasRelativeAltitude
(
void
)
const
final
{
return
_missionItem
.
relativeAltitude
();
}
bool
exitCoordinateHasRelativeAltitude
(
void
)
const
final
{
return
coordinateHasRelativeAltitude
();
}
...
...
src/MissionManager/VisualMissionItem.cc
View file @
0778e3ba
...
...
@@ -31,7 +31,6 @@ This file is part of the QGROUNDCONTROL project
VisualMissionItem
::
VisualMissionItem
(
Vehicle
*
vehicle
,
QObject
*
parent
)
:
QObject
(
parent
)
,
_vehicle
(
vehicle
)
,
_sequenceNumber
(
0
)
,
_isCurrentItem
(
false
)
,
_dirty
(
false
)
,
_altDifference
(
0.0
)
...
...
@@ -45,7 +44,6 @@ VisualMissionItem::VisualMissionItem(Vehicle* vehicle, QObject* parent)
VisualMissionItem
::
VisualMissionItem
(
const
VisualMissionItem
&
other
,
QObject
*
parent
)
:
QObject
(
parent
)
,
_vehicle
(
NULL
)
,
_sequenceNumber
(
0
)
,
_isCurrentItem
(
false
)
,
_dirty
(
false
)
,
_altDifference
(
0.0
)
...
...
@@ -60,7 +58,6 @@ const VisualMissionItem& VisualMissionItem::operator=(const VisualMissionItem& o
{
_vehicle
=
other
.
_vehicle
;
setSequenceNumber
(
other
.
_sequenceNumber
);
setIsCurrentItem
(
other
.
_isCurrentItem
);
setDirty
(
other
.
_dirty
);
setAltDifference
(
other
.
_altDifference
);
...
...
@@ -106,11 +103,3 @@ void VisualMissionItem::setAzimuth(double azimuth)
_azimuth
=
azimuth
;
emit
azimuthChanged
(
_azimuth
);
}
void
VisualMissionItem
::
setSequenceNumber
(
int
sequenceNumber
)
{
if
(
_sequenceNumber
!=
sequenceNumber
)
{
_sequenceNumber
=
sequenceNumber
;
emit
sequenceNumberChanged
(
_sequenceNumber
);
}
}
src/MissionManager/VisualMissionItem.h
View file @
0778e3ba
...
...
@@ -99,7 +99,6 @@ public:
double
azimuth
(
void
)
const
{
return
_azimuth
;
}
double
distance
(
void
)
const
{
return
_distance
;
}
bool
isCurrentItem
(
void
)
const
{
return
_isCurrentItem
;
}
int
sequenceNumber
(
void
)
const
{
return
_sequenceNumber
;
}
QmlObjectListModel
*
childItems
(
void
)
{
return
&
_childItems
;
}
...
...
@@ -111,10 +110,6 @@ public:
Vehicle
*
vehicle
(
void
)
{
return
_vehicle
;
}
// Virtuals which may be overriden by derived classes
virtual
void
setSequenceNumber
(
int
sequenceNumber
);
// Pure virtuals which must be provides by derived classes
virtual
bool
dirty
(
void
)
const
=
0
;
...
...
@@ -125,6 +120,7 @@ public:
virtual
QString
commandName
(
void
)
const
=
0
;
virtual
QGeoCoordinate
coordinate
(
void
)
const
=
0
;
virtual
QGeoCoordinate
exitCoordinate
(
void
)
const
=
0
;
virtual
int
sequenceNumber
(
void
)
const
=
0
;
virtual
bool
coordinateHasRelativeAltitude
(
void
)
const
=
0
;
virtual
bool
exitCoordinateHasRelativeAltitude
(
void
)
const
=
0
;
...
...
@@ -132,6 +128,7 @@ public:
virtual
void
setDirty
(
bool
dirty
)
=
0
;
virtual
void
setCoordinate
(
const
QGeoCoordinate
&
coordinate
)
=
0
;
virtual
void
setSequenceNumber
(
int
sequenceNumber
)
=
0
;
/// Save the item(s) in Json format
/// @param saveObject Save the item to this json object
...
...
@@ -159,7 +156,6 @@ signals:
protected:
Vehicle
*
_vehicle
;
int
_sequenceNumber
;
bool
_isCurrentItem
;
bool
_dirty
;
double
_altDifference
;
///< Difference in altitude from previous waypoint
...
...
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