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
4289338a
Commit
4289338a
authored
Aug 17, 2017
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add distance to home to Vehicle FactGroup
parent
d0946f6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
Vehicle.cc
src/Vehicle/Vehicle.cc
+16
-0
Vehicle.h
src/Vehicle/Vehicle.h
+5
-0
VehicleFact.json
src/Vehicle/VehicleFact.json
+7
-0
No files found.
src/Vehicle/Vehicle.cc
View file @
4289338a
...
...
@@ -55,6 +55,7 @@ const char* Vehicle::_altitudeRelativeFactName = "altitudeRelative";
const
char
*
Vehicle
::
_altitudeAMSLFactName
=
"altitudeAMSL"
;
const
char
*
Vehicle
::
_flightDistanceFactName
=
"flightDistance"
;
const
char
*
Vehicle
::
_flightTimeFactName
=
"flightTime"
;
const
char
*
Vehicle
::
_distanceToHomeFactName
=
"distanceToHome"
;
const
char
*
Vehicle
::
_gpsFactGroupName
=
"gps"
;
const
char
*
Vehicle
::
_batteryFactGroupName
=
"battery"
;
...
...
@@ -160,6 +161,7 @@ Vehicle::Vehicle(LinkInterface* link,
,
_altitudeAMSLFact
(
0
,
_altitudeAMSLFactName
,
FactMetaData
::
valueTypeDouble
)
,
_flightDistanceFact
(
0
,
_flightDistanceFactName
,
FactMetaData
::
valueTypeDouble
)
,
_flightTimeFact
(
0
,
_flightTimeFactName
,
FactMetaData
::
valueTypeElapsedTimeInSeconds
)
,
_distanceToHomeFact
(
0
,
_distanceToHomeFactName
,
FactMetaData
::
valueTypeDouble
)
,
_gpsFactGroup
(
this
)
,
_batteryFactGroup
(
this
)
,
_windFactGroup
(
this
)
...
...
@@ -325,6 +327,7 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
,
_altitudeAMSLFact
(
0
,
_altitudeAMSLFactName
,
FactMetaData
::
valueTypeDouble
)
,
_flightDistanceFact
(
0
,
_flightDistanceFactName
,
FactMetaData
::
valueTypeDouble
)
,
_flightTimeFact
(
0
,
_flightTimeFactName
,
FactMetaData
::
valueTypeElapsedTimeInSeconds
)
,
_distanceToHomeFact
(
0
,
_distanceToHomeFactName
,
FactMetaData
::
valueTypeDouble
)
,
_gpsFactGroup
(
this
)
,
_batteryFactGroup
(
this
)
,
_windFactGroup
(
this
)
...
...
@@ -338,6 +341,9 @@ void Vehicle::_commonInit(void)
{
_firmwarePlugin
=
_firmwarePluginManager
->
firmwarePluginForAutopilot
(
_firmwareType
,
_vehicleType
);
connect
(
this
,
&
Vehicle
::
coordinateChanged
,
this
,
&
Vehicle
::
_updateDistanceToHome
);
connect
(
this
,
&
Vehicle
::
homePositionChanged
,
this
,
&
Vehicle
::
_updateDistanceToHome
);
_missionManager
=
new
MissionManager
(
this
);
connect
(
_missionManager
,
&
MissionManager
::
error
,
this
,
&
Vehicle
::
_missionManagerError
);
connect
(
_missionManager
,
&
MissionManager
::
newMissionItemsAvailable
,
this
,
&
Vehicle
::
_missionLoadComplete
);
...
...
@@ -376,6 +382,7 @@ void Vehicle::_commonInit(void)
_addFact
(
&
_altitudeAMSLFact
,
_altitudeAMSLFactName
);
_addFact
(
&
_flightDistanceFact
,
_flightDistanceFactName
);
_addFact
(
&
_flightTimeFact
,
_flightTimeFactName
);
_addFact
(
&
_distanceToHomeFact
,
_distanceToHomeFactName
);
_addFactGroup
(
&
_gpsFactGroup
,
_gpsFactGroupName
);
_addFactGroup
(
&
_batteryFactGroup
,
_batteryFactGroupName
);
...
...
@@ -2798,6 +2805,15 @@ void Vehicle::_handleADSBVehicle(const mavlink_message_t& message)
}
}
void
Vehicle
::
_updateDistanceToHome
(
void
)
{
if
(
coordinate
().
isValid
()
&&
homePosition
().
isValid
())
{
_distanceToHomeFact
.
setRawValue
(
coordinate
().
distanceTo
(
homePosition
()));
}
else
{
_distanceToHomeFact
.
setRawValue
(
qQNaN
());
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
...
...
src/Vehicle/Vehicle.h
View file @
4289338a
...
...
@@ -348,6 +348,7 @@ public:
Q_PROPERTY
(
Fact
*
altitudeRelative
READ
altitudeRelative
CONSTANT
)
Q_PROPERTY
(
Fact
*
altitudeAMSL
READ
altitudeAMSL
CONSTANT
)
Q_PROPERTY
(
Fact
*
flightDistance
READ
flightDistance
CONSTANT
)
Q_PROPERTY
(
Fact
*
distanceToHome
READ
distanceToHome
CONSTANT
)
Q_PROPERTY
(
FactGroup
*
gps
READ
gpsFactGroup
CONSTANT
)
Q_PROPERTY
(
FactGroup
*
battery
READ
batteryFactGroup
CONSTANT
)
...
...
@@ -613,6 +614,7 @@ public:
Fact
*
altitudeRelative
(
void
)
{
return
&
_altitudeRelativeFact
;
}
Fact
*
altitudeAMSL
(
void
)
{
return
&
_altitudeAMSLFact
;
}
Fact
*
flightDistance
(
void
)
{
return
&
_flightDistanceFact
;
}
Fact
*
distanceToHome
(
void
)
{
return
&
_distanceToHomeFact
;
}
FactGroup
*
gpsFactGroup
(
void
)
{
return
&
_gpsFactGroup
;
}
FactGroup
*
batteryFactGroup
(
void
)
{
return
&
_batteryFactGroup
;
}
...
...
@@ -825,6 +827,7 @@ private slots:
void
_activeJoystickChanged
(
void
);
void
_clearTrajectoryPoints
(
void
);
void
_clearCameraTriggerPoints
(
void
);
void
_updateDistanceToHome
(
void
);
private:
bool
_containsLink
(
LinkInterface
*
link
);
...
...
@@ -1042,6 +1045,7 @@ private:
Fact
_altitudeAMSLFact
;
Fact
_flightDistanceFact
;
Fact
_flightTimeFact
;
Fact
_distanceToHomeFact
;
VehicleGPSFactGroup
_gpsFactGroup
;
VehicleBatteryFactGroup
_batteryFactGroup
;
...
...
@@ -1059,6 +1063,7 @@ private:
static
const
char
*
_altitudeAMSLFactName
;
static
const
char
*
_flightDistanceFactName
;
static
const
char
*
_flightTimeFactName
;
static
const
char
*
_distanceToHomeFactName
;
static
const
char
*
_gpsFactGroupName
;
static
const
char
*
_batteryFactGroupName
;
...
...
src/Vehicle/VehicleFact.json
View file @
4289338a
...
...
@@ -62,6 +62,13 @@
"decimalPlaces"
:
1
,
"units"
:
"m"
},
{
"name"
:
"distanceToHome"
,
"shortDescription"
:
"Distance to Home"
,
"type"
:
"double"
,
"decimalPlaces"
:
1
,
"units"
:
"m"
},
{
"name"
:
"flightTime"
,
"shortDescription"
:
"Flight Time"
,
...
...
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