mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-28 05:14:06 +08:00
UAVCAN: Fixed CAN battery status
* Set battery.voltage_filtered_v and battery.current_filtered_a value * Fixed battery.remaining error when full_charge_capacity_wh is zero
This commit is contained in:
parent
e39e73cea1
commit
77a896a0dd
@ -69,12 +69,21 @@ UavcanBatteryBridge::battery_sub_cb(const uavcan::ReceivedDataStructure<uavcan::
|
||||
|
||||
battery.timestamp = hrt_absolute_time();
|
||||
battery.voltage_v = msg.voltage;
|
||||
// battery.voltage_filtered_v = msg.;
|
||||
battery.voltage_filtered_v = battery.voltage_v;
|
||||
battery.current_a = msg.current;
|
||||
// battery.current_filtered_a = msg.;
|
||||
battery.current_filtered_a = battery.current_a;
|
||||
// battery.average_current_a = msg.;
|
||||
// battery.discharged_mah = msg.;
|
||||
battery.remaining = msg.remaining_capacity_wh / msg.full_charge_capacity_wh; // between 0 and 1
|
||||
|
||||
// between 0 and 1
|
||||
if (msg.full_charge_capacity_wh > 0) {
|
||||
battery.remaining = msg.remaining_capacity_wh / msg.full_charge_capacity_wh;
|
||||
|
||||
} else {
|
||||
battery.remaining = 0;
|
||||
|
||||
}
|
||||
|
||||
// battery.scale = msg.; // Power scaling factor, >= 1, or -1 if unknown
|
||||
battery.temperature = msg.temperature;
|
||||
// battery.cell_count = msg.;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user