Fixed reporting of battery voltages in uORB

This commit is contained in:
Timothy Scott
2020-03-31 09:14:50 +02:00
committed by Julian Oes
parent d609639367
commit 14a61a6695
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -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
+12
View File
@@ -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;