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
9624d5c5
Commit
9624d5c5
authored
Sep 02, 2016
by
Don Gagne
Committed by
GitHub
Sep 02, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4009 from DonLakeFlyer/PX4FencePlugin
PX4 fence plugin
parents
625cb132
c9dab611
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
237 additions
and
96 deletions
+237
-96
qgroundcontrol.pro
qgroundcontrol.pro
+2
-0
SafetyComponent.qml
src/AutoPilotPlugins/PX4/SafetyComponent.qml
+4
-4
PX4FirmwarePlugin.h
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h
+27
-25
PX4GeoFenceManager.cc
src/FirmwarePlugin/PX4/PX4GeoFenceManager.cc
+85
-0
PX4GeoFenceManager.h
src/FirmwarePlugin/PX4/PX4GeoFenceManager.h
+45
-0
GeoFenceEditor.qml
src/MissionEditor/GeoFenceEditor.qml
+1
-1
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+64
-61
GeoFenceController.cc
src/MissionManager/GeoFenceController.cc
+4
-2
QGCRadioButton.qml
src/QmlControls/QGCRadioButton.qml
+4
-2
LinkManager.cc
src/comm/LinkManager.cc
+1
-1
No files found.
qgroundcontrol.pro
View file @
9624d5c5
...
@@ -700,6 +700,7 @@ HEADERS+= \
...
@@ -700,6 +700,7 @@ HEADERS+= \
src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h \
src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h \
src/FirmwarePlugin/PX4/px4_custom_mode.h \
src/FirmwarePlugin/PX4/px4_custom_mode.h \
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h \
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h \
src/FirmwarePlugin/PX4/PX4GeoFenceManager.h \
src/FirmwarePlugin/PX4/PX4ParameterMetaData.h \
src/FirmwarePlugin/PX4/PX4ParameterMetaData.h \
src/Vehicle/MultiVehicleManager.h \
src/Vehicle/MultiVehicleManager.h \
src/Vehicle/Vehicle.h \
src/Vehicle/Vehicle.h \
...
@@ -761,6 +762,7 @@ SOURCES += \
...
@@ -761,6 +762,7 @@ SOURCES += \
src/FirmwarePlugin/FirmwarePlugin.cc \
src/FirmwarePlugin/FirmwarePlugin.cc \
src/FirmwarePlugin/FirmwarePluginManager.cc \
src/FirmwarePlugin/FirmwarePluginManager.cc \
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc \
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc \
src/FirmwarePlugin/PX4/PX4GeoFenceManager.cc \
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc \
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc \
src/Vehicle/MultiVehicleManager.cc \
src/Vehicle/MultiVehicleManager.cc \
src/Vehicle/Vehicle.cc \
src/Vehicle/Vehicle.cc \
...
...
src/AutoPilotPlugins/PX4/SafetyComponent.qml
View file @
9624d5c5
...
@@ -313,8 +313,8 @@ SetupPage {
...
@@ -313,8 +313,8 @@ SetupPage {
id
:
fenceRadiusCheckBox
id
:
fenceRadiusCheckBox
anchors.baseline
:
fenceRadiusField
.
baseline
anchors.baseline
:
fenceRadiusField
.
baseline
text
:
qsTr
(
"
Max radius:
"
)
text
:
qsTr
(
"
Max radius:
"
)
checked
:
_fenceRadius
.
value
>
=
0
checked
:
_fenceRadius
.
value
>
0
onClicked
:
_fenceRadius
.
value
=
checked
?
100
:
-
1
onClicked
:
_fenceRadius
.
value
=
checked
?
100
:
0
width
:
_middleRowWidth
width
:
_middleRowWidth
}
}
FactTextField
{
FactTextField
{
...
@@ -330,8 +330,8 @@ SetupPage {
...
@@ -330,8 +330,8 @@ SetupPage {
id
:
fenceAltMaxCheckBox
id
:
fenceAltMaxCheckBox
anchors.baseline
:
fenceAltMaxField
.
baseline
anchors.baseline
:
fenceAltMaxField
.
baseline
text
:
qsTr
(
"
Max altitude:
"
)
text
:
qsTr
(
"
Max altitude:
"
)
checked
:
_fenceAlt
.
value
>
=
0
checked
:
_fenceAlt
.
value
>
0
onClicked
:
_fenceAlt
.
value
=
checked
?
100
:
-
1
onClicked
:
_fenceAlt
.
value
=
checked
?
100
:
0
width
:
_middleRowWidth
width
:
_middleRowWidth
}
}
FactTextField
{
FactTextField
{
...
...
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h
View file @
9624d5c5
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "FirmwarePlugin.h"
#include "FirmwarePlugin.h"
#include "ParameterLoader.h"
#include "ParameterLoader.h"
#include "PX4ParameterMetaData.h"
#include "PX4ParameterMetaData.h"
#include "PX4GeoFenceManager.h"
class
PX4FirmwarePlugin
:
public
FirmwarePlugin
class
PX4FirmwarePlugin
:
public
FirmwarePlugin
{
{
...
@@ -30,31 +31,32 @@ public:
...
@@ -30,31 +31,32 @@ public:
QList
<
VehicleComponent
*>
componentsForVehicle
(
AutoPilotPlugin
*
vehicle
)
final
;
QList
<
VehicleComponent
*>
componentsForVehicle
(
AutoPilotPlugin
*
vehicle
)
final
;
QList
<
MAV_CMD
>
supportedMissionCommands
(
void
)
final
;
QList
<
MAV_CMD
>
supportedMissionCommands
(
void
)
final
;
bool
isCapable
(
const
Vehicle
*
vehicle
,
FirmwareCapabilities
capabilities
)
final
;
bool
isCapable
(
const
Vehicle
*
vehicle
,
FirmwareCapabilities
capabilities
)
final
;
QStringList
flightModes
(
Vehicle
*
vehicle
)
final
;
QStringList
flightModes
(
Vehicle
*
vehicle
)
final
;
QString
flightMode
(
uint8_t
base_mode
,
uint32_t
custom_mode
)
const
final
;
QString
flightMode
(
uint8_t
base_mode
,
uint32_t
custom_mode
)
const
final
;
bool
setFlightMode
(
const
QString
&
flightMode
,
uint8_t
*
base_mode
,
uint32_t
*
custom_mode
)
final
;
bool
setFlightMode
(
const
QString
&
flightMode
,
uint8_t
*
base_mode
,
uint32_t
*
custom_mode
)
final
;
void
setGuidedMode
(
Vehicle
*
vehicle
,
bool
guidedMode
)
final
;
void
setGuidedMode
(
Vehicle
*
vehicle
,
bool
guidedMode
)
final
;
void
pauseVehicle
(
Vehicle
*
vehicle
)
final
;
void
pauseVehicle
(
Vehicle
*
vehicle
)
final
;
void
guidedModeRTL
(
Vehicle
*
vehicle
)
final
;
void
guidedModeRTL
(
Vehicle
*
vehicle
)
final
;
void
guidedModeLand
(
Vehicle
*
vehicle
)
final
;
void
guidedModeLand
(
Vehicle
*
vehicle
)
final
;
void
guidedModeTakeoff
(
Vehicle
*
vehicle
,
double
altitudeRel
)
final
;
void
guidedModeTakeoff
(
Vehicle
*
vehicle
,
double
altitudeRel
)
final
;
void
guidedModeOrbit
(
Vehicle
*
vehicle
,
const
QGeoCoordinate
&
centerCoord
=
QGeoCoordinate
(),
double
radius
=
NAN
,
double
velocity
=
NAN
,
double
altitude
=
NAN
)
final
;
void
guidedModeOrbit
(
Vehicle
*
vehicle
,
const
QGeoCoordinate
&
centerCoord
=
QGeoCoordinate
(),
double
radius
=
NAN
,
double
velocity
=
NAN
,
double
altitude
=
NAN
)
final
;
void
guidedModeGotoLocation
(
Vehicle
*
vehicle
,
const
QGeoCoordinate
&
gotoCoord
)
final
;
void
guidedModeGotoLocation
(
Vehicle
*
vehicle
,
const
QGeoCoordinate
&
gotoCoord
)
final
;
void
guidedModeChangeAltitude
(
Vehicle
*
vehicle
,
double
altitudeRel
)
final
;
void
guidedModeChangeAltitude
(
Vehicle
*
vehicle
,
double
altitudeRel
)
final
;
bool
isGuidedMode
(
const
Vehicle
*
vehicle
)
const
;
bool
isGuidedMode
(
const
Vehicle
*
vehicle
)
const
;
int
manualControlReservedButtonCount
(
void
)
final
;
int
manualControlReservedButtonCount
(
void
)
final
;
bool
supportsManualControl
(
void
)
final
;
bool
supportsManualControl
(
void
)
final
;
void
initializeVehicle
(
Vehicle
*
vehicle
)
final
;
void
initializeVehicle
(
Vehicle
*
vehicle
)
final
;
bool
sendHomePositionToVehicle
(
void
)
final
;
bool
sendHomePositionToVehicle
(
void
)
final
;
void
addMetaDataToFact
(
QObject
*
parameterMetaData
,
Fact
*
fact
,
MAV_TYPE
vehicleType
)
final
;
void
addMetaDataToFact
(
QObject
*
parameterMetaData
,
Fact
*
fact
,
MAV_TYPE
vehicleType
)
final
;
QString
getDefaultComponentIdParam
(
void
)
const
final
{
return
QString
(
"SYS_AUTOSTART"
);
}
QString
getDefaultComponentIdParam
(
void
)
const
final
{
return
QString
(
"SYS_AUTOSTART"
);
}
QString
missionCommandOverrides
(
MAV_TYPE
vehicleType
)
const
final
;
QString
missionCommandOverrides
(
MAV_TYPE
vehicleType
)
const
final
;
QString
getVersionParam
(
void
)
final
{
return
QString
(
"SYS_PARAM_VER"
);
}
QString
getVersionParam
(
void
)
final
{
return
QString
(
"SYS_PARAM_VER"
);
}
QString
internalParameterMetaDataFile
(
void
)
final
{
return
QString
(
":/FirmwarePlugin/PX4/PX4ParameterFactMetaData.xml"
);
}
QString
internalParameterMetaDataFile
(
void
)
final
{
return
QString
(
":/FirmwarePlugin/PX4/PX4ParameterFactMetaData.xml"
);
}
void
getParameterMetaDataVersionInfo
(
const
QString
&
metaDataFile
,
int
&
majorVersion
,
int
&
minorVersion
)
final
{
PX4ParameterMetaData
::
getParameterMetaDataVersionInfo
(
metaDataFile
,
majorVersion
,
minorVersion
);
}
void
getParameterMetaDataVersionInfo
(
const
QString
&
metaDataFile
,
int
&
majorVersion
,
int
&
minorVersion
)
final
{
PX4ParameterMetaData
::
getParameterMetaDataVersionInfo
(
metaDataFile
,
majorVersion
,
minorVersion
);
}
QObject
*
loadParameterMetaData
(
const
QString
&
metaDataFile
);
QObject
*
loadParameterMetaData
(
const
QString
&
metaDataFile
);
bool
adjustIncomingMavlinkMessage
(
Vehicle
*
vehicle
,
mavlink_message_t
*
message
);
bool
adjustIncomingMavlinkMessage
(
Vehicle
*
vehicle
,
mavlink_message_t
*
message
);
GeoFenceManager
*
newGeoFenceManager
(
Vehicle
*
vehicle
)
{
return
new
PX4GeoFenceManager
(
vehicle
);
}
// Use these constants to set flight modes using setFlightMode method. Don't use hardcoded string names since the
// Use these constants to set flight modes using setFlightMode method. Don't use hardcoded string names since the
// names may change.
// names may change.
...
...
src/FirmwarePlugin/PX4/PX4GeoFenceManager.cc
0 → 100644
View file @
9624d5c5
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "PX4GeoFenceManager.h"
#include "Vehicle.h"
#include "FirmwarePlugin.h"
#include "ParameterLoader.h"
PX4GeoFenceManager
::
PX4GeoFenceManager
(
Vehicle
*
vehicle
)
:
GeoFenceManager
(
vehicle
)
,
_firstParamLoadComplete
(
false
)
,
_circleRadiusFact
(
NULL
)
{
connect
(
_vehicle
->
getParameterLoader
(),
&
ParameterLoader
::
parametersReady
,
this
,
&
PX4GeoFenceManager
::
_parametersReady
);
}
PX4GeoFenceManager
::~
PX4GeoFenceManager
()
{
}
void
PX4GeoFenceManager
::
_parametersReady
(
void
)
{
if
(
!
_firstParamLoadComplete
)
{
_firstParamLoadComplete
=
true
;
_circleRadiusFact
=
_vehicle
->
getParameterFact
(
FactSystem
::
defaultComponentId
,
QStringLiteral
(
"GF_MAX_HOR_DIST"
));
connect
(
_circleRadiusFact
,
&
Fact
::
rawValueChanged
,
this
,
&
PX4GeoFenceManager
::
_circleRadiusRawValueChanged
);
emit
circleRadiusChanged
(
circleRadius
());
QStringList
paramNames
;
QStringList
paramLabels
;
paramNames
<<
QStringLiteral
(
"GF_ACTION"
)
<<
QStringLiteral
(
"GF_MAX_HOR_DIST"
)
<<
QStringLiteral
(
"GF_MAX_VER_DIST"
);
paramLabels
<<
QStringLiteral
(
"Action:"
)
<<
QStringLiteral
(
"Radius:"
)
<<
QStringLiteral
(
"Max Altitude:"
);
_params
.
clear
();
_paramLabels
.
clear
();
for
(
int
i
=
0
;
i
<
paramNames
.
count
();
i
++
)
{
QString
paramName
=
paramNames
[
i
];
if
(
_vehicle
->
parameterExists
(
FactSystem
::
defaultComponentId
,
paramName
))
{
Fact
*
paramFact
=
_vehicle
->
getParameterFact
(
FactSystem
::
defaultComponentId
,
paramName
);
_params
<<
QVariant
::
fromValue
(
paramFact
);
_paramLabels
<<
paramLabels
[
i
];
}
}
emit
paramsChanged
(
_params
);
emit
paramLabelsChanged
(
_paramLabels
);
emit
circleSupportedChanged
(
circleSupported
());
qCDebug
(
GeoFenceManagerLog
)
<<
"fenceSupported:circleSupported:polygonSupported:breachReturnSupported"
<<
fenceSupported
()
<<
circleSupported
()
<<
polygonSupported
()
<<
breachReturnSupported
();
}
}
float
PX4GeoFenceManager
::
circleRadius
(
void
)
const
{
if
(
_circleRadiusFact
)
{
return
_circleRadiusFact
->
rawValue
().
toFloat
();
}
else
{
return
0.0
;
}
}
void
PX4GeoFenceManager
::
_circleRadiusRawValueChanged
(
QVariant
value
)
{
emit
circleRadiusChanged
(
value
.
toFloat
());
emit
circleSupportedChanged
(
circleSupported
());
}
bool
PX4GeoFenceManager
::
circleSupported
(
void
)
const
{
if
(
_circleRadiusFact
)
{
return
_circleRadiusFact
->
rawValue
().
toFloat
()
>=
0.0
;
}
return
false
;
}
src/FirmwarePlugin/PX4/PX4GeoFenceManager.h
0 → 100644
View file @
9624d5c5
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#ifndef PX4GeoFenceManager_H
#define PX4GeoFenceManager_H
#include "GeoFenceManager.h"
#include "QGCMAVLink.h"
#include "FactSystem.h"
class
PX4GeoFenceManager
:
public
GeoFenceManager
{
Q_OBJECT
public:
PX4GeoFenceManager
(
Vehicle
*
vehicle
);
~
PX4GeoFenceManager
();
// Overrides from GeoFenceManager
bool
fenceSupported
(
void
)
const
final
{
return
true
;
}
bool
circleSupported
(
void
)
const
final
;
float
circleRadius
(
void
)
const
final
;
QVariantList
params
(
void
)
const
final
{
return
_params
;
}
QStringList
paramLabels
(
void
)
const
final
{
return
_paramLabels
;
}
private
slots
:
void
_circleRadiusRawValueChanged
(
QVariant
value
);
void
_parametersReady
(
void
);
private:
bool
_firstParamLoadComplete
;
QVariantList
_params
;
QStringList
_paramLabels
;
Fact
*
_circleRadiusFact
;
};
#endif
src/MissionEditor/GeoFenceEditor.qml
View file @
9624d5c5
...
@@ -44,7 +44,7 @@ QGCFlickable {
...
@@ -44,7 +44,7 @@ QGCFlickable {
anchors.margins
:
_margin
anchors.margins
:
_margin
anchors.left
:
parent
.
left
anchors.left
:
parent
.
left
anchors.top
:
parent
.
top
anchors.top
:
parent
.
top
text
:
qsTr
(
"
Geo
-
Fence (WIP careful!)
"
)
text
:
qsTr
(
"
GeoFence (WIP careful!)
"
)
color
:
"
black
"
color
:
"
black
"
}
}
...
...
src/MissionEditor/MissionEditor.qml
View file @
9624d5c5
This diff is collapsed.
Click to expand it.
src/MissionManager/GeoFenceController.cc
View file @
9624d5c5
...
@@ -83,8 +83,9 @@ void GeoFenceController::_activeVehicleSet(void)
...
@@ -83,8 +83,9 @@ void GeoFenceController::_activeVehicleSet(void)
connect
(
geoFenceManager
,
&
GeoFenceManager
::
paramsChanged
,
this
,
&
GeoFenceController
::
paramsChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
paramsChanged
,
this
,
&
GeoFenceController
::
paramsChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
paramLabelsChanged
,
this
,
&
GeoFenceController
::
paramLabelsChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
paramLabelsChanged
,
this
,
&
GeoFenceController
::
paramLabelsChanged
);
_signalAll
();
if
(
_activeVehicle
->
getParameterLoader
()
->
parametersAreReady
())
{
if
(
_activeVehicle
->
getParameterLoader
()
->
parametersAreReady
())
{
_signalAll
();
if
(
!
syncInProgress
())
{
if
(
!
syncInProgress
())
{
// We are switching between two previously existing vehicles. We have to manually ask for the items from the Vehicle.
// We are switching between two previously existing vehicles. We have to manually ask for the items from the Vehicle.
// We don't request mission items for new vehicles since that will happen autamatically.
// We don't request mission items for new vehicles since that will happen autamatically.
...
@@ -223,7 +224,8 @@ void GeoFenceController::_setDirty(void)
...
@@ -223,7 +224,8 @@ void GeoFenceController::_setDirty(void)
void
GeoFenceController
::
_setPolygon
(
const
QList
<
QGeoCoordinate
>&
polygon
)
void
GeoFenceController
::
_setPolygon
(
const
QList
<
QGeoCoordinate
>&
polygon
)
{
{
_polygon
.
setPath
(
polygon
);
_polygon
.
setPath
(
polygon
);
setDirty
(
true
);
// This is coming from a GeoFenceManager::loadFromVehicle call
setDirty
(
false
);
}
}
float
GeoFenceController
::
circleRadius
(
void
)
const
float
GeoFenceController
::
circleRadius
(
void
)
const
...
...
src/QmlControls/QGCRadioButton.qml
View file @
9624d5c5
...
@@ -6,7 +6,9 @@ import QGroundControl.Palette 1.0
...
@@ -6,7 +6,9 @@ import QGroundControl.Palette 1.0
import
QGroundControl
.
ScreenTools
1.0
import
QGroundControl
.
ScreenTools
1.0
RadioButton
{
RadioButton
{
property
var
__qgcPal
:
QGCPalette
{
colorGroupEnabled
:
enabled
}
property
var
color
:
_qgcPal
.
text
///< Text color
property
var
_qgcPal
:
QGCPalette
{
colorGroupEnabled
:
enabled
}
style
:
RadioButtonStyle
{
style
:
RadioButtonStyle
{
label
:
Item
{
label
:
Item
{
...
@@ -31,7 +33,7 @@ RadioButton {
...
@@ -31,7 +33,7 @@ RadioButton {
font.pointSize
:
ScreenTools
.
defaultFontPointSize
font.pointSize
:
ScreenTools
.
defaultFontPointSize
font.family
:
ScreenTools
.
normalFontFamily
font.family
:
ScreenTools
.
normalFontFamily
antialiasing
:
true
antialiasing
:
true
color
:
control
.
__qgcPal
.
text
color
:
control
.
color
anchors.centerIn
:
parent
anchors.centerIn
:
parent
}
}
}
}
...
...
src/comm/LinkManager.cc
View file @
9624d5c5
...
@@ -188,7 +188,7 @@ void LinkManager::_addLink(LinkInterface* link)
...
@@ -188,7 +188,7 @@ void LinkManager::_addLink(LinkInterface* link)
if
(
!
(
_mavlinkChannelsUsedBitMask
&
1
<<
i
))
{
if
(
!
(
_mavlinkChannelsUsedBitMask
&
1
<<
i
))
{
mavlink_reset_channel_status
(
i
);
mavlink_reset_channel_status
(
i
);
link
->
_setMavlinkChannel
(
i
);
link
->
_setMavlinkChannel
(
i
);
_mavlinkChannelsUsedBitMask
|=
i
<<
i
;
_mavlinkChannelsUsedBitMask
|=
1
<<
i
;
channelSet
=
true
;
channelSet
=
true
;
break
;
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