Skip to content

Fixed wing nav: fix extreme bank on the first turn after entering WP mode, bank ceiling follows nav_fw_bank_angle - #12271

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

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

Conversation

@b14ckyy

@b14ckyy b14ckyy commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Two related fixes for fixed wing navigation turns in 10.0. Both came out of tester reports of far too steep bank angles in navigation turns.

1. Extreme bank on the first turn after entering WP mode

Problem

When WP mode is entered while the aircraft points more than 30° away from the first waypoint, the turn coordinator plans a corner arc for that first turn. This was not intended: the rule that triggers it was added for loiter exits.

On entry the leg to the first waypoint starts at the aircraft itself. The planned circle therefore has its turn-in point behind the aircraft, and the aircraft starts well outside the circle. The arc control law reacts to that distance and to the heading error and demands far more bank than the turn needs.

From a tester's blackbox log (nav_fw_bank_angle = 45, max_angle_inclination_rll = 900, entry at 27 m/s ground speed with tailwind, 103° off the bearing to WP1):

  • the turn-in point was 95 m behind the aircraft
  • the roll command ran to the full 90° limit, the aircraft reached 73° of bank
  • the heading overshot the leg by about 60°

A higher entry ground speed makes it worse, because the turn radius and with it the initial distance to the circle grow with speed.

Fix

fwArcPlanCornerTurn() now checks where the turn-in point lies along the current course. If it is well behind the aircraft, no circle is engaged:

  • With waypoint tracking enabled (nav_fw_wp_tracking_accuracy > 0) the turn flies the existing leg capture, which is limited to nav_fw_bank_angle.
  • With waypoint tracking disabled there is no leg line to capture. The heading controller flies the turn straight at the waypoint, as it did before the turn coordinator handled this case. It is limited to nav_fw_bank_angle as well.

"Well behind" means more than 10 m or more than 0.2 turn radii, whichever is smaller. The tolerance keeps the arc for a regular corner that engages slightly late.

A reset after a pilot-flown phase now also clears the last navigation roll command. Before, the bank left over from an earlier navigation phase could seed the first command after entering WP mode.

Regular waypoint corners engage with the turn-in point ahead and are not affected. In the same log the 12 regular corners that engage an arc have the turn-in point 19 to 43 m ahead.

The same check also applies to the other cases that plan a corner arc with the turn-in point behind: loiter exits, and waypoints that are reached without turn anticipation. They now fly the bounded capture as well.

2. Bank ceiling on turn arcs and loiter follows nav_fw_bank_angle

Problem

On 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° or 90° for stick feel in ANGLE/HORIZON. 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.

The ceiling is cached and only recomputed when one of the two settings changes.

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

Behaviour changes

  • The first turn after entering WP mode, and loiter exits or waypoint changes with the turn-in point well behind the aircraft, are limited to nav_fw_bank_angle. They fly the leg capture with waypoint tracking enabled and the plain heading controller without it.
  • 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: 637/637 pass, including two new tests for the turn-in point check.
  • SITL, MATEKF722SE, MATEKF405 and MATEKF765 build without warnings.
  • Size against maintenance-10.x: MATEKF722SE +192 B flash, +8 B RAM. MATEKF405 +192 B flash, RAM unchanged.
  • The first-turn case was reconstructed from the tester's log (position, velocity and roll command), not reproduced in a simulator. The log has no turn debug channels.
  • Not flight tested yet. A HITL test in X-Plane (WP mode entry at a large heading error with tailwind, loiter exit, wind with a high 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 🟡 Medium 💥 3 capabilities

  • 3 affected capabilities within one bounded functional scope: fixed-wing GPS turn coordination.
  • Waypoint arcs and loiter circles share the same fixed-wing navigation turn law, bank-limit calculation, and output clamp; the changed ceiling is propagated to both end-to-end guidance behaviors rather than creating separate technical-layer capabilities.
  • This is a distinct user-visible operation within the same fixed-wing turn-coordination integration: selecting and executing the corner entry path.
  • The along-track helper is only a geometry hop in that end-to-end behavior.
  • The changed state synchronization controls the end-to-end transition from controller reset into navigation roll smoothing and arc handoff.
  • It is a separate transition operation within the same bounded fixed-wing navigation integration, not an independent storage or technical-layer capability.
Behavioral complexity 🟡 Medium 🧩 Coordinated invariants, Interacting branches

  • Before, coordinated arcs and loiter used the existing effective limit derived from the configured navigation bank and guard.
  • After, active arcs can exceed the planning target through a trigonometric lateral-acceleration reserve while loiter and arc output remain clamped by the effective limit.
  • The new correctness condition is that planning radius, live-speed bank, active-arc reserve, global inclination cap, and energy-guard reduction remain consistent across arc and loiter states; the cache must also refresh when either setting changes.
Potential damage 🟡 Medium 🩹 Recoverable

  • If the changed ceiling or its interaction with the energy guard is wrong, coordinated turns or loiters can use an unsuitable bank command and deviate from the planned path.
  • The global inclination cap still bounds the command.
  • Reverting restores future behavior; any flight-path deviation is not repaired retrospectively.
  • A code/configuration revert stops new incorrect guidance.
  • A flight already displaced from its intended path requires the normal navigation controller to reacquire the leg or loiter; no automatic repair of the prior trajectory is established.
Assessed commit 831b478
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) 🔗 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

Context sources
✅ Cross-repo context — repo relationships
  Explored: repo: iNavFlight/iNavFlight.github.io (sha: 7dc2681a) — View relationship
✅ Context preparation
  Commit messages: summarized; full text retained for this review
Review mode: Auto: ⚖️ Balanced: Flight-control behavior changes carry real risk but remain reviewable in one pass.

Grey Divider

Tip of the day
💡 Did you know, you can move or hide resolved findings to focus on what still needs action

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 831b478 ⚖️ Balanced

Results up to commit N/A


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


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

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 c032abc — commit 831b478

Target Flash Δ RAM Δ
MATEKF405 +216 B (+0.03%) CCM: ±0 B (±0.00%)
RAM: ±0 B (±0.00%)
MATEKF722 +224 B (+0.05%) ITCM_RAM: ±0 B (±0.00%)
RAM: +8 B (+0.01%)
TCM: ±0 B (±0.00%)
MATEKF765 +504 B (+0.07%) DTCM_RAM: ±0 B (±0.00%)
SRAM1: +4 B (+0.00%)
MATEKH743 +712 B (+0.09%) D2_RAM: ±0 B (±0.00%)
DTCM_RAM: ±0 B (±0.00%)
ITCM_RAM: -8 B (-0.05%)
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 f383800

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.

…raft

Entering WP mode more than 30 deg off the bearing to the first waypoint
planned a corner arc. The leg starts at the aircraft there, so the circle's
turn-in tangency lies behind it and the aircraft starts well outside the
circle. The arc law then demanded 80-95 deg of bank and the command ran to
the bank ceiling (tester log: 73 deg bank, 60 deg heading overshoot).

Such a turn now flies the bounded leg capture, limited to nav_fw_bank_angle.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@b14ckyy b14ckyy changed the title Fixed wing nav: bank ceiling on turn arcs and loiter follows nav_fw_bank_angle Fixed wing nav: fix extreme bank on the first turn after entering WP mode, bank ceiling follows nav_fw_bank_angle Dec 2, 2026
…e arc

A regular corner can engage marginally late; it should keep its arc.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@b14ckyy b14ckyy added the Bugfix label Dec 2, 2026
- Tolerance is the smaller of 10 m and 0.2 R: on a small radius 10 m behind
  already drives the arc law into the bank ceiling.
- Without WP tracking there is no leg line to capture; leave such a turn to
  the heading controller, which flies straight at the waypoint.
- A reset after a pilot-flown phase also clears the last nav roll command,
  so a stale bank no longer seeds the arc engage or the handback.

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

b14ckyy commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

/review

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 831b478

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