| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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)
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 72 byte (0 %)] FILE SIZE VM SIZE
-------------- --------------
+0.0% +72 +0.0% +72 .text
+26% +40 +26% +40 AnalogBattery::updateParams()
+11% +32 +11% +32 AnalogBattery::updateBatteryStatusADC()
+1.8% +4 +1.8% +4 AnalogBattery::AnalogBattery()
+2.0% +4 +2.0% +4 Commander::updateParameters()
+4.8% +4 +4.8% +4 FlightTask
+44% +4 +44% +4 g_nullstring
-0.0% -4 -0.0% -4 g_cromfs_image
-0.0% -12 -0.0% -12 [section .text]
+0.0% +55 [ = ] 0 .debug_abbrev
+0.0% +333 [ = ] 0 .debug_info
+0.0% +188 [ = ] 0 .debug_line
[DEL] -3 [ = ] 0 [Unmapped]
+0.0% +191 [ = ] 0 [section .debug_line]
+0.0% +119 [ = ] 0 .debug_loclists
+0.0% +25 [ = ] 0 .debug_rnglists
[NEW] +1 [ = ] 0 [Unmapped]
+0.0% +24 [ = ] 0 [section .debug_rnglists]
+0.0% +60 [ = ] 0 .debug_str
-0.8% -72 [ = ] 0 [Unmapped]
+0.0% +780 +0.0% +72 TOTAL
FILE SIZE VM SIZE
-------------- --------------
+0.0% +64 +0.0% +64 .text
+26% +40 +26% +40 AnalogBattery::updateParams()
+11% +32 +11% +32 AnalogBattery::updateBatteryStatusADC()
+1.8% +4 +1.8% +4 AnalogBattery::AnalogBattery()
+2.0% +4 +2.0% +4 Commander::updateParameters()
+4.8% +4 +4.8% +4 FlightTask
-0.0% -4 -0.0% -4 g_cromfs_image
-0.0% -16 -0.0% -16 [section .text]
+0.0% +55 [ = ] 0 .debug_abbrev
+0.0% +333 [ = ] 0 .debug_info
+0.0% +196 [ = ] 0 .debug_line
[NEW] +5 [ = ] 0 [Unmapped]
+0.0% +191 [ = ] 0 [section .debug_line]
+0.0% +119 [ = ] 0 .debug_loclists
+0.0% +25 [ = ] 0 .debug_rnglists
+100% +1 [ = ] 0 [Unmapped]
+0.0% +24 [ = ] 0 [section .debug_rnglists]
+0.0% +60 [ = ] 0 .debug_str
-1.1% -64 [ = ] 0 [Unmapped]
+0.0% +788 +0.0% +64 TOTAL
Updated: 2026-09-04T02:53:47 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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.