mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 15:28:53 +08:00
Fixed reporting of battery voltages in uORB
This commit is contained in:
committed by
Julian Oes
parent
d609639367
commit
14a61a6695
@@ -19,7 +19,7 @@ uint16 average_time_to_empty # predicted remaining battery capacity based on t
|
||||
uint16 serial_number # serial number of the battery pack
|
||||
uint8 id # ID number of a battery. Should be unique and consistent for the lifetime of a vehicle. 1-indexed.
|
||||
|
||||
float32[4] voltage_cell_v # Battery individual cell voltages
|
||||
float32[10] voltage_cell_v # Battery individual cell voltages
|
||||
float32 max_cell_voltage_delta # Max difference between individual cell voltages
|
||||
|
||||
bool is_powering_off # Power off event imminent indication, false if unknown
|
||||
|
||||
@@ -150,6 +150,18 @@ Battery::updateBatteryStatus(hrt_abstime timestamp, float voltage_v, float curre
|
||||
_battery_status.connected = connected;
|
||||
_battery_status.system_source = selected_source;
|
||||
_battery_status.priority = priority;
|
||||
|
||||
static constexpr int uorb_max_cells = sizeof(_battery_status.voltage_cell_v) / sizeof(
|
||||
_battery_status.voltage_cell_v[0]);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < _params.n_cells && i < uorb_max_cells; i++) {
|
||||
_battery_status.voltage_cell_v[i] = _voltage_filtered_v / _params.n_cells;
|
||||
}
|
||||
|
||||
for (; i < uorb_max_cells; i++) {
|
||||
_battery_status.voltage_cell_v[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
_battery_status.timestamp = timestamp;
|
||||
|
||||
Reference in New Issue
Block a user