MAVLink mission transfer state machine#11716
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
6857a38 to
bbc962b
Compare
|
This is an AI-generated draft of things to check on — flagged for the author's judgment, not a formal review verdict. Reviewed this part in isolation ( 1. LAND-terminated missions may never report completion. This PR wires the new "waypoint reached" latch ( 2. 3. Legacy 4. Minor, bundled:
Aside, spanning the stack rather than specific to this PR: by #11717 there are now four independent |
bbc962b to
05e8ec5
Compare
Rewritten mission protocol replacing the old ad-hoc counters (absent since the modular split): owned transfers tracking initiating system, component and ingress port; upload retries and timeouts; one-item retransmission; final MISSION_ACK; out-of-sequence recovery; explicit cancellation; legacy MISSION_REQUEST answered with MISSION_ITEM_INT. Uploads are staged and committed only on success, QGC planned-home item 0 is skipped, modifier items (speed/delay/altitude) fold onto the correct INAV waypoint, and persistence failures restore the previous mission. Successful uploads and clears update nonvolatile storage. Adds 1 Hz MISSION_CURRENT, active-item download flags, and MISSION_ITEM_REACHED broadcast from a navigation-side reached latch. Includes the live SITL mission test rig (src/test/mavlink/missions) and routing compliance harness (src/test/mavlink/routing). Unit slice: 58/58 passing. Mission translation to INAV's MSP waypoint model is lossy; downloads are best-effort reconstruction, not canonical mission backups.
Standalone 8-check pass/fail rig against a self-started SITL with the known-good multiport serial layout: MSP on UART1, MAVLink receiver telemetry and RC override on UART2, GCS heartbeat, mission upload and readback, stream-rate and message-rate control on UART3. Previously lived only in the development workspace and was never committed.
NAV_STATE_WAYPOINT_RTH_LAND success maps straight to NAV_STATE_WAYPOINT_FINISHED, bypassing NAV_STATE_WAYPOINT_NEXT where the reached latch is normally set, and a mission LAND item that hands off to the fixed-wing autoland FSM terminates in NAV_STATE_FW_LANDING_FINISHED without touching either path. In both cases a mission terminated by NAV_WP_ACTION_LAND never fired MISSION_ITEM_REACHED for its final item and MISSION_CURRENT stayed NOT_STARTED after touchdown. Mark the item in the simple-landing success branch, and in FW_LANDING_FINISHED when the autoland was entered from a mission LAND item (fwLandState.landWp), using landState to guard the self-looping re-entry. The aborted-landing paths intentionally do not mark.
…ad encoder MISSION_CLEAR_ALL now denies a sender that is not the owning partner of an in-progress transfer, matching MISSION_COUNT and MISSION_REQUEST_LIST; previously any local-target sender could cancel another partner's transfer mid-flight. Downloads always answer MISSION_ITEM_INT (per MAVLink deprecation guidance for MISSION_REQUEST), so the float MISSION_ITEM response encoder was unreachable - removed, with a comment explaining why legacy requests get INT replies. Upload-side float support is unaffected.
Two ways the completion signal could be lost or misreported: - mavlinkSendPendingMissionItemReached() consumed the one-slot reached latch before checking for an active port. A shared MAVLink port that closes on disarm right after landing destroyed the final item's MISSION_ITEM_REACHED and left missionCompleted false. Check for a delivery target first; the latch stays pending until a port can send. - MISSION_CURRENT ranked WP-mode activity above completion, and NAV_STATE_WAYPOINT_FINISHED still maps to NAV_WP_MODE, so a landed vehicle reported ACTIVE until the pilot left WP mode. Completion now outranks activity, and missionCompleted is cleared on the WP-mode rising edge so a re-flown mission reports ACTIVE, not stale COMPLETE.
Covers the fixes in the previous commits: - MISSION_CURRENT completion outranks WP-mode activity and clears on a fresh WP-mode engagement - the reached latch survives cycles with no active MAVLink port - MISSION_CLEAR_ALL from a non-owning sender is denied and leaves the owner's transfer usable; the owning sender can still cancel its own
05e8ec5 to
42dbfc5
Compare
|
Thanks for the review — all four were looked at, and we also ran an independent second-opinion audit over the diff, which turned up a few more issues in the same areas. Everything below is pushed (this PR's unit suite grew to 62 tests, all green; SITL builds warnings-as-errors at every stack level; and the shipped 1. LAND completion — confirmed, and it went deeper than the finding. Fixed in 02d5b36. Marking in the 2. CLEAR_ALL ownership — confirmed, guarded in 603288a with the same shape as the COUNT / REQUEST_LIST denials, plus unit tests for both directions (non-owner denied with the owner's transfer left usable; owner can still cancel its own). One deliberate call worth flagging: ownership includes the ingress port, matching the existing guards, so a GCS that starts a transfer on port A and fails over to port B mid-transfer is denied until the transfer times out (~9 s upload worst case, 5 s download). Kept that for consistency; happy to relax all three guards together if you'd rather. 3. Legacy MISSION_REQUEST — dead branch deleted rather than commented (603288a): downloads always answer 4. Agreed on the refactor, deferred. Restructuring Separately: since 4/7 merged while this was in flight, one audit finding against the reconnect commit became a small follow-up instead — #11731. It moves heartbeat presence tracking from per-port to per-peer (a steady peer no longer masks a newly joining one; port failover registers), adds a per-port rate limit on arming snapshots (a slow-heartbeat peer can't resend on every beat), and drops the enable-transition snapshot in favour of the heartbeat signal alone. |
c214a12
into
iNavFlight:maintenance-10.x
Part 5/7 of the mavlink_multiport2 stack.
Rewritten MAVLink mission protocol, replacing the old ad-hoc counter-based implementation (absent since part 3/7) with an owned transfer state machine. The transfer design is adapted from Betaflight's GPLv3
mavlink_mission.c(commit87d4bd63) and reshaped for INAV's routed multi-port runtime.Transfer robustness
MAV_MISSION_OPERATION_CANCELLEDreturns the transfer to idle.MISSION_REQUESTdownloads are answered withMISSION_ITEM_INT, per the current MAVLink mission service.Translation (MAVLink ↔ INAV waypoints)
DO_CHANGE_SPEED→ pending leg speed;CONDITION_DELAY→ previous waypoint becomes/updatesPOSHOLD_TIME; altitude modifiers update the previous geographic waypoint while preserving INAV'sp3bitfield semantics (bit 0 = AMSL reference, bits 1–4 = user actions).NAV_WAYPOINT→ WAYPOINT or POSHOLD_TIME (hold time set),NAV_LOITER_TIME→ POSHOLD_TIME,NAV_LAND→ LAND (retaining supplied coordinates),DO_JUMP→ JUMP with remapped target.Persistence and reporting
MISSION_CURRENT(count, current item, execution mode, state); active-item flags on downloads.MISSION_ITEM_REACHEDbroadcast to all active MAVLink ports from a navigation-side reached latch (hold-time waypoints, altitude-enforced holds, and waypoint-next transitions).Caveats
Mission translation to INAV's MSP waypoint model is lossy (leg speed, LAND elevation, RTH land flag,
p3user-action bits). MAVLink mission downloads are best-effort reconstruction from the stored MSP waypoint list — not a canonical mission backup. Documented indocs/Mavlink.md(part 7/7).Testing
mavlink_unittest).src/test/mavlink/missions/, 8 scenario cases incl. planned-home skip, modifier folding, JUMP remap, failed-upload preservation, legacy download) and the routing compliance harness (src/test/mavlink/routing/).src/test/mavlink/sanity/): 8-check pass/fail rig covering MSP, MAVLink telemetry, RC override, GCS heartbeat, mission upload/readback, and stream/message-rate control.