JUMP_TAG (600) / DO_JUMP_TAG
ID: 601
Summary
The JUMP_TAG and DO_JUMP_TAG commands provide an advanced, identifier-based flow control system for missions. Unlike the standard DO_JUMP (which uses sequence numbers), the tag-based system uses a "Named Marker" (a numeric tag). This allows the mission to be edited—inserting or deleting waypoints—without breaking the jump logic, as the autopilot searches for the tag rather than a fixed index.
Status
Supported (All Vehicles)
Directionality
- RX (Receive): The vehicle receives these commands as part of a mission upload.
Mission Storage (AP_Mission)
- Tag (Param 1): A user-defined integer ID (1-255).
- Repeat (Param 2): (601 only) Number of times to jump to that tag.
- Search Logic: When
DO_JUMP_TAGis reached, the autopilot scans the entire mission command list from the beginning to find the firstJUMP_TAGwith a matching ID (AP_Mission.cpp:2279).
Execution (Engineer's View)
Robust Flow Control
- Tag Discovery: The mission engine calls
find_tag_index(tag). This is a $O(N)$ operation where $N$ is the number of mission items. - Persistence: Like standard jumps, ArduPilot tracks the
num_times_runfor eachDO_JUMP_TAGusing the command's unique mission index. - Failure State: If a
DO_JUMP_TAGpoints to a tag that does not exist in the mission list, ArduPilot logs a warning and the mission completes immediately for safety.
Data Fields (MAVLink)
JUMP_TAG (600)
param1(Tag ID): The identifier for this marker.
DO_JUMP_TAG (601)
param1(Tag ID): The target marker to jump to.param2(Repeat): Number of times to jump.
Theory: Semantic vs. Positional Addressing
In computer science, DO_JUMP is equivalent to a GOTO statement with a line number. DO_JUMP_TAG is equivalent to a GOTO with a Label.
- Maintainability: Positional jumps are "Brittle." If you add a waypoint at the start of a mission, every
DO_JUMPthat follows must be manually updated to point to the new shifted indices. - Flexibility:
DO_JUMP_TAGis "Semantic." The jump points to the meaning of the location (e.g., "Start of Search Area"), ensuring the mission logic remains valid regardless of minor path adjustments.
Practical Use Cases
- Multi-Stage Search:
- Scenario: A drone needs to orbit a site, then fly a grid, then repeat.
- Action: Place
JUMP_TAG (ID: 50)at the start of the orbit. UseDO_JUMP_TAG (Target: 50, Repeat: 5)at the end of the grid.
- Dynamic Scripting:
- Scenario: A GCS script wants to loop a specific section of a mission that was just uploaded.
- Action: The script searches for the Tag ID instead of parsing the whole mission list for indices.
Key Parameters
MIS_RESTART: Resetting the mission will reset the tag counters.
Key Codebase Locations
- libraries/AP_Mission/AP_Mission.cpp:2279: Tag discovery loop.
- libraries/AP_Mission/AP_Mission.cpp:2176: Mission re-indexing and tag validation.