Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multicopter hover thrust estimator use vehicle_thrust_setpoint (work in stabilized/manual mode) #19633

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

dagar
Copy link
Member

@dagar dagar commented May 11, 2022

Update the hover thrust estimator to use vehicle_thrust_setpoint (body frame) rather than vehicle_local_position_setpoint thrust (NED). This allows it to work in stabilized mode.

https://logs.px4.io/plot_app?log=6df3713e-f511-4e2e-854d-8fc7ab98ec65

TODO:

  • review usability and safety in stabilized mode
  • battery scaling?

@dagar dagar changed the title multicopter hover thrust estimator use vehicle_thrust_setpoint (work in stabilized mode) multicopter hover thrust estimator use vehicle_thrust_setpoint (work in stabilized/manual mode) May 11, 2022
@dagar
Copy link
Member Author

dagar commented May 11, 2022

Should we go even lower level and use the allocated_thrust from control_allocator_status?

@bresch
Copy link
Member

bresch commented May 12, 2022

Should we go even lower level and use the allocated_thrust from control_allocator_status?

Il would improve the estimate on setups that are often saturating, yes. For the other ones, it shouldn't change anything.
Should we maybe change to that once we switch to the new control allocation system completely?

1 similar comment
@bresch
Copy link
Member

bresch commented May 12, 2022

Should we go even lower level and use the allocated_thrust from control_allocator_status?

Il would improve the estimate on setups that are often saturating, yes. For the other ones, it shouldn't change anything.
Should we maybe change to that once we switch to the new control allocation system completely?

@MaEtUgR
Copy link
Member

MaEtUgR commented Sep 18, 2024

Let's pick this up again. I've not seen the hover thrust estimator fail 👀

once we switch to the new control allocation system completely?

That's done 😃

@mahimayoga mahimayoga force-pushed the pr-mc_hover_thrust_stabilized branch from 0a90621 to 4d00981 Compare December 13, 2024 10:45
Copy link

github-actions bot commented Dec 16, 2024

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 744 byte (0.04 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +744  +0.0%    +744    .text
   +16%    +552   +16%    +552    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +2.7%    +180  +2.7%    +180    ../../src/modules/mc_att_control/mc_att_control_main.cpp
  +0.0%      +5  +0.0%      +5    [section .text]
  +0.0%      +4  +0.0%      +4    ../../src/modules/mc_autotune_attitude_control/mc_autotune_attitude_control.cpp
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.cpp
+0.0%    +196  [ = ]       0    .debug_abbrev
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
  +0.5%     +18  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
  +3.5%    +122  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
+0.0%     +56  [ = ]       0    .debug_frame
+0.1% +15.6Ki  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.6%    +662  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +22% +14.9Ki  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
+0.0% +1.63Ki  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +1.2%    +254  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +14% +1.40Ki  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +0.4%      +5  [ = ]       0    task/task_cancelpt.c
+0.1% +4.54Ki  [ = ]       0    .debug_loc
  +1.0%    +414  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +41% +4.13Ki  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
+0.1%    +770  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +0.8%     +88  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +15%    +688  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +3.1%      +2  [ = ]       0    task/task_cancelpt.c
+0.0%     +98  [ = ]       0    .debug_str
  +1.4%     +14  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/FlightTask/FlightTask.cpp
  +0.2%     +21  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
  +0.8%     +88  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/mc_pos_control/MulticopterPositionControl.cpp
  -0.2%     -30  [ = ]       0    ../../src/modules/mc_rate_control/MulticopterRateControl.cpp
-1.4%      -3  [ = ]       0    .shstrtab
+0.0%     +59  [ = ]       0    .strtab
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  +3.6%     +59  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +0.0%     +32  [ = ]       0    [section .strtab]
+0.0%     +96  [ = ]       0    .symtab
  -7.0%     -64  [ = ]       0    ../../src/lib/version/version.c
  +0.3%     +16  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  +2.2%     +32  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
  +6.8%     +96  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +0.0%     +16  [ = ]       0    [section .symtab]
-4.8%    -744  [ = ]       0    [Unmapped]
+0.0% +23.0Ki  +0.0%    +744    TOTAL

px4_fmu-v6x [Total VM Diff: 744 byte (0.04 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +744  +0.0%    +744    .text
   +16%    +552   +16%    +552    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +2.7%    +180  +2.7%    +180    ../../src/modules/mc_att_control/mc_att_control_main.cpp
  +0.0%      +5  +0.0%      +5    [section .text]
  +0.0%      +4  +0.0%      +4    ../../src/modules/mc_autotune_attitude_control/mc_autotune_attitude_control.cpp
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.cpp
+0.0%    +196  [ = ]       0    .debug_abbrev
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
  +0.5%     +18  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
  +3.5%    +122  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
+0.0%     +56  [ = ]       0    .debug_frame
+0.1% +15.6Ki  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.6%    +662  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +23% +14.9Ki  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
+0.0% +1.62Ki  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +1.2%    +254  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +14% +1.40Ki  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  -0.3%      -3  [ = ]       0    task/task_cancelpt.c
+0.1% +4.54Ki  [ = ]       0    .debug_loc
  +1.0%    +414  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +41% +4.13Ki  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
+0.1%    +766  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +0.8%     +88  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +15%    +688  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  -3.0%      -2  [ = ]       0    task/task_cancelpt.c
+0.0%     +98  [ = ]       0    .debug_str
  +1.4%     +14  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/FlightTask/FlightTask.cpp
  +0.2%     +21  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
  +0.8%     +88  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +0.0%      +5  [ = ]       0    ../../src/modules/mc_pos_control/MulticopterPositionControl.cpp
  -0.2%     -30  [ = ]       0    ../../src/modules/mc_rate_control/MulticopterRateControl.cpp
+0.5%      +1  [ = ]       0    .shstrtab
+0.0%     +59  [ = ]       0    .strtab
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  +3.6%     +59  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +0.0%     +32  [ = ]       0    [section .strtab]
+0.0%     +96  [ = ]       0    .symtab
  -7.0%     -64  [ = ]       0    ../../src/lib/version/version.c
  +0.3%     +16  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  +2.2%     +32  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
  +6.8%     +96  [ = ]       0    ../../src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp
  +0.0%     +16  [ = ]       0    [section .symtab]
-1.0%    -744  [ = ]       0    [Unmapped]
+0.0% +23.0Ki  +0.0%    +744    TOTAL

Updated: 2025-01-13T09:44:28

Tools/simulation/gz Outdated Show resolved Hide resolved
@mahimayoga
Copy link
Contributor

Tests in SITL:

  1. Switch from position mode to stabilized while hovering.
    image

  2. For a heavier vehicle, check if thrust setpoint tracks allocated thrust (stabilized mode).

image

@mahimayoga mahimayoga force-pushed the pr-mc_hover_thrust_stabilized branch 2 times, most recently from 94dd880 to e21605a Compare January 8, 2025 12:42
@mahimayoga mahimayoga marked this pull request as ready for review January 8, 2025 12:56
Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

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

Looks good, just some nitpicks.

src/modules/mc_att_control/mc_att_control.hpp Outdated Show resolved Hide resolved
src/modules/mc_att_control/mc_att_control.hpp Outdated Show resolved Hide resolved
src/modules/mc_att_control/mc_att_control.hpp Outdated Show resolved Hide resolved
src/modules/mc_att_control/mc_att_control.hpp Outdated Show resolved Hide resolved
src/modules/mc_att_control/mc_att_control_main.cpp Outdated Show resolved Hide resolved
@mahimayoga
Copy link
Contributor

Flight tested today. Thrust setpoint successfully set to hover thrust estimate after switching to stabilized mode without giving any stick input:

image

Use hover thrust estimate in stabilized mode to rescale stick inputs. Prevents vehicle from losing/gaining altitude when switching from position to stabilized mode.
Improves estimates on vehicles where thrust is often saturating.
@mahimayoga mahimayoga force-pushed the pr-mc_hover_thrust_stabilized branch from 1b317a8 to d3c5f45 Compare January 13, 2025 09:39
@mahimayoga mahimayoga requested a review from bresch January 13, 2025 09:41
@mahimayoga mahimayoga merged commit 879e0ea into main Jan 13, 2025
60 of 61 checks passed
@mahimayoga mahimayoga deleted the pr-mc_hover_thrust_stabilized branch January 13, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants