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
b6bee338
Commit
b6bee338
authored
May 21, 2019
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updateMission working + borderPoly added
parent
cc5ba699
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
140 additions
and
22 deletions
+140
-22
WimaArea.cc
src/Wima/WimaArea.cc
+21
-0
WimaArea.h
src/Wima/WimaArea.h
+3
-1
WimaController.cc
src/Wima/WimaController.cc
+51
-15
WimaController.h
src/Wima/WimaController.h
+4
-1
WimaGOperationArea.SettingsGroup.json
src/Wima/WimaGOperationArea.SettingsGroup.json
+9
-0
WimaGOperationArea.cc
src/Wima/WimaGOperationArea.cc
+17
-1
WimaGOperationArea.h
src/Wima/WimaGOperationArea.h
+15
-3
WimaGOperationAreaEditor.qml
src/WimaView/WimaGOperationAreaEditor.qml
+7
-1
WimaGOperationAreaMapVisual.qml
src/WimaView/WimaGOperationAreaMapVisual.qml
+11
-0
WimaView.qml
src/WimaView/WimaView.qml
+2
-0
No files found.
src/Wima/WimaArea.cc
View file @
b6bee338
...
...
@@ -92,4 +92,25 @@ QGeoCoordinate WimaArea::getClosestVertex(QGeoCoordinate coordinate)
return
this
->
vertexCoordinate
(
getClosestVertexIndex
(
coordinate
));
}
QGCMapPolygon
*
WimaArea
::
toQGCPolygon
(
WimaArea
*
poly
)
{
if
(
poly
!=
nullptr
)
{
QGCMapPolygon
*
qgcPoly
=
new
QGCMapPolygon
(
this
);
qgcPoly
->
setPath
(
poly
->
path
());
qgcPoly
->
setCenter
(
poly
->
center
());
qgcPoly
->
setCenterDrag
(
poly
->
centerDrag
());
qgcPoly
->
setInteractive
(
poly
->
interactive
());
return
qgcPoly
;
}
else
{
qWarning
(
"WimaArea::toQGCPolygon(): poly == nullptr"
);
return
nullptr
;
}
}
QGCMapPolygon
*
WimaArea
::
joinPolygons
(
QList
<
QGCMapPolygon
*>
polyList
)
{
}
src/Wima/WimaArea.h
View file @
b6bee338
...
...
@@ -39,7 +39,9 @@ public:
//iterates over all vertices in _polygon and returns the index of that one closest to coordinate
int
getClosestVertexIndex
(
QGeoCoordinate
coordinate
);
//iterates over all vertices in _polygon and returns that one closest to coordinate
QGeoCoordinate
getClosestVertex
(
QGeoCoordinate
coordinate
);
QGeoCoordinate
getClosestVertex
(
QGeoCoordinate
coordinate
);
QGCMapPolygon
*
toQGCPolygon
(
WimaArea
*
poly
);
QGCMapPolygon
*
joinPolygons
(
QList
<
QGCMapPolygon
*>
polyList
);
signals:
void
maxAltitudeChanged
(
void
);
...
...
src/Wima/WimaController.cc
View file @
b6bee338
...
...
@@ -90,7 +90,7 @@ bool WimaController::addVehicleCorridor(WimaGOperationArea *opArea, WimaServiceA
bool
newCorridorCreated
=
false
;
if
(
corridor
==
nullptr
){
corridor
=
new
WimaVCorridor
(
this
);
corridor
=
new
WimaVCorridor
(
opArea
);
newCorridorCreated
=
true
;
}
else
{
corridor
->
clear
();
...
...
@@ -175,15 +175,42 @@ bool WimaController::updateMission()
return
false
;
}
// create survey mission, will be extened with more mission types in the future
int
secNumber
=
_missionController
->
insertComplexMissionItem
(
_missionController
->
surveyComplexItemName
(),
new
QGeoCoordinate
(),
_missionController
->
visualItems
()
->
count
());
SurveyComplexItem
*
survey
=
qobject_cast
<
SurveyComplexItem
*>
(
_missionController
->
visualItems
()
->
get
(
secNumber
));
if
(
survey
!=
nullptr
)
{
survey
->
}
else
{
// reset visual items
_missionController
->
removeAll
();
QmlObjectListModel
*
missionItems
=
_missionController
->
visualItems
();
// set home position to serArea center
MissionSettingsItem
*
settingsItem
=
qobject_cast
<
MissionSettingsItem
*>
(
missionItems
->
get
(
0
));
if
(
settingsItem
==
nullptr
){
qWarning
(
"WimaController::updateMission(): settingsItem == nullptr"
);
return
false
;
}
settingsItem
->
setCoordinate
(
serArea
->
center
());
// set take off position item
_missionController
->
insertSimpleMissionItem
(
serArea
->
center
(),
1
);
// create survey item, will be extened with more mission types in the future
_missionController
->
insertComplexMissionItem
(
_missionController
->
surveyComplexItemName
(),
opArea
->
center
(),
2
);
SurveyComplexItem
*
survey
=
qobject_cast
<
SurveyComplexItem
*>
(
missionItems
->
get
(
missionItems
->
count
()
-
1
));
if
(
survey
==
nullptr
){
qWarning
(
"WimaController::updateMission(): survey == nullptr"
);
return
false
;
}
else
{
survey
->
surveyAreaPolygon
()
->
clear
();
survey
->
surveyAreaPolygon
()
->
appendVertices
(
opArea
->
coordinateList
());
}
// create land position item
_missionController
->
insertSimpleMissionItem
(
serArea
->
center
(),
3
);
SimpleMissionItem
*
landItem
=
qobject_cast
<
SimpleMissionItem
*>
(
missionItems
->
get
(
missionItems
->
count
()
-
1
));
if
(
landItem
==
nullptr
){
qWarning
(
"WimaController::updateMission(): landItem == nullptr"
);
return
false
;
}
else
{
Vehicle
*
controllerVehicle
=
_masterController
->
controllerVehicle
();
MAV_CMD
landCmd
=
controllerVehicle
->
vtol
()
?
MAV_CMD_NAV_VTOL_LAND
:
MAV_CMD_NAV_LAND
;
if
(
controllerVehicle
->
firmwarePlugin
()
->
supportedMissionCommands
().
contains
(
landCmd
))
{
landItem
->
setCommand
(
landCmd
);
}
}
return
true
;
}
void
WimaController
::
saveMission
()
...
...
@@ -213,19 +240,28 @@ void WimaController::recalcAll()
void
WimaController
::
recalcPolygonInteractivity
(
int
index
)
{
resetAllIsCurrentPolygon
();
WimaArea
*
interactivePoly
=
qobject_cast
<
WimaArea
*>
(
_visualItems
->
get
(
index
));
interactivePoly
->
setInteractive
(
true
);
if
(
index
>=
0
&&
index
<
_visualItems
->
count
())
{
resetAllInteractive
();
WimaArea
*
interactivePoly
=
qobject_cast
<
WimaArea
*>
(
_visualItems
->
get
(
index
));
interactivePoly
->
setInteractive
(
true
);
}
}
void
WimaController
::
resetAllI
sCurrentPolygon
()
void
WimaController
::
resetAllI
nteractive
()
{
int
itemCount
=
_visualItems
->
count
();
for
(
int
i
=
0
;
i
<
itemCount
;
i
++
)
{
WimaArea
*
iteratorPoly
=
qobject_cast
<
WimaArea
*>
(
_visualItems
->
get
(
i
));
iteratorPoly
->
setInteractive
(
false
);
if
(
itemCount
>
0
){
for
(
int
i
=
0
;
i
<
itemCount
;
i
++
)
{
WimaArea
*
iteratorPoly
=
qobject_cast
<
WimaArea
*>
(
_visualItems
->
get
(
i
));
iteratorPoly
->
setInteractive
(
false
);
}
}
}
void
WimaController
::
setInteractive
()
{
recalcPolygonInteractivity
(
_currentPolygonIndex
);
}
src/Wima/WimaController.h
View file @
b6bee338
...
...
@@ -12,6 +12,8 @@
#include "PlanMasterController.h"
#include "MissionController.h"
#include "SurveyComplexItem.h"
#include "SimpleMissionItem.h"
#include "MissionSettingsItem.h"
class
WimaController
:
public
QObject
...
...
@@ -60,7 +62,8 @@ public:
Q_INVOKABLE
void
saveMission
();
Q_INVOKABLE
void
loadMission
();
Q_INVOKABLE
void
resetAllIsCurrentPolygon
(
void
);
Q_INVOKABLE
void
resetAllInteractive
(
void
);
Q_INVOKABLE
void
setInteractive
(
void
);
...
...
src/Wima/WimaGOperationArea.SettingsGroup.json
View file @
b6bee338
...
...
@@ -23,5 +23,14 @@
"min"
:
0
,
"decimalPlaces"
:
2
,
"defaultValue"
:
10
},
{
"name"
:
"BorderPolygonOffset"
,
"shortDescription"
:
"The distance between the Operation Area and it's surounding Border Polygon."
,
"type"
:
"double"
,
"units"
:
"m"
,
"min"
:
0
,
"decimalPlaces"
:
1
,
"defaultValue"
:
5
}
]
src/Wima/WimaGOperationArea.cc
View file @
b6bee338
...
...
@@ -5,6 +5,7 @@ const char* WimaGOperationArea::settingsGroup = "OperatingArea
const
char
*
WimaGOperationArea
::
bottomLayerAltitudeName
=
"BottomLayerAltitude"
;
const
char
*
WimaGOperationArea
::
numberOfLayersName
=
"NumberOfLayers"
;
const
char
*
WimaGOperationArea
::
layerDistanceName
=
"LayerDistance"
;
const
char
*
WimaGOperationArea
::
borderPolygonOffsetName
=
"BorderPolygonOffset"
;
WimaGOperationArea
::
WimaGOperationArea
(
QObject
*
parent
)
:
WimaGOperationArea
(
nullptr
,
parent
)
...
...
@@ -18,10 +19,14 @@ WimaGOperationArea::WimaGOperationArea(WimaArea *other, QObject *parent)
,
_bottomLayerAltitude
(
settingsGroup
,
_metaDataMap
[
bottomLayerAltitudeName
])
,
_numberOfLayers
(
settingsGroup
,
_metaDataMap
[
numberOfLayersName
])
,
_layerDistance
(
settingsGroup
,
_metaDataMap
[
layerDistanceName
])
,
_borderPolygonOffset
(
settingsGroup
,
_metaDataMap
[
borderPolygonOffsetName
])
,
_polyline
(
new
WimaTrackerPolyline
(
this
))
,
_borderPolygon
(
new
QGCMapPolygon
(
this
))
{
this
->
setObjectName
(
"Operati
ng
Area"
);
this
->
setObjectName
(
"Operati
on
Area"
);
_polyline
.
bindPolygon
(
this
);
connect
(
this
,
&
WimaGOperationArea
::
pathChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
connect
(
&
_borderPolygonOffset
,
&
SettingsFact
::
rawValueChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
//qWarning("Here I am!");
//connect(&_polyline, &WimaTrackerPolyline::pathChanged, this, &WimaGOperationArea::polylineChanged );
}
...
...
@@ -57,6 +62,17 @@ void WimaGOperationArea::setVehicleCorridor(WimaVCorridor *corridor)
}
}
void
WimaGOperationArea
::
recalcBorderPolygon
()
{
//qWarning("WimaGOperationArea::recalcBorderPolygon() %f", _borderPolygonOffset.rawValue().toDouble());
QGCMapPolygon
*
polyCopy
=
this
->
toQGCPolygon
(
this
);
polyCopy
->
offset
(
_borderPolygonOffset
.
rawValue
().
toDouble
());
_borderPolygon
.
setPath
(
polyCopy
->
path
());
polyCopy
->
deleteLater
();
emit
borderPolygonChanged
();
}
/*void WimaGOperationArea::recalculatesubPolygons()
{
int vehicleCount = _vehicleList->count();
...
...
src/Wima/WimaGOperationArea.h
View file @
b6bee338
...
...
@@ -15,12 +15,14 @@ public:
WimaGOperationArea
(
QObject
*
parent
=
nullptr
);
WimaGOperationArea
(
WimaArea
*
other
,
QObject
*
parent
=
nullptr
);
Q_PROPERTY
(
Fact
*
bottomLayerAltitude
READ
bottomLayerAltitude
CONSTANT
)
Q_PROPERTY
(
Fact
*
numberOfLayers
READ
numberOfLayers
CONSTANT
)
Q_PROPERTY
(
Fact
*
layerDistance
READ
layerDistance
CONSTANT
)
Q_PROPERTY
(
Fact
*
bottomLayerAltitude
READ
bottomLayerAltitude
CONSTANT
)
Q_PROPERTY
(
Fact
*
numberOfLayers
READ
numberOfLayers
CONSTANT
)
Q_PROPERTY
(
Fact
*
layerDistance
READ
layerDistance
CONSTANT
)
Q_PROPERTY
(
Fact
*
borderPolygonOffset
READ
borderPolygonOffset
CONSTANT
)
/*Q_PROPERTY(QmlObjectListModel* vehicleList READ vehicleList NOTIFY vehicleListChanged)
Q_PROPERTY(QmlObjectListModel* vehiclePolygons READ vehiclePolygons NOTIFY vehiclePolygonsChanged)*/
Q_PROPERTY
(
WimaTrackerPolyline
*
polyline
READ
polyline
CONSTANT
)
Q_PROPERTY
(
QGCMapPolygon
*
borderPolygon
READ
borderPolygon
NOTIFY
borderPolygonChanged
)
Q_INVOKABLE
void
addVehicle
(
WimaVehicle
*
vehicle
);
...
...
@@ -41,16 +43,19 @@ public:
Fact
*
bottomLayerAltitude
(
void
)
{
return
&
_bottomLayerAltitude
;}
Fact
*
numberOfLayers
(
void
)
{
return
&
_numberOfLayers
;}
Fact
*
layerDistance
(
void
)
{
return
&
_layerDistance
;}
Fact
*
borderPolygonOffset
(
void
)
{
return
&
_borderPolygonOffset
;}
/*QmlObjectListModel* vehicleList (void) const { return _vehicleList;}
QmlObjectListModel* vehiclePolygons (void) const { return _vehiclePolygons;}*/
WimaTrackerPolyline
*
polyline
(
void
)
{
return
&
_polyline
;}
WimaVCorridor
*
vehicleCorridor
(
void
)
{
return
_vehicleCorridor
;}
QGCMapPolygon
*
borderPolygon
(
void
)
{
return
&
_borderPolygon
;}
static
const
char
*
settingsGroup
;
static
const
char
*
bottomLayerAltitudeName
;
static
const
char
*
numberOfLayersName
;
static
const
char
*
layerDistanceName
;
static
const
char
*
borderPolygonOffsetName
;
signals:
...
...
@@ -61,6 +66,11 @@ signals:
void
polylineChanged
(
void
);
//void vehiclePolygonsChanged (void);
void
vehicleCorridorChanged
(
WimaVCorridor
*
corridor
);
void
borderPolygonChanged
(
void
);
private
slots
:
void
recalcBorderPolygon
(
void
);
private:
QMap
<
QString
,
FactMetaData
*>
_metaDataMap
;
...
...
@@ -68,12 +78,14 @@ private:
SettingsFact
_bottomLayerAltitude
;
SettingsFact
_numberOfLayers
;
SettingsFact
_layerDistance
;
SettingsFact
_borderPolygonOffset
;
/*QmlObjectListModel* _vehicleList;
QmlObjectListModel* _vehiclePolygons;*/
WimaTrackerPolyline
_polyline
;
WimaVCorridor
*
_vehicleCorridor
;
QGCMapPolygon
_borderPolygon
;
...
...
src/WimaView/WimaGOperationAreaEditor.qml
View file @
b6bee338
...
...
@@ -85,7 +85,7 @@ Rectangle {
columns
:
2
QGCLabel
{
text
:
qsTr
(
"
Bottom Layer Alt
itude
"
)
text
:
qsTr
(
"
Bottom Layer Alt
.
"
)
}
FactTextField
{
fact
:
areaItem
.
bottomLayerAltitude
...
...
@@ -104,6 +104,12 @@ Rectangle {
Layout.fillWidth
:
true
}
QGCLabel
{
text
:
qsTr
(
"
Border Offset
"
)
}
FactTextField
{
fact
:
areaItem
.
borderPolygonOffset
Layout.fillWidth
:
true
}
}
...
...
src/WimaView/WimaGOperationAreaMapVisual.qml
View file @
b6bee338
...
...
@@ -28,6 +28,7 @@ Item {
property
var
areaItem
:
object
property
var
_polygon
:
areaItem
property
var
_polyline
:
areaItem
.
polyline
property
var
_borderPolygon
:
areaItem
.
borderPolygon
signal
clicked
(
int
sequenceNumber
)
...
...
@@ -89,6 +90,16 @@ Item {
interiorOpacity
:
0.25
}
WimaMapPolygonVisuals
{
qgcView
:
_root
.
qgcView
mapControl
:
map
mapPolygon
:
_borderPolygon
borderWidth
:
1
borderColor
:
"
white
"
interiorColor
:
"
transparent
"
interiorOpacity
:
1
}
WimaMapPolylineVisuals
{
qgcView
:
_root
.
qgcView
...
...
src/WimaView/WimaView.qml
View file @
b6bee338
...
...
@@ -756,9 +756,11 @@ QGCView {
switch
(
current
)
{
case
planElementMission
:
_editingLayer
=
_layerMission
_wimaController
.
resetAllInteractive
();
break
case
planElementWima
:
_editingLayer
=
_layerWima
_wimaController
.
setInteractive
();
break
}
}
...
...
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