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
cbe4ba6c
Commit
cbe4ba6c
authored
Oct 19, 2017
by
Patrick José Pereira
Committed by
Jacob Walser
Dec 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new Fact with current consumption in Watts
Signed-off-by:
Patrick José Pereira
<
patrickelectric@gmail.com
>
parent
4ed2e7e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
0 deletions
+19
-0
BatteryFact.json
src/Vehicle/BatteryFact.json
+7
-0
Vehicle.cc
src/Vehicle/Vehicle.cc
+7
-0
Vehicle.h
src/Vehicle/Vehicle.h
+5
-0
No files found.
src/Vehicle/BatteryFact.json
View file @
cbe4ba6c
...
...
@@ -39,5 +39,12 @@
"shortDescription"
:
"Cell Count"
,
"type"
:
"int32"
,
"decimalPlaces"
:
0
},
{
"name"
:
"instantPower"
,
"shortDescription"
:
"Watts"
,
"type"
:
"float"
,
"decimalPlaces"
:
2
,
"units"
:
"W"
}
]
src/Vehicle/Vehicle.cc
View file @
cbe4ba6c
...
...
@@ -1032,6 +1032,8 @@ void Vehicle::_handleSysStatus(mavlink_message_t& message)
_batteryFactGroup
.
voltage
()
->
setRawValue
(
VehicleBatteryFactGroup
::
_voltageUnavailable
);
}
else
{
_batteryFactGroup
.
voltage
()
->
setRawValue
((
double
)
sysStatus
.
voltage_battery
/
1000.0
);
// current_battery is 10 mA and voltage_battery is 1mV. (10/1e3 times 1/1e3 = 1/1e5)
_batteryFactGroup
.
instantPower
()
->
setRawValue
((
float
)(
sysStatus
.
current_battery
*
sysStatus
.
voltage_battery
)
/
(
100000.0
));
}
_batteryFactGroup
.
percentRemaining
()
->
setRawValue
(
sysStatus
.
battery_remaining
);
...
...
@@ -2935,6 +2937,7 @@ const char* VehicleBatteryFactGroup::_mahConsumedFactName = "mah
const
char
*
VehicleBatteryFactGroup
::
_currentFactName
=
"current"
;
const
char
*
VehicleBatteryFactGroup
::
_temperatureFactName
=
"temperature"
;
const
char
*
VehicleBatteryFactGroup
::
_cellCountFactName
=
"cellCount"
;
const
char
*
VehicleBatteryFactGroup
::
_instantPowerFactName
=
"instantPower"
;
const
char
*
VehicleBatteryFactGroup
::
_settingsGroup
=
"Vehicle.battery"
;
...
...
@@ -2944,6 +2947,7 @@ const int VehicleBatteryFactGroup::_mahConsumedUnavailable = -1;
const
int
VehicleBatteryFactGroup
::
_currentUnavailable
=
-
1
;
const
double
VehicleBatteryFactGroup
::
_temperatureUnavailable
=
-
1.0
;
const
int
VehicleBatteryFactGroup
::
_cellCountUnavailable
=
-
1.0
;
const
double
VehicleBatteryFactGroup
::
_instantPowerUnavailable
=
-
1.0
;
VehicleBatteryFactGroup
::
VehicleBatteryFactGroup
(
QObject
*
parent
)
:
FactGroup
(
1000
,
":/json/Vehicle/BatteryFact.json"
,
parent
)
...
...
@@ -2953,6 +2957,7 @@ VehicleBatteryFactGroup::VehicleBatteryFactGroup(QObject* parent)
,
_currentFact
(
0
,
_currentFactName
,
FactMetaData
::
valueTypeFloat
)
,
_temperatureFact
(
0
,
_temperatureFactName
,
FactMetaData
::
valueTypeDouble
)
,
_cellCountFact
(
0
,
_cellCountFactName
,
FactMetaData
::
valueTypeInt32
)
,
_instantPowerFact
(
0
,
_instantPowerFactName
,
FactMetaData
::
valueTypeFloat
)
{
_addFact
(
&
_voltageFact
,
_voltageFactName
);
_addFact
(
&
_percentRemainingFact
,
_percentRemainingFactName
);
...
...
@@ -2960,6 +2965,7 @@ VehicleBatteryFactGroup::VehicleBatteryFactGroup(QObject* parent)
_addFact
(
&
_currentFact
,
_currentFactName
);
_addFact
(
&
_temperatureFact
,
_temperatureFactName
);
_addFact
(
&
_cellCountFact
,
_cellCountFactName
);
_addFact
(
&
_instantPowerFact
,
_instantPowerFactName
);
// Start out as not available
_voltageFact
.
setRawValue
(
_voltageUnavailable
);
...
...
@@ -2968,6 +2974,7 @@ VehicleBatteryFactGroup::VehicleBatteryFactGroup(QObject* parent)
_currentFact
.
setRawValue
(
_currentUnavailable
);
_temperatureFact
.
setRawValue
(
_temperatureUnavailable
);
_cellCountFact
.
setRawValue
(
_cellCountUnavailable
);
_instantPowerFact
.
setRawValue
(
_instantPowerUnavailable
);
}
const
char
*
VehicleWindFactGroup
::
_directionFactName
=
"direction"
;
...
...
src/Vehicle/Vehicle.h
View file @
cbe4ba6c
...
...
@@ -156,6 +156,7 @@ public:
Q_PROPERTY
(
Fact
*
current
READ
current
CONSTANT
)
Q_PROPERTY
(
Fact
*
temperature
READ
temperature
CONSTANT
)
Q_PROPERTY
(
Fact
*
cellCount
READ
cellCount
CONSTANT
)
Q_PROPERTY
(
Fact
*
instantPower
READ
instantPower
CONSTANT
)
Fact
*
voltage
(
void
)
{
return
&
_voltageFact
;
}
Fact
*
percentRemaining
(
void
)
{
return
&
_percentRemainingFact
;
}
...
...
@@ -163,6 +164,7 @@ public:
Fact
*
current
(
void
)
{
return
&
_currentFact
;
}
Fact
*
temperature
(
void
)
{
return
&
_temperatureFact
;
}
Fact
*
cellCount
(
void
)
{
return
&
_cellCountFact
;
}
Fact
*
instantPower
(
void
)
{
return
&
_instantPowerFact
;
}
static
const
char
*
_voltageFactName
;
...
...
@@ -171,6 +173,7 @@ public:
static
const
char
*
_currentFactName
;
static
const
char
*
_temperatureFactName
;
static
const
char
*
_cellCountFactName
;
static
const
char
*
_instantPowerFactName
;
static
const
char
*
_settingsGroup
;
...
...
@@ -180,6 +183,7 @@ public:
static
const
int
_currentUnavailable
;
static
const
double
_temperatureUnavailable
;
static
const
int
_cellCountUnavailable
;
static
const
double
_instantPowerUnavailable
;
private:
Fact
_voltageFact
;
...
...
@@ -188,6 +192,7 @@ private:
Fact
_currentFact
;
Fact
_temperatureFact
;
Fact
_cellCountFact
;
Fact
_instantPowerFact
;
};
class
VehicleTemperatureFactGroup
:
public
FactGroup
...
...
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