fix(battery_status): keep analog filter state across parameter updates [1.18] - #28536
Merged
dakejahl merged 1 commit intoSep 4, 2026
Merged
Conversation
PX4#28452) * fix(battery_status): seed the analog filters from the first sample Nothing seeded the voltage and current filters, so after boot the filtered values converged from zero over the filter time constant, several seconds of falsely low battery readings. Seed each filter with its first sample. Assisted-by: Claude:claude-fable-5 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> * fix(battery_status): reseed the filters after they are enabled again A filter that was disabled and later enabled kept its seeded flag, so it resumed from the stale state it held before being disabled. Clear the flag when a filter is disabled so enabling it again restarts from the live measurement. Assisted-by: Claude:claude-fable-5 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> * fix(battery_status): keep the analog filter state across parameter updates updateParams replaced the voltage and current filters with freshly constructed ones, which zeroes their state. It runs on any parameter change anywhere in the system, so with filtering enabled every change restarted the filtered voltage and current from zero. The next published voltage then sits below the 2.1 V battery recognition threshold, which reports the battery as disconnected, and while armed the battery warning only ever escalates, so a single in flight param set could latch a critical battery failsafe and command RTL or land per COM_LOW_BAT_ACT. Recovery of the filtered value takes several time constants, tens of seconds at the BAT_V_FILT maximum of 5 s. Carry the previous state across the reconstruction once the filter has been seeded. Assisted-by: Claude:claude-fable-5 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> --------- Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> (cherry picked from commit 3b1517c)
Contributor
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 72 byte (0 %)]px4_fmu-v6x [Total VM Diff: 64 byte (0 %)]Updated: 2026-09-04T02:53:47 |
dakejahl
approved these changes
Sep 4, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of #28452 to
release/1.18, adapted for the branch.Any parameter change rebuilt the analog voltage and current filters from zero, so the next published voltage sat below the battery recognition threshold and the battery was reported disconnected. The filter on this branch still takes seconds, so the constructors and update calls stay in seconds. The seeding and reset logic is the same as on main.