Skip to content

fix(navigator): enforce NAV_MIN_LTR_ALT in MC braking loiter#27680

Open
saad1551 wants to merge 1 commit into
PX4:mainfrom
saad1551:saad1551/fix-mc-hold-min-ltr-alt
Open

fix(navigator): enforce NAV_MIN_LTR_ALT in MC braking loiter#27680
saad1551 wants to merge 1 commit into
PX4:mainfrom
saad1551:saad1551/fix-mc-hold-min-ltr-alt

Conversation

@saad1551

Copy link
Copy Markdown

Multicopter Hold/AUTO.LOITER silently ignores NAV_MIN_LTR_ALT when entered below the configured altitude, contradicting the documented behavior. The min-altitude clamp was added to MissionBlock::setLoiterItemFromCurrentPosition in 2022 but never applied to the sibling setLoiterItemFromCurrentPositionWithBraking, which is the multicopter Hold path selected at loiter.cpp:131 (vehicle_type == ROTARY_WING). Fixed-wing keeps working because it takes the non-braking branch.

This PR copies the same four-line clamp into the braking variant so the rotary-wing path matches.

Reproduced and verified in SITL (jMAVSim x500):

  • before fix: NAV_MIN_LTR_ALT=20, Hold entered at ~5 m → vehicle held at 5 m for 30 s.
  • after fix: same setup → vehicle climbs from 5 m to 20 m on Hold entry.

Local sanity:

  • make px4_sitl builds clean
  • make px4_fmu-v6x not built locally (no arm toolchain on this machine — CI covers it)

Fixes #27578

@github-actions github-actions Bot added kind:bug Something is broken or behaving incorrectly. scope:navigation Missions, RTL, geofence, takeoff, landing, or navigator behavior. labels Jun 17, 2026
@saad1551 saad1551 force-pushed the saad1551/fix-mc-hold-min-ltr-alt branch from 69ef25b to 344e6e3 Compare June 17, 2026 04:42
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 48 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +48  +0.0%     +48    .text
     +87%     +52   +87%     +52    MissionBlock::setLoiterItemFromCurrentPositionWithBraking()
    -3.2%      -4  -3.2%      -4    MissionBlock::setLoiterItemFromCurrentPosition()
  +0.0%     +55  [ = ]       0    .debug_abbrev
  +0.0%    +141  [ = ]       0    .debug_info
  +0.0%     +92  [ = ]       0    .debug_line
   -66.7%      -4  [ = ]       0    [Unmapped]
    +0.0%     +96  [ = ]       0    [section .debug_line]
  +0.0%     +58  [ = ]       0    .debug_loclists
  +0.0%     +10  [ = ]       0    .debug_rnglists
   -66.7%      -2  [ = ]       0    [Unmapped]
    +0.0%     +12  [ = ]       0    [section .debug_rnglists]
  -0.4%     -48  [ = ]       0    [Unmapped]
  +0.0%    +356  +0.0%     +48    TOTAL

px4_fmu-v6x [Total VM Diff: 48 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +48  +0.0%     +48    .text
     +87%     +52   +87%     +52    MissionBlock::setLoiterItemFromCurrentPositionWithBraking()
    -3.2%      -4  -3.2%      -4    MissionBlock::setLoiterItemFromCurrentPosition()
  +0.0%     +55  [ = ]       0    .debug_abbrev
  +0.0%    +141  [ = ]       0    .debug_info
  +0.0%    +100  [ = ]       0    .debug_line
    +133%      +4  [ = ]       0    [Unmapped]
    +0.0%     +96  [ = ]       0    [section .debug_line]
  +0.0%     +58  [ = ]       0    .debug_loclists
  +0.0%     +14  [ = ]       0    .debug_rnglists
    [NEW]      +2  [ = ]       0    [Unmapped]
    +0.0%     +12  [ = ]       0    [section .debug_rnglists]
  -0.6%     -48  [ = ]       0    [Unmapped]
  +0.0%    +368  +0.0%     +48    TOTAL

Updated: 2026-06-17T05:19:54

When a multicopter enters Hold (AUTO.LOITER) below NAV_MIN_LTR_ALT the
documented behavior is to first climb to that minimum altitude. The
clamp was added in 2022 to setLoiterItemFromCurrentPosition (the
fixed-wing branch) but never applied to the sibling
setLoiterItemFromCurrentPositionWithBraking, which is the rotary-wing
Hold path selected at loiter.cpp:131. As a result, multicopters
silently held at the entry altitude.

Apply the same min-altitude clamp in the braking variant so the
rotary-wing path matches the fixed-wing one.

Verified in SITL (jMAVSim x500): with NAV_MIN_LTR_ALT=20 and Hold
engaged from a 5m hover, the vehicle now climbs to 20m as documented.

Fixes PX4#27578

Signed-off-by: saad1551 <saad.ashraf.9094@gmail.com>
@saad1551 saad1551 force-pushed the saad1551/fix-mc-hold-min-ltr-alt branch from 344e6e3 to 4100aee Compare June 17, 2026 05:13
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. scope:navigation Missions, RTL, geofence, takeoff, landing, or navigator behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] NAV_MIN_LTR_ALT has no effect when entering Multicopter Hold below the configured altitude

1 participant