Skip to content

Fixed wing nav: bank ceiling on turn arcs and loiter follows nav_fw_bank_angle - #12271

Open
b14ckyy wants to merge 2 commits into
iNavFlight:maintenance-10.xfrom
b14ckyy:fw-nav-bank-headroom
Open

b14ckyy wants to merge 2 commits into
iNavFlight:maintenance-10.xfrom
b14ckyy:fw-nav-bank-headroom

Conversation

@b14ckyy

@b14ckyy b14ckyy commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

On coordinated turn arcs and the loiter circle the navigation may bank beyond nav_fw_bank_angle to hold its radius in wind. The hard ceiling for that was max_angle_inclination_rll.

Some pilots raise max_angle_inclination_rll to 85° for stick feel in ANGLE/HORIZON. Two testers reported that in windy conditions the aircraft then banks far too steeply in navigation turns.

Change

The ceiling now follows the navigation bank angle with a fixed reserve of 30 % more lateral acceleration, and is still capped by max_angle_inclination_rll:

ceiling = min( atan(1.3 · tan(nav_fw_bank_angle)), max_angle_inclination_rll )
nav_fw_bank_angle Ceiling (inclination limit 45°) Ceiling (inclination limit 85°)
20° 25.3° 25.3°
35° 42.3° 42.3°
45° 45.0° 52.4°
60° 45.0° 66.1°

This applies to waypoint turn arcs (including the landing approach) and the established loiter circle. Navigation without an active arc is unchanged; it was already limited to nav_fw_bank_angle.

This is meant as a simple fixed rule for 10.0. A better scheme can follow in 10.1.

Behaviour change

  • With the defaults (35° / 45°) the arc ceiling drops from 45° to 42.3°.
  • Setups with a high max_angle_inclination_rll lose bank reserve on arcs. In strong wind the turn widens instead of steepening.

No new setting, no parameter group change. The nav_fw_bank_angle description and docs/Settings.md are updated.

The user documentation follows in iNavFlight/iNavFlight.github.io#38.

Testing

  • Unit tests: 635/635 pass.
  • SITL, MATEKF722SE, MATEKF405, MATEKH743 and MATEKF765 build without warnings.
  • Size: MATEKF722SE +64 B flash, +8 B RAM. MATEKF405 +320 B flash, RAM unchanged.
  • The ceiling is cached and only recomputed when one of the two settings changes, so the PID loop does no extra trigonometry.
  • The ceiling values above were computed with the firmware's approximation functions; they differ from the exact result by less than 0.0001°.
  • Not flight tested yet. A HITL test in X-Plane with wind and an 85° inclination limit is still to come.

🤖 Generated with Claude Code

The arc controller could bank up to max_angle_inclination_rll to hold its
radius in wind. With that limit raised to 85 deg for stick feel, windy
coordinated turns and loiters banked far beyond the navigation bank.

The ceiling is now nav_fw_bank_angle plus a fixed reserve of 30 % more
lateral acceleration, still capped by max_angle_inclination_rll. With the
defaults (35 / 45 deg) it drops from 45 to 42.3 deg.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Bank ceiling on nav turn arcs follows nav_fw_bank_angle

🐞 Bug fix ✨ Enhancement 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Turn arc and loiter bank ceiling now derives from nav_fw_bank_angle, not
 max_angle_inclination_rll.
• Ceiling is atan(1.3·tan(bank)), still capped by max_angle_inclination_rll; defaults drop 45° to
 42.3°.
• Setting description and docs/Settings.md updated; no new setting or parameter group change.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The changed ceiling is consumed by the fixed-wing navigation controller to constrain waypoint-turn, loiter, and arc commands that together produce the aircraft's GPS-assisted turn and loiter behavior.
  • These are related control surfaces within one bounded navigation integration, not independent capabilities.
Sources

src/main/navigation/navigation_fixedwing.c[532-538]

    const uint8_t bank = navConfig()->fw.max_bank_angle;
    const int16_t inclination = pidProfile()->max_angle_inclination[FD_ROLL];
    // Called every PID loop: redo the trig only when a setting changes
    if (bank != cachedBank || inclination != cachedInclination) {
        const float bankRad = DEGREES_TO_RADIANS((float)bank);
        const float reserveDeg = RADIANS_TO_DEGREES(atan2_approx(NAV_FW_BANK_RESERVE_FACTOR * sin_approx(bankRad), cos_approx(bankRad)));
        ceilingDeg = MIN(reserveDeg, (float)inclination / 10.0f);
Behavioral complexity 🟡 Medium 🧩 Interacting branches, Data transformation

  • Before: the navigation ceiling directly used max_angle_inclination_rll.
  • After: it derives a reserve bank from nav_fw_bank_angle using trigonometric lateral-acceleration conversion, caps it by max_angle_inclination_rll, and combines it with the energy guard.
  • New correctness conditions are that planning remains based on the configured target while active arcs and loiter may use the reserve, and that guard reductions never exceed the derived ceiling.
  • The transformation itself is bounded and cached when settings change.
Sources

src/main/navigation/navigation_fixedwing.c[532-538]

    const uint8_t bank = navConfig()->fw.max_bank_angle;
    const int16_t inclination = pidProfile()->max_angle_inclination[FD_ROLL];
    // Called every PID loop: redo the trig only when a setting changes
    if (bank != cachedBank || inclination != cachedInclination) {
        const float bankRad = DEGREES_TO_RADIANS((float)bank);
        const float reserveDeg = RADIANS_TO_DEGREES(atan2_approx(NAV_FW_BANK_RESERVE_FACTOR * sin_approx(bankRad), cos_approx(bankRad)));
        ceilingDeg = MIN(reserveDeg, (float)inclination / 10.0f);
Potential damage 🟡 Medium 🩹 Recoverable

  • If the calculated ceiling is wrong, the aircraft may use an overly tight or overly wide bank-limited turn or loiter path.
  • The ceiling remains capped by max_angle_inclination_rll and the energy guard can reduce it.
  • Reverting restores the prior limiting rule, but any path deviation already flown is not retroactively undone.
  • Code rollback restores the control calculation.
  • Already-executed path deviations require the vehicle to resume navigation or be manually corrected; no persistent state repair or external compensation is indicated.
Sources

src/main/navigation/navigation_fixedwing.c[532-538]

    const uint8_t bank = navConfig()->fw.max_bank_angle;
    const int16_t inclination = pidProfile()->max_angle_inclination[FD_ROLL];
    // Called every PID loop: redo the trig only when a setting changes
    if (bank != cachedBank || inclination != cachedInclination) {
        const float bankRad = DEGREES_TO_RADIANS((float)bank);
        const float reserveDeg = RADIANS_TO_DEGREES(atan2_approx(NAV_FW_BANK_RESERVE_FACTOR * sin_approx(bankRad), cos_approx(bankRad)));
        ceilingDeg = MIN(reserveDeg, (float)inclination / 10.0f);
Assessed commit cf63582
Diagram

graph TD
  A["nav_fw_bank_angle"] --> B["Bank ceiling fn"] --> D["Effective bank limit"] --> E["Arc / loiter bank cmd"]
  C["max_angle_inclination_rll"] --> B
  F["Energy guard"] --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Dedicated nav bank-ceiling setting
  • ➕ Pilots can tune wind reserve explicitly
  • ➕ Decouples nav limits from stick-feel config
  • ➖ Adds a setting and parameter group change
  • ➖ More configuration surface for a bug fix
2. Hard clamp at nav_fw_bank_angle with no reserve
  • ➕ Simplest rule, bank never exceeds the target
  • ➕ No math approximation needed
  • ➖ Wind cannot be corrected on arcs, so the turn widens more than necessary
  • ➖ Loses the radius-holding behaviour the reserve was added for

Recommendation: The fixed-rule approach fits the 10.0 scope: it needs no new setting, keeps the inclination limit as a pure stick-feel cap, and removes the wind-induced steepening. Keep it for 10.0 and treat the 30% reserve as a tunable constant. Consider the alternatives below for 10.1, or if the reserve proves too loose or tight in HITL.

Files changed (4) +11 / -8

Bug fix (1) +6 / -3
navigation_fixedwing.cDerive arc/loiter bank ceiling from nav_fw_bank_angle +6/-3

Derive arc/loiter bank ceiling from nav_fw_bank_angle

• Adds NAV_FW_BANK_RESERVE_FACTOR (1.3). getFwBankCeilingDeg now computes atan(1.3·tan(nav_fw_bank_angle)) and takes the minimum with max_angle_inclination_rll. Comments are updated to say the inclination limit is a stick-feel limit, not a nav bank source.

src/main/navigation/navigation_fixedwing.c

Documentation (3) +5 / -5
settings.yamlUpdate nav_fw_bank_angle description +1/-1

Update nav_fw_bank_angle description

• Description now says wind corrections on arcs and loiter may exceed the target by a 30% lateral-accel reserve, capped by max_angle_inclination_rll. The settings doc is generated from this text.

src/main/fc/settings.yaml

Settings.mdSync Settings.md with new bank ceiling wording +1/-1

Sync Settings.md with new bank ceiling wording

• Mirrors the settings.yaml description change, with the 35° to about 42° example. Keeps the generated reference consistent with the firmware.

docs/Settings.md

fw-turn-debugging.mdUpdate debug channel 6 bank ceiling description +3/-3

Update debug channel 6 bank ceiling description

• Channel 6 now describes the derived ceiling instead of max_angle_inclination_rll. The saturation note is reworded so channel 6 is read in whole degrees. Reviewers should check this wording reads cleanly.

docs/development/fw-turn-debugging.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (1) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Pilots misjudge navigation bank ceiling 🔗 Cross-repo conflict ≡ Correctness
Description
getFwBankCeilingDeg() now limits arc and loiter corrections to a 30% lateral-acceleration reserve
above nav_fw_bank_angle, but the iNavFlight.github.io guidance still describes
max_angle_inclination_rll as the limit available for those corrections. With a 35° navigation bank
setting and an 85° inclination limit, pilots reading the website are led to expect substantially
more wind-correction authority than the new approximately 42° ceiling allows.
Code

src/main/navigation/navigation_fixedwing.c[R529-530]

+    const float reserveDeg = RADIANS_TO_DEGREES(atan2_approx(NAV_FW_BANK_RESERVE_FACTOR * sin_approx(bankRad), cos_approx(bankRad)));
+    return MIN(reserveDeg, (float)pidProfile()->max_angle_inclination[FD_ROLL] / 10.0f);
Evidence
The new firmware calculation takes the minimum of the reserve-based limit and the inclination limit;
both current website pages still present the inclination limit alone as the correction ceiling.

inav -> iNavFlight.github.io
src/main/navigation/navigation_fixedwing.c[525-530]
External repo: iNavFlight/iNavFlight.github.io, docs/06-advanced-features/fixed-wing-waypoint-turns.mdx [168-178]
External repo: iNavFlight/iNavFlight.github.io, docs/05-core-features/flight-modes-navigation.mdx [91]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The firmware's arc and loiter bank ceiling now depends on `nav_fw_bank_angle`, while the website still presents `max_angle_inclination_rll` as the available correction limit.
## Fix Focus Areas
- src/main/navigation/navigation_fixedwing.c[525-530]
- /cross_repos/iNavFlight.github.io/docs/06-advanced-features/fixed-wing-waypoint-turns.mdx[168-178]
- /cross_repos/iNavFlight.github.io/docs/05-core-features/flight-modes-navigation.mdx[91-91]
## Recommended Fix
Coordinate a website documentation change for INAV 10.0 that explains the 30% lateral-acceleration reserve, capped by `max_angle_inclination_rll`, and notes that turns can widen when the reserve is exhausted. Keep versioned guidance for earlier firmware unchanged.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can see how risky a PR is at a glance with blast radius labels

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@b14ckyy b14ckyy added this to the 10.0 milestone Dec 2, 2026
The ceiling is read on every PID loop; its trig only depends on two settings.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

RAM / Flash usage vs. base commit bb4dd36 — commit cf63582

Target Flash Δ RAM Δ
MATEKF405 +312 B (+0.04%) CCM: ±0 B (±0.00%)
RAM: ±0 B (±0.00%)
MATEKF722 +104 B (+0.02%) ITCM_RAM: ±0 B (±0.00%)
RAM: +8 B (+0.01%)
TCM: ±0 B (±0.00%)
MATEKF765 +432 B (+0.06%) DTCM_RAM: ±0 B (±0.00%)
SRAM1: +16 B (+0.01%)
MATEKH743 +432 B (+0.05%) D2_RAM: ±0 B (±0.00%)
DTCM_RAM: ±0 B (±0.00%)
ITCM_RAM: ±0 B (±0.00%)
RAM: +32 B (+0.02%)

See RAM/flash optimization guide for techniques to reduce usage.

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Test firmware build ready — commit cf63582

Download firmware for PR #12271

252 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

@b14ckyy

b14ckyy commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Re the Qodo cross-repo finding: the two documentation pages are updated in iNavFlight/iNavFlight.github.io#38.

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.

1 participant