FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(control_allocation): fix erroneous NaN in unallocated thrust/torque by mbjd · Pull Request #28489 · PX4/PX4-Autopilot · GitHub

fix(control_allocation): fix erroneous NaN in unallocated thrust/torque - #28489

Merged
mbjd merged 1 commit into
mainfrom
pr-fix-unallocated-calculation
Sep 3, 2026
Merged

mbjd merged 1 commit into
mainfrom
pr-fix-unallocated-calculation

Conversation

mbjd commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Solved Problem

Commit af3cfae (#26530) introduced a semantic change in _actuator_sp:

  • prior to that commit it was always the output of the allocation algorithm, i.e. if 0 thrust was allocated the _actuator_sp was 0, and the NaN needed to stop some motors only entered the picture when populating the actuator_motors message in publish_actuator_controls
  • after that commit, we change _actuator_sp itself to be NaN when the corresponding motor should be stopped

This breaks consumers of _actuator_sp that expect there to be a finite, physical thrust in _actuator_sp. One such consumer is publish_control_allocator_status, which produces NaN if the _actuator_sp is NaN and is thus currently useless.

Solution

Convert NaNs back to zero in getAllocatedControl so all consumers of that work as before.

Test coverage

sihsim_standard_vtol, take off and then increase SIH_WIND_N to 10 m/s to cause unallocated thrust.

Before: unallocated thrust/torque are NaN

After: unallocated thrust/torque correctly logged

Commit af3cfae introduced a small semantic change in _actuator_sp:
 - prior to that commit it was always the output of the allocation
   algorithm, i.e. if 0 thrust was allocated the _actuator_sp was 0, and
   the NaN needed to stop some motors only entered the picture when
   populating the actuator_motors message in publish_actuator_controls
 - after that commit, we change _actuator_sp itself to be NaN when the
   corresponding motor should be stopped

This breaks consumers of _actuator_sp that expect there to be a finite,
physical thrust in _actuator_sp. One such consumer is
publish_control_allocator_status, which produces NaN if the _actuator_sp
is NaN and is thus currently useless.

Fix: Convert NaNs back to zero in getAllocatedControl so all consumers
of that work as before.
mbjd requested review from MaEtUgR and sfuhrer September 1, 2026 13:17
github-actions Bot added the kind:bug Something is broken or behaving incorrectly. label Sep 1, 2026

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 72 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +72  +0.0%     +72    .text
    [NEW]    +240  [NEW]    +240    ControlAllocation::getAllocatedControl()
   -31.6%    -168 -31.6%    -168    ControlAllocator::publish_control_allocator_status()
  +0.0%     +51  [ = ]       0    .debug_abbrev
  +0.0%      +8  [ = ]       0    .debug_aranges
  +0.0%     +36  [ = ]       0    .debug_frame
  +0.0%    +496  [ = ]       0    .debug_info
  +0.0%    +181  [ = ]       0    .debug_line
   -42.9%      -3  [ = ]       0    [Unmapped]
    +0.0%    +184  [ = ]       0    [section .debug_line]
  +0.0%    +155  [ = ]       0    .debug_loclists
  +0.0%     +17  [ = ]       0    .debug_rnglists
    [DEL]      -1  [ = ]       0    [Unmapped]
    +0.0%     +18  [ = ]       0    [section .debug_rnglists]
  -1.2%      -3  [ = ]       0    .shstrtab
  +0.0%     +47  [ = ]       0    .strtab
    [NEW]     +47  [ = ]       0    ControlAllocation::getAllocatedControl()
     +52%     +16  [ = ]       0    __nxsched_process_timer_veneer
   -38.1%     -16  [ = ]       0    __nxsem_freeholder_veneer
  +0.0%     +32  [ = ]       0    .symtab
    [NEW]     +16  [ = ]       0    ControlAllocation::getAllocatedControl()
    +0.1%     +16  [ = ]       0    [section .symtab]
     +33%     +16  [ = ]       0    ___ZN4uORB7Manager17get_device_masterEv_veneer
   -33.3%     -16  [ = ]       0    ____aeabi_l2f_veneer
     +50%     +16  [ = ]       0    __net_unlock_veneer
     +67%     +32  [ = ]       0    __nxsched_process_timer_veneer
   -40.0%     -32  [ = ]       0    __nxsem_freeholder_veneer
   -25.0%     -16  [ = ]       0    __up_dma_rxavailable_veneer
  -0.6%     -72  [ = ]       0    [Unmapped]
  +0.0%   +1020  +0.0%     +72    TOTAL

px4_fmu-v6x [Total VM Diff: 72 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +72  +0.0%     +72    .text
    [NEW]    +240  [NEW]    +240    ControlAllocation::getAllocatedControl()
   -31.6%    -168 -31.6%    -168    ControlAllocator::publish_control_allocator_status()
  +0.0%     +51  [ = ]       0    .debug_abbrev
  +0.0%      +8  [ = ]       0    .debug_aranges
  +0.0%     +36  [ = ]       0    .debug_frame
  +0.0%    +496  [ = ]       0    .debug_info
  +0.0%    +189  [ = ]       0    .debug_line
    [NEW]      +5  [ = ]       0    [Unmapped]
    +0.0%    +184  [ = ]       0    [section .debug_line]
  +0.0%    +155  [ = ]       0    .debug_loclists
  +0.0%     +17  [ = ]       0    .debug_rnglists
   -33.3%      -1  [ = ]       0    [Unmapped]
    +0.0%     +18  [ = ]       0    [section .debug_rnglists]
  -1.3%      -3  [ = ]       0    .shstrtab
  +0.0%     +47  [ = ]       0    .strtab
    [NEW]     +47  [ = ]       0    ControlAllocation::getAllocatedControl()
  +0.0%     +32  [ = ]       0    .symtab
    [NEW]     +16  [ = ]       0    ControlAllocation::getAllocatedControl()
    +0.1%     +16  [ = ]       0    [section .symtab]
  -1.0%     -72  [ = ]       0    [Unmapped]
  +0.0% +1.00Ki  +0.0%     +72    TOTAL

Updated: 2026-09-01T13:23:33

mbjd merged commit 6041c96 into main Sep 3, 2026
71 checks passed
mbjd deleted the pr-fix-unallocated-calculation branch September 3, 2026 10:26
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

Labels

kind:bug Something is broken or behaving incorrectly.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL