Skip to content

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Jan 30, 2024

Solved Problem

It's always hard to enable airmode on a product, project, ... because it can amplify any problems with rate control instability like wrong autopilot orientation, wrong motor directions, strong oscillations. That's also why it's disabled by default and should only be enabled after initial test flights. Also once airmode is enabled the minimum thrust can be lowered to zero because it's only there to keep rate control authority.

Solution

Instead of disabling airmode by default and having a minimum thrust commanded to the motors all the time I suggest to always have a limited airmode which can only have as much of an effect as the minimum thrust had before again configurable.

Changelog Entry

Feature: Limited airmode

Documentation: Needs to be updated: https://docs.px4.io/main/en/config_mc/pid_tuning_guide_multicopter.html#airmode-mixer-saturation

Test coverage

I got hung up in unit testing of corner cases. Unsaturation behaves slightly different than before. I'm convinced it's better but couldn't proof that yet.

@MaEtUgR MaEtUgR self-assigned this Jan 30, 2024
@MaEtUgR MaEtUgR changed the title Limited airmode [WIP] Limited airmode Jan 30, 2024
@dagar dagar self-requested a review January 30, 2024 20:47
@dagar
Copy link
Member

dagar commented Jan 30, 2024

Old mixers?

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Apr 22, 2025

Initial commits from this pr were merged already here: #21256
I'll update this pr to continue working on it.

@MaEtUgR MaEtUgR force-pushed the maetugr/limited-airmode branch from 3fa95d5 to ca786e8 Compare April 25, 2025 14:48
Copy link

github-actions bot commented Apr 25, 2025

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 216 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +216  +0.0%    +216    .text
  +9.0%    +128  +9.0%    +128    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  +0.0%     +85  +0.0%     +85    [section .text]
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.cpp
+0.0%    +195  [ = ]       0    .debug_abbrev
  +5.5%    +139  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
-0.0%     -32  [ = ]       0    .debug_aranges
 -16.7%     -24  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
-0.0%     -40  [ = ]       0    .debug_frame
+0.0% +2.88Ki  [ = ]       0    .debug_info
  +0.0%      +5  [ = ]       0    ../../src/lib/control_allocation/actuator_effectiveness/ActuatorEffectiveness.cpp
  +6.7% +2.75Ki  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.1%     +63  [ = ]       0    ../../src/modules/control_allocator/ControlAllocator.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessCustom.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessFixedWing.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopter.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopterCoaxial.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessMCTilt.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessMultirotor.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessRotors.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessRoverAckermann.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessStandardVTOL.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTailsitterVTOL.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTilts.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessUUV.cpp
-0.0%    -335  [ = ]       0    .debug_line
  -4.4%    -194  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  -0.1%      -4  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp
  -0.4%     -13  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessCustom.cpp
  -0.3%     -12  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessFixedWing.cpp
  -0.1%      -4  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopter.cpp
  -0.1%      -6  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopterCoaxial.cpp
  -0.3%     -12  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessMCTilt.cpp
  -0.3%      -8  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessMultirotor.cpp
  -0.1%      -4  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessRotors.cpp
  -0.3%     -12  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessStandardVTOL.cpp
  -0.3%     -12  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTailsitterVTOL.cpp
  -0.3%     -16  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.cpp
  -0.1%      -4  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTilts.cpp
  -0.2%      -8  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessUUV.cpp
  -0.1%      -1  [ = ]       0    task/task_cancelpt.c
+0.0%    +658  [ = ]       0    .debug_loc
   +16%    +658  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
+0.0%    +185  [ = ]       0    .debug_ranges
   +21%    +192  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +1.5%      +1  [ = ]       0    task/task_cancelpt.c
-0.0%    -187  [ = ]       0    .debug_str
 -21.3%    -187  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
-0.5%      -1  [ = ]       0    .shstrtab
-0.0%    -191  [ = ]       0    .strtab
 -24.6%    -191  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  +0.1%     +32  [ = ]       0    [section .strtab]
-0.0%     -64  [ = ]       0    .symtab
 -10.3%     -48  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -5.4%     -48  [ = ]       0    ../../src/lib/version/version.c
  -4.0%     -16  [ = ]       0    ../../src/modules/battery_status/analog_battery.cpp
  +0.3%     +16  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  +0.1%     +32  [ = ]       0    [section .symtab]
-0.3%    -216  [ = ]       0    [Unmapped]
+0.0% +3.06Ki  +0.0%    +216    TOTAL

px4_fmu-v6x [Total VM Diff: 192 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +192  +0.0%    +192    .text
  +7.7%    +124  +7.7%    +124    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  +0.0%     +72  +0.0%     +72    [section .text]
  -0.1%      -4  -0.1%      -4    ../../src/modules/ekf2/EKF/yaw_estimator/EKFGSF_yaw.cpp
+0.0%    +195  [ = ]       0    .debug_abbrev
  +5.5%    +139  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
-0.0%     -32  [ = ]       0    .debug_aranges
 -16.7%     -24  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
-0.0%     -40  [ = ]       0    .debug_frame
+0.0% +2.88Ki  [ = ]       0    .debug_info
  +0.0%      +5  [ = ]       0    ../../src/lib/control_allocation/actuator_effectiveness/ActuatorEffectiveness.cpp
  +6.7% +2.75Ki  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.1%     +63  [ = ]       0    ../../src/modules/control_allocator/ControlAllocator.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessCustom.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessFixedWing.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopter.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopterCoaxial.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessMCTilt.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessMultirotor.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessRotors.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessRoverAckermann.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessStandardVTOL.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTailsitterVTOL.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTilts.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessUUV.cpp
-0.0%    -335  [ = ]       0    .debug_line
  -4.4%    -194  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  -0.1%      -4  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp
  -0.4%     -13  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessCustom.cpp
  -0.3%     -12  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessFixedWing.cpp
  -0.1%      -4  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopter.cpp
  -0.1%      -6  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopterCoaxial.cpp
  -0.3%     -12  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessMCTilt.cpp
  -0.3%      -8  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessMultirotor.cpp
  -0.1%      -4  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessRotors.cpp
  -0.3%     -12  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessStandardVTOL.cpp
  -0.3%     -12  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTailsitterVTOL.cpp
  -0.3%     -16  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.cpp
  -0.1%      -4  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTilts.cpp
  -0.2%      -8  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessUUV.cpp
  -0.1%      -1  [ = ]       0    task/task_cancelpt.c
+0.0%    +658  [ = ]       0    .debug_loc
   +16%    +658  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
+0.0%    +185  [ = ]       0    .debug_ranges
   +21%    +192  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +1.6%      +1  [ = ]       0    task/task_cancelpt.c
-0.0%    -187  [ = ]       0    .debug_str
 -21.3%    -187  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
-0.5%      -1  [ = ]       0    .shstrtab
-0.0%    -191  [ = ]       0    .strtab
 -24.6%    -191  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  +0.0%     +32  [ = ]       0    [section .strtab]
-0.0%     -64  [ = ]       0    .symtab
 -10.7%     -48  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocationSequentialDesaturation.cpp
  -7.0%     -64  [ = ]       0    ../../src/lib/version/version.c
  -4.2%     -16  [ = ]       0    ../../src/modules/battery_status/analog_battery.cpp
  +0.3%     +16  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  +0.1%     +48  [ = ]       0    [section .symtab]
-0.3%    -192  [ = ]       0    [Unmapped]
+0.0% +3.06Ki  +0.0%    +192    TOTAL

Updated: 2025-05-05T13:50:51

@MaEtUgR MaEtUgR force-pushed the maetugr/limited-airmode branch from ca786e8 to 929581d Compare April 25, 2025 15:42
@hamishwillee
Copy link
Contributor

hamishwillee commented Apr 30, 2025

Documentation: Needs to be updated: https://docs.px4.io/main/en/config_mc/pid_tuning_guide_multicopter.html#airmode-mixer-saturation

Yes it does. I was thinking though perhaps we pull airmode into its own section of multicopter tuning. That might seem even more relevant if this is something that we expect people to read (now you made this change). At the moment most will not read that doc, because the assumption is that the autotuning does most of what people need.

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

Labels

None yet

Projects

Status: 📋 Backlog

Development

Successfully merging this pull request may close these issues.

4 participants