Skip to content

feat(failure_detector): unite motorfailure offsets#26990

Merged
ttechnick merged 6 commits into
mainfrom
pr-unite-motorfailure-offset
May 7, 2026
Merged

feat(failure_detector): unite motorfailure offsets#26990
ttechnick merged 6 commits into
mainfrom
pr-unite-motorfailure-offset

Conversation

@ttechnick
Copy link
Copy Markdown
Member

Solved Problem

This PR simplifies the motor over/under-current detection introduced in #26262.

Currently, overcurrent and undercurrent thresholds must be configured separately. In practice, estimating even one of these reliably is already difficult, making the feature unnecessarily complex to use.


Solution

Instead of defining separate offsets for overcurrent and undercurrent, this PR introduces a single symmetric offset.

The new parameter MOTFAIL_OFF is applied symmetrically around the expected current-to-throttle relationship (MOTFAIL_C2T). This simplifies configuration while preserving the ability to detect motor failures.

Using the original image from @MaEtUgR:

Untitled design
  • Purple: Ideal current-to-throttle relationship (as defined by MOTFAIL_C2T)
  • Green: Symmetric offset band (defined by MOTFAIL_OFF)

Changelog Entry

For release notes:

Feature: Use Symmetric motorfailure offset limit
Removed param `MOTFAIL_LOW_OFF` & `MOTFAIL_HIGH_OFF` replaced by `MOTFAIL_OFF`

Issue

Both the current and proposed implementations assume:

  • 0 current at 0 throttle
  • a linear increase in current with throttle

However, as shown in the original analysis by @MaEtUgR, this assumption does not hold in practice. There is typically a dead zone, where motor command increases before significant current is drawn.

This behavior cannot be represented in the current model—neither before nor after this change. Despite this limitation, the simplification introduced by this PR is considered a worthwhile trade-off.


Alternatives

To address the limitation mentioned above, the following options come to my mind:

  1. Introduce a parameter to better describe the current curve (e.g., current at 50% throttle or a similar reference point).
  2. Estimate the throttle offset at which current starts flowing and use it as a fixed approximation.

Open to hear your thoughts 👐

@ttechnick ttechnick requested a review from MaEtUgR April 7, 2026 14:15
@ttechnick ttechnick self-assigned this Apr 7, 2026
@ttechnick
Copy link
Copy Markdown
Member Author

Fun fact:

The image shown above—originally used to advocate for separate low and high limits—actually supports using a symmetric limit.

The key issue is that the yellow and red “lines” should be parallel to the purple line, not the measured blue “ideal” line. This follows from the assumption of 0 current at 0 command, which defines the reference slope.

As a result:

  • The overcurrent deviation is largest at high motor commands
  • The undercurrent deviation is largest at low motor commands

In this specific example, both deviations appear to be very similar in magnitude, based on the image provided by @MaEtUgR.

😀

@ttechnick ttechnick requested a review from dakejahl April 7, 2026 14:20
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

No broken links found in changed files.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: -192 byte (-0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%     +55  [ = ]       0    .debug_abbrev
-0.0% -3.65Ki  [ = ]       0    .debug_info
-0.0%    -147  [ = ]       0    .debug_line
 -50.0%      -2  [ = ]       0    [Unmapped]
  -0.0%    -145  [ = ]       0    [section .debug_line]
-0.0%    -276  [ = ]       0    .debug_loclists
-0.0%     -33  [ = ]       0    .debug_rnglists
  [NEW]      +3  [ = ]       0    [Unmapped]
  -0.0%     -36  [ = ]       0    [section .debug_rnglists]
-0.0%    -975  [ = ]       0    .debug_str
-32.7% -3.81Ki  [ = ]       0    [Unmapped]
-0.0%    -192  -0.0%    -192    .text
  +3.4%     +12  +3.4%     +12    Commander::handleAutoDisarm()
  +1.5%      +8  +1.5%      +8    Commander::arm()
  [NEW]      +4  [NEW]      +4    CSWTCH.822
  +1.7%      +4  +1.7%      +4    Commander::landDetectorUpdate()
  +1.1%      +4  +1.1%      +4    Commander::~Commander()
  [DEL]      -4  [DEL]      -4    CSWTCH.824
  -1.1%      -4  -1.1%      -4    Commander::disarm()
  -1.0%      -4  -1.0%      -4    Commander::executeActionRequest()
  -5.3%      -4  -5.3%      -4    Commander::getPrearmState()
  -2.4%      -4  -2.4%      -4    Commander::handleCommandsFromModeExecutors()
  -1.6%      -4  -1.6%      -4    Commander::manualControlCheck()
  -2.2%      -4  -2.2%      -4    Commander::updateControlMode()
 -100.2%      -8 -100.2%      -8    [8 Others]
  -0.0%      -8  -0.0%      -8    px4::parameters
  -4.8%     -12  -4.8%     -12    Commander::checkForMissionUpdate()
 -11.1%     -12 -11.1%     -12    EscChecks::updateParamsImpl()
  -0.0%     -16  -0.0%     -16    [section .text]
  -7.4%     -20  -7.4%     -20    EscChecks::EscChecks()
  -0.0%     -32  -0.0%     -32    g_cromfs_image
  -7.2%     -40  -7.2%     -40    Commander::control_status_leds()
  -1.3%     -48  -1.3%     -48    Commander::handle_command()
-0.0% -9.00Ki  -0.0%    -192    TOTAL

px4_fmu-v6x [Total VM Diff: -248 byte (-0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%     +55  [ = ]       0    .debug_abbrev
-0.0% -3.60Ki  [ = ]       0    .debug_info
-0.0%    -181  [ = ]       0    .debug_line
-0.0%    -299  [ = ]       0    .debug_loclists
-0.0%     -42  [ = ]       0    .debug_rnglists
  [DEL]      -2  [ = ]       0    [Unmapped]
  -0.0%     -40  [ = ]       0    [section .debug_rnglists]
-0.0%    -975  [ = ]       0    .debug_str
+3.5%    +248  [ = ]       0    [Unmapped]
-0.0%    -248  -0.0%    -248    .text
  +3.4%     +12  +3.4%     +12    Commander::handleAutoDisarm()
  +1.5%      +8  +1.5%      +8    Commander::arm()
  [NEW]      +4  [NEW]      +4    CSWTCH.822
  +1.7%      +4  +1.7%      +4    Commander::landDetectorUpdate()
  +1.1%      +4  +1.1%      +4    Commander::~Commander()
  [DEL]      -4  [DEL]      -4    CSWTCH.824
  -1.1%      -4  -1.1%      -4    Commander::disarm()
  -1.0%      -4  -1.0%      -4    Commander::executeActionRequest()
  -5.3%      -4  -5.3%      -4    Commander::getPrearmState()
  -2.4%      -4  -2.4%      -4    Commander::handleCommandsFromModeExecutors()
  -1.6%      -4  -1.6%      -4    Commander::manualControlCheck()
  -2.2%      -4  -2.2%      -4    Commander::updateControlMode()
 -25.0%      -4 -25.0%      -4    ConstLayer::contains()
  -0.0%      -8  -0.0%      -8    px4::parameters
  -4.8%     -12  -4.8%     -12    Commander::checkForMissionUpdate()
 -11.1%     -12 -11.1%     -12    EscChecks::updateParamsImpl()
  -7.4%     -20  -7.4%     -20    EscChecks::EscChecks()
  -0.0%     -24  -0.0%     -24    [section .text]
  -7.2%     -40  -7.2%     -40    Commander::control_status_leds()
  -1.3%     -48  -1.3%     -48    Commander::handle_command()
 -100.1%     -84 -100.1%     -84    [29 Others]
-0.0% -5.00Ki  -0.0%    -248    TOTAL

Updated: 2026-04-07T14:23:20

Comment thread docs/en/config/safety.md Outdated
dakejahl
dakejahl previously approved these changes Apr 13, 2026
@ttechnick ttechnick marked this pull request as draft April 14, 2026 08:05
@ttechnick ttechnick marked this pull request as ready for review April 30, 2026 06:56
@github-actions github-actions Bot added kind:feature Request or change that adds new functionality. risk:safety-critical May affect arming, failsafe, control, navigation, or flight safety. scope:commander Arming, modes, failsafe, health checks, or vehicle state. scope:parameters Parameter definitions, metadata, migration, or defaults. labels Apr 30, 2026
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

💡 Commit messages could be improved

Not blocking, but these commit messages could use some cleanup.

Commit Message Suggestion
7c37755d2a Update docs/en/config/safety.md Missing conventional commit format (e.g. "feat(ekf2): add something")
587a936a1e docs: update docs/en/config/safety.md Missing conventional commit format (e.g. "feat(ekf2): add something")
32eea20833 docs: Update src/modules/commander/HealthAndArmingChecks/esc_check_params.yaml Missing conventional commit format (e.g. "feat(ekf2): add something")

See the commit message convention for details.


This comment will be automatically removed once the issues are resolved.

@ttechnick ttechnick requested a review from dakejahl April 30, 2026 06:57
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: -32 byte (-0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%     +16  +0.1%     +16    .ramfunc
    +1.7%      +4  +1.7%      +4    param_get
    +1.4%      +4  +1.4%      +4    param_get_default_value
     +33%      +4   +33%      +4    param_get_index
    +9.1%      +4  +9.1%      +4    param_get_system_default_value
  +0.0%     +55  [ = ]       0    .debug_abbrev
  +0.0%     +24  [ = ]       0    .debug_frame
  -0.0% -3.64Ki  [ = ]       0    .debug_info
  -0.0%     -37  [ = ]       0    .debug_line
    +300%      +3  [ = ]       0    [Unmapped]
    -0.0%     -40  [ = ]       0    [section .debug_line]
  -0.0%    -382  [ = ]       0    .debug_loclists
  -0.0%      -7  [ = ]       0    .debug_rnglists
    +100%      +1  [ = ]       0    [Unmapped]
    -0.0%      -8  [ = ]       0    [section .debug_rnglists]
  -0.0%    -975  [ = ]       0    .debug_str
  +0.3%     +32  [ = ]       0    [Unmapped]
  -0.0%     -48  -0.0%     -48    .text
   -99.0%     +74 -99.0%     +74    [32 Others]
    +4.7%     +20  +4.7%     +20    param_reset_specific
    +3.4%     +12  +3.4%     +12    Commander::handleAutoDisarm()
    +0.6%      +8  +0.6%      +8    Commander::Commander()
    +1.6%      +8  +1.6%      +8    Commander::arm()
    +2.6%      +8  +2.6%      +8    param_hash_check
    [NEW]      +4  [NEW]      +4    CSWTCH.803
    [DEL]      -4  [DEL]      -4    CSWTCH.805
    -1.9%      -4  -1.9%      -4    Commander::checkForMissionUpdate()
    -0.3%      -4  -0.3%      -4    Commander::dataLinkCheck()
    -1.0%      -4  -1.0%      -4    Commander::executeActionRequest()
    -5.3%      -4  -5.3%      -4    Commander::getPrearmState()
    -2.5%      -4  -2.5%      -4    Commander::handleCommandsFromModeExecutors()
   -10.7%      -6 -10.7%      -6    matrix::detail::wrap_floating<>()
    -0.0%      -8  -0.0%      -8    [section .text]
    -0.1%      -8  -0.1%      -8    px4::parameters
   -11.1%     -12 -11.1%     -12    EscChecks::updateParamsImpl()
    -7.4%     -20  -7.4%     -20    EscChecks::EscChecks()
    -0.0%     -20  -0.0%     -20    g_cromfs_image
    -7.2%     -40  -7.2%     -40    Commander::control_status_leds()
    -1.2%     -44  -1.2%     -44    Commander::handle_command()
  -0.0% -4.93Ki  -0.0%     -32    TOTAL

px4_fmu-v6x [Total VM Diff: -144 byte (-0.01 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +55  [ = ]       0    .debug_abbrev
  +0.0%      +4  [ = ]       0    .debug_frame
  -0.0% -3.59Ki  [ = ]       0    .debug_info
  -0.0%    -135  [ = ]       0    .debug_line
    +150%      +3  [ = ]       0    [Unmapped]
    -0.0%    -138  [ = ]       0    [section .debug_line]
  -0.0%    -365  [ = ]       0    .debug_loclists
  -0.0%     -20  [ = ]       0    .debug_rnglists
    [NEW]      +1  [ = ]       0    [Unmapped]
    -0.0%     -21  [ = ]       0    [section .debug_rnglists]
  -0.0%    -975  [ = ]       0    .debug_str
  +2.2%    +144  [ = ]       0    [Unmapped]
  -0.0%    -144  -0.0%    -144    .text
    +3.4%     +12  +3.4%     +12    Commander::handleAutoDisarm()
    +0.6%      +8  +0.6%      +8    Commander::Commander()
    +1.6%      +8  +1.6%      +8    Commander::arm()
   -100.0%      +6 -100.0%      +6    [11 Others]
    [NEW]      +4  [NEW]      +4    CSWTCH.803
    +1.7%      +4  +1.7%      +4    Commander::landDetectorUpdate()
    [DEL]      -4  [DEL]      -4    CSWTCH.805
    -1.9%      -4  -1.9%      -4    Commander::checkForMissionUpdate()
    -0.3%      -4  -0.3%      -4    Commander::dataLinkCheck()
    -1.0%      -4  -1.0%      -4    Commander::executeActionRequest()
    -5.3%      -4  -5.3%      -4    Commander::getPrearmState()
    -2.5%      -4  -2.5%      -4    Commander::handleCommandsFromModeExecutors()
    -1.6%      -4  -1.6%      -4    Commander::manualControlCheck()
    -2.2%      -4  -2.2%      -4    Commander::updateControlMode()
   -10.7%      -6 -10.7%      -6    matrix::detail::wrap_floating<>()
    -0.1%      -8  -0.1%      -8    px4::parameters
   -11.1%     -12 -11.1%     -12    EscChecks::updateParamsImpl()
    -7.4%     -20  -7.4%     -20    EscChecks::EscChecks()
    -0.0%     -24  -0.0%     -24    [section .text]
    -7.2%     -40  -7.2%     -40    Commander::control_status_leds()
    -1.2%     -44  -1.2%     -44    Commander::handle_command()
  -0.0% -4.99Ki  -0.0%    -144    TOTAL

Updated: 2026-05-07T12:24:00

@ttechnick ttechnick requested a review from sfuhrer April 30, 2026 07:06
@github-actions
Copy link
Copy Markdown
Contributor

No broken links found in changed files.

Copy link
Copy Markdown
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with simplifying the setup.

Comment thread docs/en/config/safety.md Outdated
Comment thread src/modules/commander/HealthAndArmingChecks/esc_check_params.yaml Outdated
ttechnick and others added 3 commits May 7, 2026 14:16
Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
…rams.yaml

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
@ttechnick ttechnick merged commit 6d0de73 into main May 7, 2026
82 checks passed
@ttechnick ttechnick deleted the pr-unite-motorfailure-offset branch May 7, 2026 15:20
RexGoliath1 pushed a commit to RexGoliath1/PX4-Autopilot that referenced this pull request May 8, 2026
* feat(failure_detector): unite motorfailure offsets

* docs: update docs/en/config/safety.md

* docs: Update src/modules/commander/HealthAndArmingChecks/esc_check_params.yaml

---------

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:feature Request or change that adds new functionality. risk:safety-critical May affect arming, failsafe, control, navigation, or flight safety. scope:commander Arming, modes, failsafe, health checks, or vehicle state. scope:docs scope:parameters Parameter definitions, metadata, migration, or defaults.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants