Use MAV_CMD_DO_CHANGE_ALTITUDE and MAV_CMD_DO_REPOSITION for moving vehicle - #3724
peterbarker wants to merge 3 commits into
Conversation
|
Tested basic do-repos and changealt using github build products. |
|
|
||
| [Obsolete] | ||
| public void setNewWPAlt(Locationwp gotohere) | ||
| public void setNewAlt(float new_relhome_alt_m) |
There was a problem hiding this comment.
Are you concerned with external callers to this method breaking?
I believe I changed all in-tree callers to pass in the required altitude rather than the Locationwp object.
The new method of changing the altitude - MAV_CMD_DO_CHANGE_ALTITUDE doesn't deal with waypoints at all - it's just an altitude. The old method did require the Locationwp as it's calling setWP (leaving lat/lng at and setting the magic value "3" to get the weird behaviour we are trying to eliminate in ArduPilot).
Previous review (2026-09-03)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Full report: https://uav.tridgell.net/DevCallReviews/2026_09_03/devcall_pr_reviews.html#prMissionPlanner-3724 Reviewed at head
|
a0db1d7 to
6b558b1
Compare
Previous review (2026-09-16)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Re-reviewed at head All three findings from my previous comment are resolved. One new regression turned up in their place, so: REQUEST CHANGES on that one item. Full report: https://uav.tridgell.net/DevCallReviews/followups/2026_09_16_2037/devcall_pr_reviews.html#prMissionPlanner-3724 Previous round
New this round
2 further minor notes are in the report rather than here. Checked and clear
Independent cold pass: REQUEST CHANGES. It confirmed every parameter against the fetched Reviewed by: Claude (full read of the diff, thread and surrounding source) + an independent Codex cold pass that was not shown these findings. |
6b558b1 to
15bb12a
Compare
Previous review (head `15bb12a069`)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Re-reviewed at head Full report: https://uav.tridgell.net/DevCallReviews/followups/2026_09_17_0037/devcall_pr_reviews.html#prMissionPlanner-3724 Verdict: COMMENT (was REQUEST CHANGES) — the BUG and the refusal-fallback ISSUE are both properly fixed, and fixed the right way: adding the Previous round
On the blocking-ACK point: no Two corrections I owe you on my own previous comment. ISSUE —
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved acknowledgement handling, blocking follow updates, and obsolete API usage remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates guided-flight movement to use standard MAVLink command APIs with legacy fallbacks.
Changes:
- Uses
DO_REPOSITIONandDO_CHANGE_ALTITUDE. - Adds result-aware command helpers.
- Tracks unsupported commands per vehicle.
- Updates altitude handling in the flight UI.
File summaries
| File | Summary |
|---|---|
GCSViews/FlightData.cs |
Uses the new altitude API. |
ExtLibs/ArduPilot/Mavlink/MAVState.cs |
Tracks unsupported commands per vehicle. |
ExtLibs/ArduPilot/Mavlink/MAVLinkInterface.cs |
Implements command-based movement, result handling, and fallbacks. |
Review details
Suppressed comments (2)
ExtLibs/ArduPilot/Mavlink/MAVLinkInterface.cs:4550
- The updated FlightData call resolves to the one-argument
setNewAlt(float)overload, but this overload is marked[Obsolete]here. That makes the new call emit an obsolete warning and routes the new UI code through an API declared not to be used; either remove the attribute from the intended convenience overload or call the explicit(sysid, compid, altitude)overload.
[Obsolete]
public void setNewAlt(float new_relhome_alt_m)
{
setNewAlt((byte) sysidcurrent, (byte) compidcurrent, new_relhome_alt_m);
GCSViews/FlightData.cs:4386
- The changed call resolves to the new one-argument
setNewAlt(float)overload, but that overload is marked[Obsolete]just below. This introduces a deprecation warning and keeps the UI on the implicitsysidcurrent/compidcurrenttarget API; call the explicit-target overload here instead, or remove the obsolete attribute if the one-argument overload is intended to be the supported UI API.
MainV2.comPort.setNewAlt(newalt / CurrentState.multiplieralt);
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| giveComport = false; | ||
| return (MAV_RESULT) ack.result; |
| flags |= (byte) MAV_DO_REPOSITION_FLAGS.CHANGE_MODE; | ||
| } | ||
|
|
||
| var result = doCommandIntResult(sysid, compid, MAV_CMD.DO_REPOSITION, |
15bb12a to
f7fa9e8
Compare
Previous review (2026-09-17)Automated review note — AI-generated (Claude), cross-checked by an independent Codex pass against the live diff. Please sanity-check before acting. Full report, including everything that was checked and found clean: https://uav.tridgell.net/DevCallReviews/2026_09_17_AIReview/devcall_pr_reviews.html#prMissionPlanner-3724 COMMENTRe-reviewed at head Both blocking items from my previous comment are properly fixed, and fixed the right way: Still open
Smaller points
Withdrawn from my previous round: I was going to flag Verified rather than assumed: parameter packing field by field — speed On meee1's "this shouldnt be changed" for the |
f7fa9e8 to
b69a149
Compare
Previous review (2026-09-18)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Full report, with what was checked and found clean: https://uav.tridgell.net/DevCallReviews/2026_09_18/devcall_pr_reviews.html#prMissionPlanner-3724 Re-reviewed at head The branch was rebased, so GitHub's three-dot Previous round
Still open, much reduced —
|
b69a149 to
08c1891
Compare
Previous review (2026-09-18)Automated review note — AI-generated (Claude), cross-checked by an independent Codex pass against the live diff. Please sanity-check before acting. Full report, including everything that was checked and found clean: https://uav.tridgell.net/DevCallReviews/2026_09_18/devcall_pr_reviews.html#prMissionPlanner-3724 COMMENTRe-reviewed at head Both actionable findings from the last round are resolved, and resolved the right way — a real Previous round
Nothing from the last round is disputed — you acted on both actionable items. NOTE —
|
08c1891 to
e70a86a
Compare
Previous review (2026-09-20)Automated review note — AI-generated (Claude), validated against the live diff (Claude + Codex cross-checked). Please sanity-check before acting. Re-reviewed at head Full report: https://uav.tridgell.net/DevCallReviews/2026_09_20/devcall_pr_reviews.html#prMissionPlanner-3724 Verdict: COMMENT. Still a draft. The one actionable item from last round is fixed, and fixed the right way — nothing below blocks. I also have a correction to my own previous compatibility claim, which turned out to be wrong in a way that matters. Previous round — every finding accounted for
Backward compatibility — and a correction to what I told you last roundThis is the angle that matters most for a GCS, and I got it wrong before.
The upshot: the legacy fallback carries the majority of the fleet, not a corner case — which makes it the most important thing in this PR, and I'm glad to say it works. On New this round — all NOTE level
What was checked and found cleanThe command packing was re-verified field by field against current ArduPilot master rather than carried over. No mechanism went away: comparing declaration lists against Computing the delta needed the merge-base method — the three-dot compare returns ~85 files including CI is 6 of 6 green but compile-only — Build Debug/Release/AAB/APK/OSX/IOS. No unit test, no SITL round trip, nothing that exercises either command against a vehicle. The only behavioural evidence on this PR is your 2026-05-17 note ("Tested basic do-repos and changealt using github build products"), which predates this head by four months and several rewrites of the helpers. Since the Both a primary read and an independent second pass were run; disagreements are recorded in the report rather than averaged away. Exact per-release match counts differed between passes (we counted different file sets), so only the release boundaries above are stated as fact. Anything not reproduced is labelled as such — please push back on it. |
e70a86a to
ef6df54
Compare
Previous review (2026-09-24)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Re-reviewed at head The delta since The one substantive item
Failure sequence: right-click -> "Fly To Here Alt", choose frame "Relative" ( Worth noting the history, since I withdrew a broader version of this last round: the Codex argument that copying altitude and frame together keeps the cached target internally consistent is correct, and it does hold for Cheapest fix that preserves the consistency argument: set Notes
Checked and cleanEvery DO_REPOSITION (192) param slot was checked against MP's generated On compatibility: The previous round's |
ef6df54 to
f001c55
Compare
Previous review (2026-09-24)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Full report: https://uav.tridgell.net/DevCallReviews/2026_09_24_AIReview/devcall_pr_reviews.html#prMissionPlanner-3724 Re-reviewed at head Previous round:
The per-vehicle support matrix is the governing risk here, so I established it rather than assuming it — from the ardupilot tree via
Sub is the outlier — ISSUE — the guided-target marker disappears on tlog playback and for a second GCS
Two paths are affected. Consequence: Severity is a feature regression in log review and multi-GCS awareness, not flight safety — but worth fixing before this leaves draft, since it rots silently: nobody notices a missing marker until they are reviewing an incident. Checked and clearLat/lon scaling is correct — the thing most likely to be wrong in a change like this. Every ACK outcome walked: ACCEPTED caches and returns; UNSUPPORTED falls through to legacy; COMMAND_LONG_ONLY falls through; no ACK at all raises Incidentally an improvement worth noting: Two concerns from my second pass were dropped after checking them, so you are not left chasing them: |
f001c55 to
8072efa
Compare
|
Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Re-reviewed at head The new Issue
Previous round
Notes
Checked: degE7 x/y and float z scaling match every other |
8072efa to
4d1bc75
Compare
doCommand/doCommandInt collapse every non-ACCEPTED result to false, so a caller cannot tell a vehicle which does not support a command apart from one which deliberately refused it. Add doCommandResult/doCommandIntResult and their async forms, which hand back the MAV_RESULT from the COMMAND_ACK. The existing bool entry points become wrappers comparing against ACCEPTED, so no current caller changes behaviour. While waiting for that ack these helpers hold giveComport, which gates every other reader of the link. Wrap the whole send-and-wait in a try/finally so the port is released on any exit, including an exception out of the packet read or out of the initial generatePacket if the link drops mid-write. Previously such an exception escaped with giveComport still set, and everything which defers to it, such as FollowMe, stopped until some unrelated operation happened to clear it. Release only a hold this call took: a fire-and-forget command, with requireack false, never sets giveComport and so must not clear it out from under whatever else holds the link. The old code cleared it regardless on that path, which also broke getHomePositionAsync: it takes the port for the whole operation, then retries with requireack false, and so released its own hold part way through. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
setNewAlt asked for a new guided altitude by sending a mission item with the magic mission_current value of 3, an ArduPilot-specific protocol which predates DO_CHANGE_ALTITUDE and which gives no indication of whether the vehicle took the altitude. Send DO_CHANGE_ALTITUDE as a COMMAND_INT instead and act on the MAV_RESULT, so a refusal reaches the operator rather than being silently discarded. A vehicle answering UNSUPPORTED is recorded in MAVState.UnsupportedCommands and falls back to the mission item path from then on, so older firmware keeps working without paying for the probe on every call. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
setGuidedModeWP moved the vehicle with a SET_POSITION_TARGET_GLOBAL_INT, or on plane a mission item with the magic mission_current value of 2. Neither is acknowledged, so a target the vehicle rejected - one outside the fence, say - looked exactly like one it took. Send DO_REPOSITION as a COMMAND_INT and act on the MAV_RESULT. The frame held in the Locationwp is passed through untouched, so altitude reference handling is unchanged. As with DO_CHANGE_ALTITUDE an UNSUPPORTED answer is cached in MAVState.UnsupportedCommands and the old paths are kept as the fallback. setGuidedModeWP can now throw, so its callers gain a catch: the flight data view reports the refusal to the operator, while the swarm follow path and the 3D view swallow it and carry on, as they have no useful way to report it mid-loop. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
4d1bc75 to
70b151a
Compare
MissionPlanner currently uses some archaic code which relies on magic "current"
values to move the vehicle in GUIDED mode using mission_item and
mission_item_int commands. Use MAV_CMD_DO_REPOSITION and
MAV_CMD_DO_CHANGE_ALTITUDE instead, so we can retire the ArduPilot code.
Both are sent as COMMAND_INT, so lat/lng go on the wire as exact degE7 rather
than through a float.
Falling back
The new commands are not as old as the fleet: Copter and Rover only handle
DO_REPOSITION from 4.1, and DO_CHANGE_ALTITUDE is Plane-only, from 4.6.3.
Everything else NAKs with UNSUPPORTED, so the previous mission-item path is
kept and used whenever the vehicle says it does not know the command, or does
not answer at all. An UNSUPPORTED answer is remembered per vehicle, so an
older vehicle pays one round trip per connection rather than one per command,
and the memory is cleared on reconnect.
A vehicle which refuses the command (a fence breach, say) is a different
thing: that is reported to the operator and the legacy path is not tried, so
Mission Planner no longer talks its way around a refusal the firmware
deliberately made. This is what needs the new doCommandResult/doCommandIntResult
variants: the existing bool helpers collapse every non-ACCEPTED result to false,
which cannot tell "does not support it" from "said no".
Those helpers hold giveComport while they wait for the ack, and they leaked it
if the wait threw - a truncated packet on a lossy link was enough to leave the
port held until some unrelated operation cleared it. It is now released in a
finally, and only where that call took it, which also fixes getHomePosition
releasing its own hold when it retried. That part touches every command
Mission Planner sends, so it is a separate commit.
The ack wait is short (1s, one resend) because these are sent from the UI
thread and from the follow/swarm loops.
The guided target shown on the map is now also recorded from COMMAND_INT on the
receive side, so tlog playback and a second GCS on the same link still draw it.