Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
5ce755c0
Commit
5ce755c0
authored
May 20, 2018
by
DonLakeFlyer
Browse files
Handle second battery
parent
61a50ca6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Vehicle/Vehicle.cc
View file @
5ce755c0
...
...
@@ -1304,15 +1304,17 @@ void Vehicle::_handleBatteryStatus(mavlink_message_t& message)
mavlink_battery_status_t
bat_status
;
mavlink_msg_battery_status_decode
(
&
message
,
&
bat_status
);
VehicleBatteryFactGroup
&
batteryFactGroup
=
bat_status
.
id
==
0
?
_battery1FactGroup
:
_battery2FactGroup
;
if
(
bat_status
.
temperature
==
INT16_MAX
)
{
_
battery
1
FactGroup
.
temperature
()
->
setRawValue
(
VehicleBatteryFactGroup
::
_temperatureUnavailable
);
batteryFactGroup
.
temperature
()
->
setRawValue
(
VehicleBatteryFactGroup
::
_temperatureUnavailable
);
}
else
{
_
battery
1
FactGroup
.
temperature
()
->
setRawValue
((
double
)
bat_status
.
temperature
/
100.0
);
batteryFactGroup
.
temperature
()
->
setRawValue
((
double
)
bat_status
.
temperature
/
100.0
);
}
if
(
bat_status
.
current_consumed
==
-
1
)
{
_
battery
1
FactGroup
.
mahConsumed
()
->
setRawValue
(
VehicleBatteryFactGroup
::
_mahConsumedUnavailable
);
batteryFactGroup
.
mahConsumed
()
->
setRawValue
(
VehicleBatteryFactGroup
::
_mahConsumedUnavailable
);
}
else
{
_
battery
1
FactGroup
.
mahConsumed
()
->
setRawValue
(
bat_status
.
current_consumed
);
batteryFactGroup
.
mahConsumed
()
->
setRawValue
(
bat_status
.
current_consumed
);
}
int
cellCount
=
0
;
...
...
@@ -1325,15 +1327,15 @@ void Vehicle::_handleBatteryStatus(mavlink_message_t& message)
cellCount
=
-
1
;
}
_
battery
1
FactGroup
.
cellCount
()
->
setRawValue
(
cellCount
);
batteryFactGroup
.
cellCount
()
->
setRawValue
(
cellCount
);
//-- Time remaining in seconds (0 means not supported)
_
battery
1
FactGroup
.
timeRemaining
()
->
setRawValue
(
bat_status
.
time_remaining
);
batteryFactGroup
.
timeRemaining
()
->
setRawValue
(
bat_status
.
time_remaining
);
//-- Battery charge state (0 means not supported)
if
(
bat_status
.
charge_state
<=
MAV_BATTERY_CHARGE_STATE_UNHEALTHY
)
{
_
battery
1
FactGroup
.
chargeState
()
->
setRawValue
(
bat_status
.
charge_state
);
batteryFactGroup
.
chargeState
()
->
setRawValue
(
bat_status
.
charge_state
);
}
else
{
_
battery
1
FactGroup
.
chargeState
()
->
setRawValue
(
0
);
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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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