Autopilot: in-flight waypoint capture on a switch - #15445
Conversation
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.
|
Do you want to test this code? You can flash it directly from the Betaflight App:
WARNING: It may be unstable. Use only for testing! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughAdds 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. ChangesFlight-plan waypoint capture
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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
blckmn
left a comment
There was a problem hiding this comment.
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.
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.
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:
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.waypointin the CLI shows what you dropped andsavepersists 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