Sitelet https://github.com/betaflight/betaflight/pull/15445
Skip to content

Autopilot: in-flight waypoint capture on a switch - #15445

Merged
blckmn merged 4 commits into
betaflight:masterfrom
morrob955:feature/flight-plan-switch-drop
Jul 20, 2026
Merged

blckmn merged 4 commits into
betaflight:masterfrom
morrob955:feature/flight-plan-switch-drop

Conversation

@morrob955

@morrob955 morrob955 commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Following up on #15442 and the invite in the comments there - this brings the in-flight waypoint capture across onto the flight-plan stack.

Adds a WP CAPTURE box (permanentId 57). Tap it and the craft's position goes into the flight plan as a FLYBY waypoint. Hold it for 1.5s and the last waypoint is deleted. That's the whole interface - you fly the route once, tapping the switch where you want the corners, then flip AUTOPILOT and it flies what you drew.

Details that came out of flying this a lot on my fork:

  • The position is sampled at the press but committed on release, so a hold can mean delete without dropping a waypoint first, and the point you marked is where you pressed, not wherever you'd drifted to half a second later.
  • Hold-to-delete works on a full plan. Early version of mine gated the whole gesture on there being room to add, which silently broke delete at max waypoints - pilots read that as "delete is broken". Capacity is only checked at commit.
  • Every gesture gets a cue on the OSD warnings line: WP3 SET, WP2 DELETED, WP FULL. The delete confirmation matters more than you'd think: without it, a pilot who releases the hold slightly early gets a new waypoint and has no idea.
  • Edits write to the live PG plan, so waypoint in the CLI shows what you dropped and save persists the route. Nothing touches the plan while the executor is flying it, and the rxfail guard keeps aux substitution from ghost-editing during signal loss.

9 unit tests covering the gesture state machine (sample-at-press, hold-delete at capacity, mid-gesture engage, cue expiry). Built F405 with and without USE_FLIGHT_PLAN.

The gesture and semantics are lifted from the field-tested capture switch in #15442.

Summary by CodeRabbit

  • New Features
    • Added an in-flight waypoint capture mode for the flight planner (“WP CAPTURE”).
    • Tap the capture switch to save the current GPS position as a waypoint; holding deletes the last waypoint.
    • Added OSD feedback for waypoint set, deletion, and “WP FULL” when capacity is reached.
    • Capture processing is frozen when RX flight channels are invalid to prevent unintended “ghost” changes.
  • Bug Fixes
    • Improved safety of the capture gesture during signal loss/invalid channel conditions.
  • Tests
    • Added unit tests covering tap/hold/release behavior, GPS availability, mission state, and OSD cue expiry.

Adds a WP CAPTURE box (permanentId 57): a tap appends the craft's position
to the flight plan as a FLYBY waypoint - sampled at the press, committed on
release - and holding for 1.5 s deletes the last waypoint, which also works
on a full plan. Edits go to the live PG plan, so the CLI waypoint command
sees them and save persists them; the executor is never edited while it is
flying the plan. Transient OSD cues (WPn SET / WPn DELETED / WP FULL) on
the warnings line confirm each gesture.

The gesture and its semantics are lifted from the field-tested capture
switch in betaflight#15442.
@github-actions

Copy link
Copy Markdown

Do you want to test this code? You can flash it directly from the Betaflight App:

  • Simply put #15445 (this pull request number) in the Select commit field in the Firmware Flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: acc43b3b-62c5-45c1-a2e8-2fae4cdd8449

📥 Commits

Reviewing files that changed from the base of the PR and between adc909b and 4e5c718.

📒 Files selected for processing (4)
  • src/main/fc/core.c
  • src/main/flight/flight_plan_capture.c
  • src/main/flight/flight_plan_capture.h
  • src/test/unit/flight_plan_capture_unittest.cc
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/main/flight/flight_plan_capture.h
  • src/main/fc/core.c
  • src/main/flight/flight_plan_capture.c
  • src/test/unit/flight_plan_capture_unittest.cc

Walkthrough

Adds a WP CAPTURE RC mode and flight-plan capture module for multirotors. Short presses append GPS-sampled waypoints, long presses delete the last waypoint, and transient OSD messages report results. Runtime wiring, MSP exposure, build integration, channel-validity gating, and unit tests are included.

Changes

Flight-plan waypoint capture

Layer / File(s) Summary
Capture contract and runtime wiring
src/main/flight/flight_plan_capture.h, src/main/fc/rc_modes.h, src/main/msp/msp_box.c, mk/source.mk, src/main/fc/core.c
Defines the capture API and BOXWPCAPTURE, exposes the box through MSP, adds the module to the build, and invokes capture updates with switch and channel-validity state.
Capture behavior and OSD feedback
src/main/flight/flight_plan_capture.c, src/main/osd/osd_warnings.c
Implements waypoint sampling, hold-to-delete behavior, channel-validity, mission and GPS gating, capacity handling, message expiration, and informational OSD rendering.
Capture test coverage
src/test/Makefile, src/test/unit/flight_plan_capture_unittest.cc
Adds unit-test build wiring and tests for capture gestures, waypoint limits, GPS and mission states, signal loss, repeated taps, and OSD expiration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RCInput
  participant FlightControl
  participant CaptureModule
  participant FlightPlan
  participant OSDWarning
  RCInput->>FlightControl: Activate WP CAPTURE and provide channel validity
  FlightControl->>CaptureModule: Update time, switch state, and channel validity
  CaptureModule->>FlightPlan: Sample, append, or delete waypoint
  OSDWarning->>CaptureModule: Request capture message
  CaptureModule-->>OSDWarning: Return transient status text
Loading

Suggested reviewers: haslinghuis, nerdcopter

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding in-flight waypoint capture on a switch.
Description check ✅ Passed The description clearly explains the feature, behavior, tests, and build coverage, matching the PR's scope.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@blckmn blckmn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clean and the gesture semantics read well. Sampling at press and committing at release is the right call.

One thing to sanity check, non-blocking: the valid-channels guard is ANDed into switchActive, so if channels flick invalid mid-hold the state machine sees a release. A hold that was heading for delete can commit the pending waypoint instead, which is the opposite of the ghost-edit protection you're after. Edge case only, and the sampled point is real, so happy to merge either way.

Comment thread src/main/fc/core.c Outdated

@haslinghuis haslinghuis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

approving for workflow

DrunkedSlug and others added 2 commits July 19, 2026 19:16
blckmn's review catch: rxAreFlightChannelsValid() was ANDed into the switch
state, so a mid-hold link drop looked like a release - a hold heading for a
delete would commit the pending waypoint instead, the opposite of the intended
ghost-edit protection. Pass channel validity separately and freeze the gesture
(hold clock and sampled position both held) while channels are invalid, so it
resumes cleanly when the link is back. Regression test added.
@blckmn
blckmn merged commit 92f0457 into betaflight:master Jul 20, 2026
53 checks passed
@github-project-automation github-project-automation Bot moved this from Bugfix to Done in 2026.6.0 Jul 20, 2026
gwlim pushed a commit to gwlim/betaflight that referenced this pull request Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants