Skip to content

FW nav: fix WP JUMP target skipped by stale turn-smoothing flag#11648

Merged
b14ckyy merged 1 commit into
iNavFlight:release/9.1from
b14ckyy:wp-jump-fix
Jun 11, 2026
Merged

FW nav: fix WP JUMP target skipped by stale turn-smoothing flag#11648
b14ckyy merged 1 commit into
iNavFlight:release/9.1from
b14ckyy:wp-jump-fix

Conversation

@b14ckyy

@b14ckyy b14ckyy commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes a long-standing bug where a WP mission JUMP lands on target+1 instead of
the intended target waypoint. Intermittent in general, but ~100% reproducible
with nav_fw_wp_turn_smoothing = CUT, especially on specific mission layouts.

Root cause

isWaypointReached() reads the shared wpTurnSmoothingActive flag, which is owned
and recomputed by the FW position controller. A JUMP defers setup of its target
waypoint by one navigation loop; in that gap the controller re-arms the flag from
the previous waypoint's geometry. On the next loop the freshly activated target
inherits that stale flag and, in CUT mode, is marked "reached" on its very first
loop (and can cascade the following WP via the bearing-miss check). The active
waypoint counter advances past the target.

This matches blackbox evidence: the correct target WP is active for exactly one
50 Hz nav tick (~20 ms) before being skipped.

Fix

Reset wpTurnSmoothingActive when a new active waypoint is set, so a freshly
activated waypoint cannot inherit the previous waypoint's smoothing-reached state.
One line in calculateAndSetActiveWaypointToLocalPosition(), next to the existing
nextTurnAngle reset.

Turn smoothing itself is unchanged — the controller recomputes the flag every
position update from the new waypoint's geometry, so smoothed turns still work.

Testing

  • HITL on MATEKF765, nav_fw_wp_turn_smoothing = CUT.
  • Before: 100% skip of the JUMP target (jumped to target+1, penduluming between WPs).
  • After: JUMP executes correctly to the target; turns remain smoothed (no regression).

Notes

  • No parameter-group change → no PG version bump.
  • No settings.yaml change → no CLI docs regeneration needed.
  • Single-line, no API/MSP impact.

When a WP mission JUMP activated its target waypoint, isWaypointReached() could read a wpTurnSmoothingActive flag left over from the previous waypoint. The JUMP defers target setup by one navigation loop, and in that gap the FW position controller re-arms the flag from the previous waypoint's geometry. With nav_fw_wp_turn_smoothing = CUT this marks the jump target as reached on its first loop (and cascades the following WP via the bearing-miss check), so the mission jumps to target+1 instead of the target.

Reset wpTurnSmoothingActive when a new active waypoint is set so a freshly activated waypoint cannot inherit the previous waypoint's smoothing-reached state. Turn smoothing is otherwise unchanged: the FW controller recomputes the flag every position update from the new waypoint geometry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@b14ckyy b14ckyy added this to the 9.1 milestone Jun 11, 2026
@b14ckyy b14ckyy added the Bugfix label Jun 11, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions

Copy link
Copy Markdown

Test firmware build ready — commit fa91f98

Download firmware for PR #11648

238 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 Jun 11, 2026

Copy link
Copy Markdown
Collaborator Author

Intensively tested in SITL. One line variable reset. No break found. Will merge.

@b14ckyy b14ckyy merged commit 7514548 into iNavFlight:release/9.1 Jun 11, 2026
23 checks passed
@b14ckyy b14ckyy deleted the wp-jump-fix branch June 11, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant