When using CAN-based power monitors, I found that the battery filter sample interval was set to 20 ms, assuming ~50 Hz telemetry updates. As a result, when UAVCAN_SUB_BAT = 2 (filtering via the internal battery library), the reported battery current reacted very slowly to changes in actual current.
In reality, most CAN power monitors (e.g. Pomegranate Systems Power Monitor) provide updates at only 1–5 Hz.
Fixes issue PX4#25430
Co-authored-by: Lasse Järvelä <lasse.jarvela@iceye.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solved Problem
When using CAN-based power monitors, I found that the battery filter sample interval was set to 20 ms, assuming ~50 Hz telemetry updates. As a result, when UAVCAN_SUB_BAT = 2 (filtering via the internal battery library), the reported battery current reacted very slowly to changes in actual current.
In reality, most CAN power monitors (e.g. Pomegranate Systems Power Monitor) provide updates at only 1–5 Hz.
Fixes #25430
Solution
Increase SAMPLE_INTERVAL_US from 20 ms to 500 ms in src/drivers/uavcan/sensors/battery.hpp
This matches real-world CAN power monitor update rates and reduces slow averaging behavior
Changelog Entry
Test coverage
Hardware tested with Pomegranate Systems Power Monitor at 2 Hz update rate. Battery monitoring worked fine.