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
9502c20a
Unverified
Commit
9502c20a
authored
Apr 19, 2018
by
Gus Grubba
Committed by
GitHub
Apr 19, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6316 from mavlink/lowBatteryState
Support for low battery state (and remaining time)
parents
07820407
32f88ed2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
BatteryFact.json
src/Vehicle/BatteryFact.json
+14
-0
Vehicle.cc
src/Vehicle/Vehicle.cc
+20
-0
Vehicle.h
src/Vehicle/Vehicle.h
+8
-1
No files found.
src/Vehicle/BatteryFact.json
View file @
9502c20a
...
...
@@ -46,5 +46,19 @@
"type"
:
"float"
,
"decimalPlaces"
:
2
,
"units"
:
"W"
},
{
"name"
:
"timeRemaining"
,
"shortDescription"
:
"Time Remaining"
,
"type"
:
"int32"
,
"units"
:
"s"
},
{
"name"
:
"chargeState"
,
"shortDescription"
:
"Charge State"
,
"type"
:
"uint8"
,
"enumStrings"
:
"Low Battery State Not Provided,Normal Operation,Low Battery State,Critical Battery State,Emergency Battery State,Battery Failed,Battery Unhealthy"
,
"enumValues"
:
"0,1,2,3,4,5,6"
,
"decimalPlaces"
:
0
}
]
src/Vehicle/Vehicle.cc
View file @
9502c20a
...
...
@@ -1319,6 +1319,20 @@ void Vehicle::_handleBatteryStatus(mavlink_message_t& message)
}
_batteryFactGroup
.
cellCount
()
->
setRawValue
(
cellCount
);
//-- Time remaining in seconds (0 means not supported)
_batteryFactGroup
.
timeRemaining
()
->
setRawValue
(
bat_status
.
time_remaining
);
//-- Battery charge state (0 means not supported)
if
(
bat_status
.
charge_state
<=
MAV_BATTERY_CHARGE_STATE_UNHEALTHY
)
{
_batteryFactGroup
.
chargeState
()
->
setRawValue
(
bat_status
.
charge_state
);
}
else
{
_batteryFactGroup
.
chargeState
()
->
setRawValue
(
0
);
}
//-- TODO: Somewhere, actions would be taken based on this chargeState:
// MAV_BATTERY_CHARGE_STATE_CRITICAL: Battery state is critical, return / abort immediately
// MAV_BATTERY_CHARGE_STATE_EMERGENCY: Battery state is too low for ordinary abortion, fastest possible emergency stop preventing damage
// MAV_BATTERY_CHARGE_STATE_FAILED: Battery failed, damage unavoidable
// MAV_BATTERY_CHARGE_STATE_UNHEALTHY: Battery is diagnosed to be broken or an error occurred, usage is discouraged / prohibited
}
void
Vehicle
::
_setHomePosition
(
QGeoCoordinate
&
homeCoord
)
...
...
@@ -3269,6 +3283,8 @@ const char* VehicleBatteryFactGroup::_currentFactName = "cur
const
char
*
VehicleBatteryFactGroup
::
_temperatureFactName
=
"temperature"
;
const
char
*
VehicleBatteryFactGroup
::
_cellCountFactName
=
"cellCount"
;
const
char
*
VehicleBatteryFactGroup
::
_instantPowerFactName
=
"instantPower"
;
const
char
*
VehicleBatteryFactGroup
::
_timeRemainingFactName
=
"timeRemaining"
;
const
char
*
VehicleBatteryFactGroup
::
_chargeStateFactName
=
"chargeState"
;
const
char
*
VehicleBatteryFactGroup
::
_settingsGroup
=
"Vehicle.battery"
;
...
...
@@ -3289,6 +3305,8 @@ VehicleBatteryFactGroup::VehicleBatteryFactGroup(QObject* parent)
,
_temperatureFact
(
0
,
_temperatureFactName
,
FactMetaData
::
valueTypeDouble
)
,
_cellCountFact
(
0
,
_cellCountFactName
,
FactMetaData
::
valueTypeInt32
)
,
_instantPowerFact
(
0
,
_instantPowerFactName
,
FactMetaData
::
valueTypeFloat
)
,
_timeRemainingFact
(
0
,
_timeRemainingFactName
,
FactMetaData
::
valueTypeInt32
)
,
_chargeStateFact
(
0
,
_chargeStateFactName
,
FactMetaData
::
valueTypeUint8
)
{
_addFact
(
&
_voltageFact
,
_voltageFactName
);
_addFact
(
&
_percentRemainingFact
,
_percentRemainingFactName
);
...
...
@@ -3297,6 +3315,8 @@ VehicleBatteryFactGroup::VehicleBatteryFactGroup(QObject* parent)
_addFact
(
&
_temperatureFact
,
_temperatureFactName
);
_addFact
(
&
_cellCountFact
,
_cellCountFactName
);
_addFact
(
&
_instantPowerFact
,
_instantPowerFactName
);
_addFact
(
&
_timeRemainingFact
,
_timeRemainingFactName
);
_addFact
(
&
_chargeStateFact
,
_chargeStateFactName
);
// Start out as not available
_voltageFact
.
setRawValue
(
_voltageUnavailable
);
...
...
src/Vehicle/Vehicle.h
View file @
9502c20a
...
...
@@ -254,6 +254,8 @@ public:
Q_PROPERTY
(
Fact
*
temperature
READ
temperature
CONSTANT
)
Q_PROPERTY
(
Fact
*
cellCount
READ
cellCount
CONSTANT
)
Q_PROPERTY
(
Fact
*
instantPower
READ
instantPower
CONSTANT
)
Q_PROPERTY
(
Fact
*
timeRemaining
READ
timeRemaining
CONSTANT
)
Q_PROPERTY
(
Fact
*
chargeState
READ
chargeState
CONSTANT
)
Fact
*
voltage
(
void
)
{
return
&
_voltageFact
;
}
Fact
*
percentRemaining
(
void
)
{
return
&
_percentRemainingFact
;
}
...
...
@@ -262,7 +264,8 @@ public:
Fact
*
temperature
(
void
)
{
return
&
_temperatureFact
;
}
Fact
*
cellCount
(
void
)
{
return
&
_cellCountFact
;
}
Fact
*
instantPower
(
void
)
{
return
&
_instantPowerFact
;
}
Fact
*
timeRemaining
(
void
)
{
return
&
_timeRemainingFact
;
}
Fact
*
chargeState
(
void
)
{
return
&
_chargeStateFact
;
}
static
const
char
*
_voltageFactName
;
static
const
char
*
_percentRemainingFactName
;
...
...
@@ -271,6 +274,8 @@ public:
static
const
char
*
_temperatureFactName
;
static
const
char
*
_cellCountFactName
;
static
const
char
*
_instantPowerFactName
;
static
const
char
*
_timeRemainingFactName
;
static
const
char
*
_chargeStateFactName
;
static
const
char
*
_settingsGroup
;
...
...
@@ -290,6 +295,8 @@ private:
Fact
_temperatureFact
;
Fact
_cellCountFact
;
Fact
_instantPowerFact
;
Fact
_timeRemainingFact
;
Fact
_chargeStateFact
;
};
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