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
cbfa7cc3
Commit
cbfa7cc3
authored
Nov 18, 2016
by
Don Gagne
Committed by
GitHub
Nov 18, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4220 from DonLakeFlyer/FenceFixes
Pile of GeoFence fixes
parents
3874b796
18ea73bd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
20 deletions
+57
-20
APMGeoFenceManager.cc
src/FirmwarePlugin/APM/APMGeoFenceManager.cc
+29
-12
APMGeoFenceManager.h
src/FirmwarePlugin/APM/APMGeoFenceManager.h
+2
-0
CopterGeoFenceEditor.qml
src/FirmwarePlugin/APM/CopterGeoFenceEditor.qml
+5
-3
FlightDisplayViewMap.qml
src/FlightDisplay/FlightDisplayViewMap.qml
+5
-3
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+3
-1
GeoFenceController.cc
src/MissionManager/GeoFenceController.cc
+8
-1
GeoFenceController.h
src/MissionManager/GeoFenceController.h
+3
-0
GeoFenceManager.h
src/MissionManager/GeoFenceManager.h
+2
-0
No files found.
src/FirmwarePlugin/APM/APMGeoFenceManager.cc
View file @
cbfa7cc3
...
...
@@ -14,9 +14,9 @@
#include "QGCApplication.h"
#include "ParameterManager.h"
const
char
*
APMGeoFenceManager
::
_fenceTotalParam
=
"FENCE_TOTAL"
;
const
char
*
APMGeoFenceManager
::
_fenceActionParam
=
"FENCE_ACTION"
;
const
char
*
APMGeoFenceManager
::
_fenceEnableParam
=
"FENCE_ENABLE"
;
const
char
*
APMGeoFenceManager
::
_fenceTotalParam
=
"FENCE_TOTAL"
;
const
char
*
APMGeoFenceManager
::
_fenceActionParam
=
"FENCE_ACTION"
;
const
char
*
APMGeoFenceManager
::
_fenceEnableParam
=
"FENCE_ENABLE"
;
APMGeoFenceManager
::
APMGeoFenceManager
(
Vehicle
*
vehicle
)
:
GeoFenceManager
(
vehicle
)
...
...
@@ -73,13 +73,6 @@ void APMGeoFenceManager::sendToVehicle(const QGeoCoordinate& breachReturn, const
_breachReturnPoint
=
breachReturn
;
_polygon
=
polygon
;
// First thing is to turn off geo fence while we are updating. This prevents the vehicle from going haywire it is in the air.
// Unfortunately the param to do this with differs between plane and copter.
const
char
*
enableParam
=
_vehicle
->
fixedWing
()
?
_fenceActionParam
:
_fenceEnableParam
;
Fact
*
fenceEnableFact
=
_vehicle
->
parameterManager
()
->
getParameter
(
FactSystem
::
defaultComponentId
,
enableParam
);
QVariant
savedEnableState
=
fenceEnableFact
->
rawValue
();
fenceEnableFact
->
setRawValue
(
0
);
// Total point count, +1 polygon close in last index, +1 for breach in index 0
_cWriteFencePoints
=
validatedPolygonCount
?
validatedPolygonCount
+
1
+
1
:
0
;
_vehicle
->
parameterManager
()
->
getParameter
(
FactSystem
::
defaultComponentId
,
_fenceTotalParam
)
->
setRawValue
(
_cWriteFencePoints
);
...
...
@@ -89,8 +82,6 @@ void APMGeoFenceManager::sendToVehicle(const QGeoCoordinate& breachReturn, const
_sendFencePoint
(
index
);
}
fenceEnableFact
->
setRawValue
(
savedEnableState
);
emit
loadComplete
(
_breachReturnPoint
,
_polygon
);
}
...
...
@@ -241,6 +232,28 @@ bool APMGeoFenceManager::_geoFenceSupported(void)
}
}
bool
APMGeoFenceManager
::
fenceEnabled
(
void
)
const
{
if
(
qgcApp
()
->
runningUnitTests
())
{
return
false
;
}
if
(
_vehicle
->
parameterManager
()
->
parameterExists
(
FactSystem
::
defaultComponentId
,
_fenceEnableParam
))
{
bool
fenceEnabled
=
_vehicle
->
parameterManager
()
->
getParameter
(
FactSystem
::
defaultComponentId
,
_fenceEnableParam
)
->
rawValue
().
toBool
();
qCDebug
(
GeoFenceManagerLog
)
<<
"FENCE_ENABLE available"
<<
fenceEnabled
;
return
fenceEnabled
;
}
qCDebug
(
GeoFenceManagerLog
)
<<
"FENCE_ENABLE not available"
;
return
true
;
}
void
APMGeoFenceManager
::
_fenceEnabledRawValueChanged
(
QVariant
value
)
{
qCDebug
(
GeoFenceManagerLog
)
<<
"FENCE_ENABLE changed"
<<
value
.
toBool
();
emit
fenceEnabledChanged
(
!
qgcApp
()
->
runningUnitTests
()
&&
value
.
toBool
());
}
void
APMGeoFenceManager
::
_updateSupportedFlags
(
void
)
{
bool
newCircleSupported
=
_fenceSupported
&&
_vehicle
->
multiRotor
()
&&
_fenceTypeFact
&&
(
_fenceTypeFact
->
rawValue
().
toInt
()
&
2
);
...
...
@@ -269,6 +282,10 @@ void APMGeoFenceManager::_parametersReady(void)
QStringList
paramNames
;
QStringList
paramLabels
;
if
(
_vehicle
->
parameterManager
()
->
parameterExists
(
FactSystem
::
defaultComponentId
,
_fenceEnableParam
))
{
connect
(
_vehicle
->
parameterManager
()
->
getParameter
(
FactSystem
::
defaultComponentId
,
_fenceEnableParam
),
&
Fact
::
rawValueChanged
,
this
,
&
APMGeoFenceManager
::
_fenceEnabledRawValueChanged
);
}
if
(
_vehicle
->
multiRotor
())
{
_fenceTypeFact
=
_vehicle
->
parameterManager
()
->
getParameter
(
FactSystem
::
defaultComponentId
,
QStringLiteral
(
"FENCE_TYPE"
));
...
...
src/FirmwarePlugin/APM/APMGeoFenceManager.h
View file @
cbfa7cc3
...
...
@@ -27,6 +27,7 @@ public:
void
loadFromVehicle
(
void
)
final
;
void
sendToVehicle
(
const
QGeoCoordinate
&
breachReturn
,
const
QList
<
QGeoCoordinate
>&
polygon
)
final
;
bool
fenceSupported
(
void
)
const
final
{
return
_fenceSupported
;
}
bool
fenceEnabled
(
void
)
const
final
;
bool
circleSupported
(
void
)
const
final
;
bool
polygonSupported
(
void
)
const
final
;
bool
breachReturnSupported
(
void
)
const
final
{
return
_breachReturnSupported
;
}
...
...
@@ -40,6 +41,7 @@ private slots:
void
_updateSupportedFlags
(
void
);
void
_circleRadiusRawValueChanged
(
QVariant
value
);
void
_parametersReady
(
void
);
void
_fenceEnabledRawValueChanged
(
QVariant
value
);
private:
void
_requestFencePoint
(
uint8_t
pointIndex
);
...
...
src/FirmwarePlugin/APM/CopterGeoFenceEditor.qml
View file @
cbfa7cc3
...
...
@@ -43,6 +43,8 @@ Column {
width
:
editorColumn
.
width
height
:
textField
.
height
property
bool
showCombo
:
modelData
.
enumStrings
.
length
>
0
QGCLabel
{
id
:
textFieldLabel
anchors.baseline
:
textField
.
baseline
...
...
@@ -55,7 +57,7 @@ Column {
width
:
_editFieldWidth
showUnits
:
true
fact
:
modelData
visible
:
!
comboField
.
visible
visible
:
!
parent
.
showCombo
}
FactComboBox
{
...
...
@@ -63,8 +65,8 @@ Column {
anchors.right
:
parent
.
right
width
:
_editFieldWidth
indexModel
:
false
fact
:
visible
?
modelData
:
_nullFact
visible
:
modelData
.
enumStrings
.
length
fact
:
showCombo
?
modelData
:
_nullFact
visible
:
parent
.
showCombo
property
var
_nullFact
:
Fact
{
}
}
...
...
src/FlightDisplay/FlightDisplayViewMap.qml
View file @
cbfa7cc3
...
...
@@ -110,7 +110,8 @@ FlightMap {
MapPolygon
{
border.color
:
"
#80FF0000
"
border.width
:
3
path
:
geoFenceController
.
polygonSupported
?
geoFenceController
.
polygon
.
path
:
undefined
path
:
geoFenceController
.
polygon
.
path
visible
:
geoFenceController
.
fenceEnabled
&&
geoFenceController
.
polygonSupported
}
// GeoFence circle
...
...
@@ -118,15 +119,16 @@ FlightMap {
border.color
:
"
#80FF0000
"
border.width
:
3
center
:
missionController
.
plannedHomePosition
radius
:
geoFenceController
.
circleSupported
?
geoFenceController
.
circleRadius
:
0
radius
:
(
geoFenceController
.
fenceEnabled
&&
geoFenceController
.
circleSupported
)
?
geoFenceController
.
circleRadius
:
0
z
:
QGroundControl
.
zOrderMapItems
visible
:
geoFenceController
.
fenceEnabled
&&
geoFenceController
.
circleSupported
}
// GeoFence breach return point
MapQuickItem
{
anchorPoint
:
Qt
.
point
(
sourceItem
.
width
/
2
,
sourceItem
.
height
/
2
)
coordinate
:
geoFenceController
.
breachReturnPoint
visible
:
geoFenceController
.
breachReturnSupported
visible
:
geoFenceController
.
fenceEnabled
&&
geoFenceController
.
breachReturnSupported
sourceItem
:
MissionItemIndexLabel
{
label
:
"
F
"
}
z
:
QGroundControl
.
zOrderMapItems
}
...
...
src/MissionEditor/MissionEditor.qml
View file @
cbfa7cc3
...
...
@@ -786,8 +786,9 @@ QGCView {
MapPolygon
{
border.color
:
"
#80FF0000
"
border.width
:
3
path
:
geoFenceController
.
polygon
Supported
?
geoFenceController
.
polygon
.
path
:
undefined
path
:
geoFenceController
.
polygon
.
path
z
:
QGroundControl
.
zOrderMapItems
visible
:
geoFenceController
.
polygonSupported
}
// GeoFence circle
...
...
@@ -797,6 +798,7 @@ QGCView {
center
:
missionController
.
plannedHomePosition
radius
:
geoFenceController
.
circleSupported
?
geoFenceController
.
circleRadius
:
0
z
:
QGroundControl
.
zOrderMapItems
visible
:
geoFenceController
.
circleSupported
}
// GeoFence breach return point
...
...
src/MissionManager/GeoFenceController.cc
View file @
cbfa7cc3
...
...
@@ -63,6 +63,7 @@ void GeoFenceController::setBreachReturnPoint(const QGeoCoordinate& breachReturn
void
GeoFenceController
::
_signalAll
(
void
)
{
emit
fenceSupportedChanged
(
fenceSupported
());
emit
fenceEnabledChanged
(
fenceEnabled
());
emit
circleSupportedChanged
(
circleSupported
());
emit
polygonSupportedChanged
(
polygonSupported
());
emit
breachReturnSupportedChanged
(
breachReturnSupported
());
...
...
@@ -82,9 +83,10 @@ void GeoFenceController::_activeVehicleBeingRemoved(void)
void
GeoFenceController
::
_activeVehicleSet
(
void
)
{
GeoFenceManager
*
geoFenceManager
=
_activeVehicle
->
geoFenceManager
();
connect
(
geoFenceManager
,
&
GeoFenceManager
::
fenceSupportedChanged
,
this
,
&
GeoFenceController
::
fenceSupportedChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
fenceEnabledChanged
,
this
,
&
GeoFenceController
::
fenceEnabledChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
circleSupportedChanged
,
this
,
&
GeoFenceController
::
_setDirty
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
polygonSupportedChanged
,
this
,
&
GeoFenceController
::
_setDirty
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
fenceSupportedChanged
,
this
,
&
GeoFenceController
::
fenceSupportedChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
circleSupportedChanged
,
this
,
&
GeoFenceController
::
circleSupportedChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
polygonSupportedChanged
,
this
,
&
GeoFenceController
::
polygonSupportedChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
breachReturnSupportedChanged
,
this
,
&
GeoFenceController
::
breachReturnSupportedChanged
);
...
...
@@ -375,6 +377,11 @@ bool GeoFenceController::fenceSupported(void) const
return
_activeVehicle
->
geoFenceManager
()
->
fenceSupported
();
}
bool
GeoFenceController
::
fenceEnabled
(
void
)
const
{
return
_activeVehicle
->
geoFenceManager
()
->
fenceEnabled
();
}
bool
GeoFenceController
::
circleSupported
(
void
)
const
{
return
_activeVehicle
->
geoFenceManager
()
->
circleSupported
();
...
...
src/MissionManager/GeoFenceController.h
View file @
cbfa7cc3
...
...
@@ -30,6 +30,7 @@ public:
~
GeoFenceController
();
Q_PROPERTY
(
bool
fenceSupported
READ
fenceSupported
NOTIFY
fenceSupportedChanged
)
Q_PROPERTY
(
bool
fenceEnabled
READ
fenceEnabled
NOTIFY
fenceEnabledChanged
)
Q_PROPERTY
(
bool
circleSupported
READ
circleSupported
NOTIFY
circleSupportedChanged
)
Q_PROPERTY
(
bool
polygonSupported
READ
polygonSupported
NOTIFY
polygonSupportedChanged
)
Q_PROPERTY
(
bool
breachReturnSupported
READ
breachReturnSupported
NOTIFY
breachReturnSupportedChanged
)
...
...
@@ -55,6 +56,7 @@ public:
QString
fileExtension
(
void
)
const
final
;
bool
fenceSupported
(
void
)
const
;
bool
fenceEnabled
(
void
)
const
;
bool
circleSupported
(
void
)
const
;
bool
polygonSupported
(
void
)
const
;
bool
breachReturnSupported
(
void
)
const
;
...
...
@@ -69,6 +71,7 @@ public:
signals:
void
fenceSupportedChanged
(
bool
fenceSupported
);
void
fenceEnabledChanged
(
bool
fenceEnabled
);
void
circleSupportedChanged
(
bool
circleSupported
);
void
polygonSupportedChanged
(
bool
polygonSupported
);
void
breachReturnSupportedChanged
(
bool
breachReturnSupported
);
...
...
src/MissionManager/GeoFenceManager.h
View file @
cbfa7cc3
...
...
@@ -40,6 +40,7 @@ public:
// Support flags
virtual
bool
fenceSupported
(
void
)
const
{
return
false
;
}
virtual
bool
fenceEnabled
(
void
)
const
{
return
false
;
}
virtual
bool
circleSupported
(
void
)
const
{
return
false
;
}
virtual
bool
polygonSupported
(
void
)
const
{
return
false
;
}
virtual
bool
breachReturnSupported
(
void
)
const
{
return
false
;
}
...
...
@@ -64,6 +65,7 @@ public:
signals:
void
loadComplete
(
const
QGeoCoordinate
&
breachReturn
,
const
QList
<
QGeoCoordinate
>&
polygon
);
void
fenceSupportedChanged
(
bool
fenceSupported
);
void
fenceEnabledChanged
(
bool
fenceEnabled
);
void
circleSupportedChanged
(
bool
circleSupported
);
void
polygonSupportedChanged
(
bool
polygonSupported
);
void
breachReturnSupportedChanged
(
bool
fenceSupported
);
...
...
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