Background:
For context I am working on implementing DroneCAN protocol for a custom battery management device. I have included the libcanard C libraries into our STM32 Cube project GitHub - dronecan/libcanard · GitHub
I have our device connected to the Pixhawk6x (PX4 Pro V1.17.0) over CAN1, using Qgroundcontrol to view the battery status transmitted by PX4 to QGC over MAVLink.
Image 1: PX4 UAVCAN parameters
Image 2: PX4 Battery Calibration Parameters
Test:
Running our custom board (BMS) for 1 hour, with 1.29 A. Transmitting battery status messages to the pixhawk over MAVLink (TELEM1) and DroneCAN (CAN1).
Results:
The PX4 seems to calculate an incorrect value for consumed current.
Image 4: Test results - 1 hour operation
Discussion:
I have found some information on how the consumed current may be calculated for a power module in the docs >en>config>battery.md which indicates that voltage and load compensation are factors in the equation. However it is not clear if or how this works with a DroneCAN battery info message
I was also able to find a line where the discharged_mah is calculated in Line 114 src\drivers\cyphal\subscribers\udralbattery.hpp
However its not clear where the values for energy and nominal voltage are coming from.
Image 5: Calculated dischared mah
Questions:
Does anyone else have a similar issue? and does this seem to be a bug in the PX4 firmware or is it expected behavior and an error in my configuration of UAVCAN and battery calibration parameters? or a misunderstanding of how this is supposed to function?




