Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
587df7a2
Commit
587df7a2
authored
Jun 13, 2017
by
Beat Küng
Browse files
GeoFenceManager: upload AirMap polygons
This is just to test, will need much better integration
parent
ca2c3722
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/MissionManager/AirMapManager.h
View file @
587df7a2
...
...
@@ -40,6 +40,8 @@ public:
Q_PROPERTY
(
QVariantList
polygon
MEMBER
_polygon
CONSTANT
)
const
QVariantList
&
getPolygon
()
const
{
return
_polygon
;
}
private:
QVariantList
_polygon
;
};
...
...
src/MissionManager/GeoFenceManager.cc
View file @
587df7a2
...
...
@@ -11,6 +11,7 @@
#include
"Vehicle.h"
#include
"QmlObjectListModel.h"
#include
"ParameterManager.h"
#include
"QGCApplication.h"
#include
"QGCMapPolygon.h"
#include
"QGCMapCircle.h"
...
...
@@ -20,6 +21,7 @@ GeoFenceManager::GeoFenceManager(Vehicle* vehicle)
:
_vehicle
(
vehicle
)
,
_planManager
(
vehicle
,
MAV_MISSION_TYPE_FENCE
)
,
_firstParamLoadComplete
(
false
)
,
_airmapManager
(
qgcApp
()
->
toolbox
()
->
airMapManager
())
{
connect
(
&
_planManager
,
&
PlanManager
::
inProgressChanged
,
this
,
&
GeoFenceManager
::
inProgressChanged
);
connect
(
&
_planManager
,
&
PlanManager
::
error
,
this
,
&
GeoFenceManager
::
error
);
...
...
@@ -99,6 +101,31 @@ void GeoFenceManager::sendToVehicle(const QGeoCoordinate& breachReturn,
fenceItems
.
append
(
item
);
}
// send AirMap polygons
const
QmlObjectListModel
&
airmapPolygons
=
*
_airmapManager
->
polygonRestrictions
();
for
(
int
i
=
0
;
i
<
airmapPolygons
.
count
();
++
i
)
{
PolygonAirspaceRestriction
*
polygon
=
(
PolygonAirspaceRestriction
*
)
airmapPolygons
[
i
];
int
polygonCount
=
polygon
->
getPolygon
().
count
()
-
1
;
// last vertex is equal to the first
for
(
int
j
=
0
;
j
<
polygonCount
;
++
j
)
{
const
QGeoCoordinate
&
vertex
=
polygon
->
getPolygon
()[
j
].
value
<
QGeoCoordinate
>
();
MissionItem
*
item
=
new
MissionItem
(
0
,
MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION
,
MAV_FRAME_GLOBAL
,
polygonCount
,
// vertex count
0
,
0
,
0
,
// param 2-4 unused
vertex
.
latitude
(),
vertex
.
longitude
(),
0
,
// param 7 unused
false
,
// autocontinue
false
,
// isCurrentItem
this
);
// parent
fenceItems
.
append
(
item
);
}
}
// TODO: circles too
_planManager
.
writeMissionItems
(
fenceItems
);
for
(
int
i
=
0
;
i
<
fenceItems
.
count
();
i
++
)
{
...
...
src/MissionManager/GeoFenceManager.h
View file @
587df7a2
...
...
@@ -13,6 +13,7 @@
#include
<QObject>
#include
<QGeoCoordinate>
#include
"AirMapManager.h"
#include
"QGCLoggingCategory.h"
#include
"FactSystem.h"
#include
"PlanManager.h"
...
...
@@ -96,6 +97,7 @@ private:
bool
_firstParamLoadComplete
;
QList
<
QGCFencePolygon
>
_sendPolygons
;
QList
<
QGCFenceCircle
>
_sendCircles
;
AirMapManager
*
_airmapManager
;
};
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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