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
2d7fcb24
Commit
2d7fcb24
authored
Feb 23, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Vehicle.wind properties
parent
28625888
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
134 additions
and
9 deletions
+134
-9
qgroundcontrol.qrc
qgroundcontrol.qrc
+1
-0
Fact.cc
src/FactSystem/Fact.cc
+23
-9
Vehicle.cc
src/Vehicle/Vehicle.cc
+47
-0
Vehicle.h
src/Vehicle/Vehicle.h
+36
-0
WindFact.json
src/Vehicle/WindFact.json
+27
-0
No files found.
qgroundcontrol.qrc
View file @
2d7fcb24
...
...
@@ -157,5 +157,6 @@
<file alias="Vehicle/VehicleFact.json">src/Vehicle/VehicleFact.json</file>
<file alias="Vehicle/BatteryFact.json">src/Vehicle/BatteryFact.json</file>
<file alias="Vehicle/GPSFact.json">src/Vehicle/GPSFact.json</file>
<file alias="Vehicle/WindFact.json">src/Vehicle/WindFact.json</file>
</qresource>
</RCC>
src/FactSystem/Fact.cc
View file @
2d7fcb24
...
...
@@ -254,15 +254,29 @@ QString Fact::_variantToString(const QVariant& variant) const
QString
valueString
;
switch
(
type
())
{
case
FactMetaData
:
:
valueTypeFloat
:
valueString
=
QString
(
"%1"
).
arg
(
variant
.
toFloat
(),
0
,
'f'
,
decimalPlaces
());
break
;
case
FactMetaData
:
:
valueTypeDouble
:
valueString
=
QString
(
"%1"
).
arg
(
variant
.
toDouble
(),
0
,
'f'
,
decimalPlaces
());
break
;
default:
valueString
=
variant
.
toString
();
break
;
case
FactMetaData
:
:
valueTypeFloat
:
{
float
fValue
=
variant
.
toFloat
();
if
(
qIsNaN
(
fValue
))
{
valueString
=
QStringLiteral
(
"--.--"
);
}
else
{
valueString
=
QString
(
"%1"
).
arg
(
fValue
,
0
,
'f'
,
decimalPlaces
());
}
}
break
;
case
FactMetaData
:
:
valueTypeDouble
:
{
double
dValue
=
variant
.
toDouble
();
if
(
qIsNaN
(
dValue
))
{
valueString
=
QStringLiteral
(
"--.--"
);
}
else
{
valueString
=
QString
(
"%1"
).
arg
(
dValue
,
0
,
'f'
,
decimalPlaces
());
}
}
break
;
default:
valueString
=
variant
.
toString
();
break
;
}
return
valueString
;
...
...
src/Vehicle/Vehicle.cc
View file @
2d7fcb24
...
...
@@ -57,6 +57,7 @@ const char* Vehicle::_altitudeAMSLFactName = "altitudeAMSL";
const
char
*
Vehicle
::
_gpsFactGroupName
=
"gps"
;
const
char
*
Vehicle
::
_batteryFactGroupName
=
"battery"
;
const
char
*
Vehicle
::
_windFactGroupName
=
"wind"
;
const
char
*
VehicleGPSFactGroup
::
_hdopFactName
=
"hdop"
;
const
char
*
VehicleGPSFactGroup
::
_vdopFactName
=
"vdop"
;
...
...
@@ -78,6 +79,10 @@ const int VehicleBatteryFactGroup::_currentUnavailable = -1;
const
double
VehicleBatteryFactGroup
::
_temperatureUnavailable
=
-
1.0
;
const
int
VehicleBatteryFactGroup
::
_cellCountUnavailable
=
-
1.0
;
const
char
*
VehicleWindFactGroup
::
_directionFactName
=
"direction"
;
const
char
*
VehicleWindFactGroup
::
_speedFactName
=
"speed"
;
const
char
*
VehicleWindFactGroup
::
_verticalSpeedFactName
=
"verticalSpeed"
;
Vehicle
::
Vehicle
(
LinkInterface
*
link
,
int
vehicleId
,
MAV_AUTOPILOT
firmwareType
,
...
...
@@ -144,6 +149,7 @@ Vehicle::Vehicle(LinkInterface* link,
,
_altitudeAMSLFact
(
0
,
_altitudeAMSLFactName
,
FactMetaData
::
valueTypeDouble
)
,
_gpsFactGroup
(
this
)
,
_batteryFactGroup
(
this
)
,
_windFactGroup
(
this
)
{
_addLink
(
link
);
...
...
@@ -225,8 +231,11 @@ Vehicle::Vehicle(LinkInterface* link,
_addFactGroup
(
&
_gpsFactGroup
,
_gpsFactGroupName
);
_addFactGroup
(
&
_batteryFactGroup
,
_batteryFactGroupName
);
_addFactGroup
(
&
_windFactGroup
,
_windFactGroupName
);
_gpsFactGroup
.
setVehicle
(
this
);
_batteryFactGroup
.
setVehicle
(
this
);
_windFactGroup
.
setVehicle
(
this
);
}
Vehicle
::~
Vehicle
()
...
...
@@ -324,6 +333,12 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
case
MAVLINK_MSG_ID_SCALED_IMU3
:
emit
mavlinkScaledImu3
(
message
);
break
;
// Following are ArduPilot dialect messages
case
MAVLINK_MSG_ID_WIND
:
_handleWind
(
message
);
break
;
}
emit
mavlinkMessageReceived
(
message
);
...
...
@@ -331,6 +346,16 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
_uas
->
receiveMessage
(
message
);
}
void
Vehicle
::
_handleWind
(
mavlink_message_t
&
message
)
{
mavlink_wind_t
wind
;
mavlink_msg_wind_decode
(
&
message
,
&
wind
);
_windFactGroup
.
direction
()
->
setRawValue
(
wind
.
direction
);
_windFactGroup
.
speed
()
->
setRawValue
(
wind
.
speed
);
_windFactGroup
.
verticalSpeed
()
->
setRawValue
(
wind
.
speed_z
);
}
void
Vehicle
::
_handleSysStatus
(
mavlink_message_t
&
message
)
{
mavlink_sys_status_t
sysStatus
;
...
...
@@ -1315,3 +1340,25 @@ void VehicleBatteryFactGroup::setVehicle(Vehicle* vehicle)
{
_vehicle
=
vehicle
;
}
VehicleWindFactGroup
::
VehicleWindFactGroup
(
QObject
*
parent
)
:
FactGroup
(
1000
,
":/json/Vehicle/WindFact.json"
,
parent
)
,
_vehicle
(
NULL
)
,
_directionFact
(
0
,
_directionFactName
,
FactMetaData
::
valueTypeDouble
)
,
_speedFact
(
0
,
_speedFactName
,
FactMetaData
::
valueTypeDouble
)
,
_verticalSpeedFact
(
0
,
_verticalSpeedFactName
,
FactMetaData
::
valueTypeDouble
)
{
_addFact
(
&
_directionFact
,
_directionFactName
);
_addFact
(
&
_speedFact
,
_speedFactName
);
_addFact
(
&
_verticalSpeedFact
,
_verticalSpeedFactName
);
// Start out as not available "--.--"
_directionFact
.
setRawValue
(
std
::
numeric_limits
<
float
>::
quiet_NaN
());
_speedFact
.
setRawValue
(
std
::
numeric_limits
<
float
>::
quiet_NaN
());
_verticalSpeedFact
.
setRawValue
(
std
::
numeric_limits
<
float
>::
quiet_NaN
());
}
void
VehicleWindFactGroup
::
setVehicle
(
Vehicle
*
vehicle
)
{
_vehicle
=
vehicle
;
}
src/Vehicle/Vehicle.h
View file @
2d7fcb24
...
...
@@ -52,6 +52,36 @@ Q_DECLARE_LOGGING_CATEGORY(VehicleLog)
class
Vehicle
;
class
VehicleWindFactGroup
:
public
FactGroup
{
Q_OBJECT
public:
VehicleWindFactGroup
(
QObject
*
parent
=
NULL
);
Q_PROPERTY
(
Fact
*
direction
READ
direction
CONSTANT
)
Q_PROPERTY
(
Fact
*
speed
READ
speed
CONSTANT
)
Q_PROPERTY
(
Fact
*
verticalSpeed
READ
verticalSpeed
CONSTANT
)
Fact
*
direction
(
void
)
{
return
&
_directionFact
;
}
Fact
*
speed
(
void
)
{
return
&
_speedFact
;
}
Fact
*
verticalSpeed
(
void
)
{
return
&
_verticalSpeedFact
;
}
void
setVehicle
(
Vehicle
*
vehicle
);
static
const
char
*
_directionFactName
;
static
const
char
*
_speedFactName
;
static
const
char
*
_verticalSpeedFactName
;
private
slots
:
private:
Vehicle
*
_vehicle
;
Fact
_directionFact
;
Fact
_speedFact
;
Fact
_verticalSpeedFact
;
};
class
VehicleGPSFactGroup
:
public
FactGroup
{
Q_OBJECT
...
...
@@ -214,6 +244,7 @@ public:
Q_PROPERTY
(
FactGroup
*
gps
READ
gpsFactGroup
CONSTANT
)
Q_PROPERTY
(
FactGroup
*
battery
READ
batteryFactGroup
CONSTANT
)
Q_PROPERTY
(
FactGroup
*
wind
READ
windFactGroup
CONSTANT
)
/// Resets link status counters
Q_INVOKABLE
void
resetCounters
();
...
...
@@ -363,6 +394,7 @@ public:
FactGroup
*
gpsFactGroup
(
void
)
{
return
&
_gpsFactGroup
;
}
FactGroup
*
batteryFactGroup
(
void
)
{
return
&
_batteryFactGroup
;
}
FactGroup
*
windFactGroup
(
void
)
{
return
&
_windFactGroup
;
}
void
setConnectionLostEnabled
(
bool
connectionLostEnabled
);
...
...
@@ -465,6 +497,7 @@ private:
void
_handleRCChannelsRaw
(
mavlink_message_t
&
message
);
void
_handleBatteryStatus
(
mavlink_message_t
&
message
);
void
_handleSysStatus
(
mavlink_message_t
&
message
);
void
_handleWind
(
mavlink_message_t
&
message
);
void
_missionManagerError
(
int
errorCode
,
const
QString
&
errorMsg
);
void
_mapTrajectoryStart
(
void
);
void
_mapTrajectoryStop
(
void
);
...
...
@@ -577,6 +610,7 @@ private:
VehicleGPSFactGroup
_gpsFactGroup
;
VehicleBatteryFactGroup
_batteryFactGroup
;
VehicleWindFactGroup
_windFactGroup
;
static
const
char
*
_rollFactName
;
static
const
char
*
_pitchFactName
;
...
...
@@ -586,8 +620,10 @@ private:
static
const
char
*
_climbRateFactName
;
static
const
char
*
_altitudeRelativeFactName
;
static
const
char
*
_altitudeAMSLFactName
;
static
const
char
*
_gpsFactGroupName
;
static
const
char
*
_batteryFactGroupName
;
static
const
char
*
_windFactGroupName
;
static
const
int
_vehicleUIUpdateRateMSecs
=
100
;
...
...
src/Vehicle/WindFact.json
0 → 100644
View file @
2d7fcb24
{
"version"
:
1
,
"properties"
:
[
{
"name"
:
"direction"
,
"shortDescription"
:
"Wind Direction"
,
"type"
:
"double"
,
"decimalPlaces"
:
1
,
"units"
:
"degrees"
},
{
"name"
:
"speed"
,
"shortDescription"
:
"Wind Spd"
,
"type"
:
"double"
,
"decimalPlaces"
:
1
,
"units"
:
"m/s"
},
{
"name"
:
"verticalSpeed"
,
"shortDescription"
:
"Wind Spd (vert)"
,
"type"
:
"double"
,
"decimalPlaces"
:
1
,
"units"
:
"m/s"
}
]
}
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