Skip to content

feat(battery): enhance battery management with motor failure detectio… - #30029

Open
Claudio-Chies wants to merge 1 commit into
mainfrom
cch/mot_fail_bat_reset
Open

Claudio-Chies wants to merge 1 commit into
mainfrom
cch/mot_fail_bat_reset

Conversation

@Claudio-Chies

Copy link
Copy Markdown
Member

Summary

The time remaining estimate now reacts within seconds to load changes that its 50 s current average otherwise takes minutes to reflect: a motor failure in multicopter flight and a VTOL back-transition.

Problem

Time remaining divides the remaining charge by a current average with a 50 s time constant. After a motor failure on a hexa or octa the current can rise by of 25 % but the average keeps the pre-failure value, so time remaining stays optimistic exactly when the margin matters and when Return decides between home and a rally point. After a back-transition, the average still reflects the lower fixed-wing current.

Solution

On a newly failed motor (failure_detector_status) or a back-transition, the average is held for 2 s through the load spike, then follows the cumulative mean of the samples since, handing back to the regular filter once that window reaches its time constant. The average is never lowered below the one before the event (for a back-transition, below BAT_AVRG_CURRENT), so the reset can only make the estimate more conservative. Motor faults already present on the ground and flags that clear and return in flight don't trigger it.

@github-actions

Copy link
Copy Markdown
Contributor

🔎 Flash and RAM Analysis

Target Flash Δ Flash Total Static RAM Δ Static RAM Total
px4_fmu-v2 (F4) 🟡 +360 B (+0.04%) 97.76% +0 B (+0.00%) 10.29%
px4_fmu-v5x (F7) 🟡 +352 B (+0.02%) 96.14% +0 B (+0.00%) 21.95%
px4_fmu-v6x (H7) 🟡 +352 B (+0.02%) 97.63% +0 B (+0.00%) 10.63%
px4_io-v2 (F1) +0 B (+0.00%) 70.78% +0 B (+0.00%) 54.39%

px4_io-v2 firmware image, which an FMU flashes to its IO at boot: unchanged.

px4_fmu-v2 — Bloaty section/symbol breakdown
     VM SIZE    
 -------------- 
  +0.0%    +360    .text
    [NEW]    +336    Battery::updateCurrentAverage()
    [NEW]     +50    Battery::checkNewMotorFailure()
    [NEW]     +34    Battery::resetTimeRemainingEstimate()
    +3.9%     +28    Battery::Battery()
     +13%      +8    Battery::~Battery()
    -3.8%      -4    BaroChecks::BaroChecks()
   -26.4%     -92    Battery::computeRemainingTime()
  +0.0%    +360    TOTAL

px4_fmu-v5x — Bloaty section/symbol breakdown
     VM SIZE    
 -------------- 
  +0.0%    +352    .text
    [NEW]    +328    Battery::updateCurrentAverage()
    [NEW]     +52    Battery::checkNewMotorFailure()
    +3.9%     +28    Battery::Battery()
    [NEW]     +24    Battery::resetTimeRemainingEstimate()
     +13%      +8    Battery::~Battery()
    +0.0%      +4    [section .text]
    +1.3%      +2    INA228::checkConfigurationRotating()
    -3.8%      -2    INA228::registerWrite()
    -1.2%      -2    netlib_obtain_ipv4addr
   -20.0%      -2    nsh_system_ctty
   -25.6%     -88    Battery::computeRemainingTime()
  +0.0%    +352    TOTAL

px4_fmu-v6x — Bloaty section/symbol breakdown
     VM SIZE    
 -------------- 
  +0.0%    +352    .text
    [NEW]    +328    Battery::updateCurrentAverage()
    [NEW]     +52    Battery::checkNewMotorFailure()
    +3.9%     +28    Battery::Battery()
    [NEW]     +24    Battery::resetTimeRemainingEstimate()
     +13%      +8    Battery::~Battery()
    +0.0%      +4    [section .text]
    +1.3%      +2    INA228::checkConfigurationRotating()
    +2.9%      +2    up_saveusercontext
    -3.8%      -2    INA228::registerWrite()
    -0.9%      -2    exec_builtin
    -1.2%      -2    netlib_obtain_ipv4addr
   -20.0%      -2    nsh_system_ctty
   -25.6%     -88    Battery::computeRemainingTime()
  +0.0%    +352    TOTAL

px4_io-v2 — Bloaty section/symbol breakdown
     VM SIZE    
 -------------- 
  [ = ]       0    TOTAL

Updated: 2026-11-25T16:39:46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant