Skip to content

Mission Route Planning ​

main (PX4 v2.0)

Mission route planning lets a multicopter rejoin the uploaded mission after leaving it, for example after manual repositioning or a GoTo: smart mission rejoin.

Quick Start ​

Smart mission rejoin changes where a multicopter continues when Mission mode starts or resumes in the air. Without it, the vehicle flies straight to the current mission item: the one it was flying to when it left the mission. With it, the vehicle flies to a point on a nearby mission leg, the branch-in point, and continues the mission from there.

For example, a GoTo takes the vehicle next to a later leg of the mission. When Mission resumes, the vehicle joins that later leg and skips the legs in between.

Enable ​

  1. Check that the firmware is built with the mission route cache. SITL builds include it, but most flight controller builds do not: without it the parameters below do not exist.
  2. Set MIS_ROUTE_JOIN to 1.

Only multicopters rejoin, including helicopters and coaxials, which report as rotary wing. Other vehicles, including VTOL vehicles in hover, resume the mission as they do without smart rejoin.

Tune ​

MIS_MC_SEG_DIST (default 30 m) sets how strongly the vehicle keeps to the leg it was flying. A leg is a candidate when it is at most this much farther from the vehicle than the nearest leg, and the leg the vehicle was flying wins among the candidates.

  • Larger: the vehicle keeps to the leg it was flying, even when another leg is closer.
  • Smaller: the vehicle joins the nearest leg; 0 always joins the nearest leg.

In the figure the nearest leg is 15 m away. With 30 m, the legs up to 45 m away are kept: if the vehicle was flying leg 1-2, 35 m away, it rejoins that leg. With 10 m, only the legs up to 25 m away are kept, so it joins the nearest leg, 2-3.

The vehicle projects onto four legs, 15, 35, 60 and 85 m away. With MIS_MC_SEG_DIST at 30 m the legs up to 15 + 30 = 45 m away are kept; with 10 m only the nearest leg, up to 25 m away

These parameters also act on the rejoin:

ParameterEffect on the rejoin
NAV_ACC_RADA vehicle closer than this to the landing it joins lands directly, without climbing back first.
NAV_MC_ALT_RADA vehicle more than this below the branch-in point climbs in place first.
GF_CONT_H_MARGINThe leg to the branch-in point keeps this distance from the geofence; see Geofence Checks.

When to Keep It Off ​

  • Camera surveys: the rest of a paused survey leg has no images; see Camera Surveys.
  • Missions where no command may be skipped: joining a later leg skips the items in between.
  • Flights near obstacles: the leg to the branch-in point is only checked against the geofence.

Messages ​

  • Rejoining mission route: the vehicle flies to the branch-in point.
  • Route rejoin unavailable: Mission resumes as it does without smart rejoin, for example while the mission or the geofence is still loading, or when the geofence blocks the legs back to the route.

Details ​

The rest of this page explains each rule:

Smart Mission Rejoin ​

When Mission mode resumes a mission in flight with smart rejoin enabled, the vehicle:

  1. Selects the branch-in point: the point on the route where it joins, with its altitude. See Vehicle Projection.
  2. Climbs in place to the branch-in altitude if it is more than NAV_MC_ALT_RAD below it. Without smart rejoin, Mission climbs in place the same way, to the altitude of its current mission item. With smart rejoin the climb ends at the branch-in altitude: if the next mission item is higher, the vehicle climbs to it along the route.
  3. Flies straight to the branch-in point. From above, it descends on the way.
  4. Continues the mission from there, as described below.

If a rejoin cannot be planned, Mission mode resumes without smart rejoin and reports a warning. This can happen while the mission is still loading into the route cache, or while the geofence is loading. A finished mission is not rejoined: Mission mode holds, as it does without smart rejoin.

Where the Mission Continues ​

After the branch-in point:

  • Mission continues with the waypoint at the end of the joined leg.
  • Exception: if the current item is a command on the joined leg and the branch-in point is within NAV_ACC_RAD of the waypoint at the start of the leg, Mission continues with that waypoint, so the command runs where it was planned. Farther along the leg the command is skipped: the vehicle never flies back along a leg.
  • Skipped items do not run, but their speed, camera and gimbal settings still apply, as on any Mission resume.
  • If the joined leg is before the current item, the legs from there are flown again, with their commands.

The current item is a command only when it was selected, or when Mission paused while it ran: during a delay item, or during a gripper, winch or gimbal command while MIS_COMMAND_TOUT is set.

Example: the mission has waypoint 6, a gripper release 7 and waypoint 8.

  • Flying from waypoint 5 to 6, the vehicle is sent with a GoTo next to leg 6-8, far from leg 5-6: it continues to 8, and 6 and the release are skipped.
  • Paused during the release and resumed from Hold near waypoint 6: it releases at 6, then flies to 8.
  • Paused during the release, then sent 100 m along leg 6-8: it continues to 8 without the release.

DO_JUMP Loops ​

The vehicle can branch in on the jump edge of the loop it is flying: the leg from the waypoint before the DO_JUMP back to the jump target. Mission counts a repeat when it takes the jump, and the rejoin keeps that count:

  • While repeats remain, the vehicle flies forward along the jump edge to the jump target, and flies the loop again.
  • Once no repeats remain, it flies back along the jump edge to the waypoint before the DO_JUMP, and continues after the loop. Going forward would fly the loop once more.

Rejoin on the jump edge of a DO_JUMP loop: with repeats left the vehicle flies forward to the jump target and flies the loop again; with no repeats left it flies back to the waypoint before the jump and continues after the loop

A pause on the jump edge of the last repeat therefore finds no repeats left, and the rejoin skips that last pass. A pause while Mission runs the commands just before a DO_JUMP is not on the loop yet. A rejoin on the leg that leaves the loop runs these commands and the DO_JUMP again only within NAV_ACC_RAD of the waypoint before them; farther along that leg it skips them, so the remaining loop passes are not flown.

Starting and Uploading ​

With smart rejoin enabled, starting or continuing Mission while airborne attempts to join the route, including the first start after an upload or reboot and a new flight after disarming. The join may skip earlier mission items, even on the first start. Starting Mission on the ground follows the mission normally; a later airborne resume can use smart rejoin.

An upload while Mission is active replaces the mission using normal mission handling; it does not immediately plan a join. Smart rejoin is tried the next time Mission starts in the air. If the route cache has not loaded the new mission by then, Mission resumes without it and reports Route rejoin unavailable.

Selecting an Item ​

Selecting a mission item while Mission mode is paused makes it the current item of the next resume, like any other current item. This includes MAV_CMD_MISSION_START with a first item, sent while Mission mode is not active. The rejoin then flies the leg to that item if the leg is within the search margin; otherwise it may branch in before or after the item. Selecting another item while Mission mode is active flies to it directly, as without smart rejoin. Resetting the jump counters while Mission mode is active also ends a join in progress: the vehicle flies to the current item.

The rejoin branches in on a leg near the vehicle, and Mission continues the mission in order from there, also when the current item is in the landing sequence (from the DO_LAND_START item, or the landing item if there is none). A MAV_CMD_DO_LAND_START sent while Mission mode is not active can therefore fly earlier mission legs before the landing; sent while Mission mode is active, it flies to the landing directly.

Landing ​

If the rejoin would continue with a landing item, and the vehicle is horizontally within NAV_ACC_RAD of it, Mission lands directly. This lets a paused descent continue without first climbing back to the approach altitude. Outside that radius, for example after a GoTo during a paused descent, Mission rejoins as usual: the vehicle climbs in place back to the route altitude, then flies to the branch-in point.

Camera Surveys ​

A camera survey paused while triggering is joined too: the vehicle does not fly back to the previous survey waypoint, as it does without smart rejoin. The camera restarts only when the vehicle reaches the joined mission item, so the rest of the paused survey leg has no images. Keep smart rejoin off for camera surveys.

Geofence Checks ​

Before selecting a branch-in point, the planner checks the leg from the vehicle to that point against the polygons and circles of the loaded geofence. A leg that touches or crosses a fence boundary is rejected. With a contingency geofence, the leg must also stay GF_CONT_H_MARGIN away from these boundaries, like a mission leg. Mission legs passed the altitude and distance-from-home limits in the mission check, so points on them are not checked against those limits again.

The check depends on where the vehicle is, relative to these polygons and circles:

VehicleLeg to the branch-in point
Inside, more than GF_CONT_H_MARGIN from every boundaryKeeps GF_CONT_H_MARGIN from the boundaries.
Inside, but within GF_CONT_H_MARGIN of a boundaryMust not touch a boundary, but may run within the margin.
Outside an inclusion area, or inside an exclusion areaNot checked, so that the vehicle can fly back in along the route.

A vehicle that only breaches GF_MAX_HOR_DIST or GF_MAX_VER_DIST gets no exemption: its leg is checked as in the first two rows. With GF_CONT_H_MARGIN at 0 (the default), the leg must only not touch a boundary. The same rules apply to the direct flight to a landing within its acceptance radius (see Landing).

The planner checks the candidates kept by Point Projection, up to four, once the route has been scanned. A candidate that fails is removed before the search margin is applied, so it cannot hide a farther candidate among the four.

If the fence is unavailable or still loading, smart rejoin is skipped with a warning and is not retried during that activation. The planner does not find detours around fences.

Vehicle Projection ​

To rejoin the route, the planner projects the current vehicle position onto the mission path and chooses a "branch-in" point. The vehicle may have left the route (for example with a GoTo), so the planner picks the point that best preserves mission continuity.

The branch-in point is chosen in three phases:

Phase 1: Identifying valid candidates:

The vehicle is projected onto the route as described in Point Projection. Candidates must pass the Geofence Checks before selection.

Phase 2: Selecting the best branch-in point:

The best candidate is chosen with a priority system:

  • Priority 1: a candidate is selected immediately if it lies on the segment the vehicle is currently expected to be flying (the last targeted waypoint index, or the last flown DO_JUMP segment when known). This includes the vertical segment being flown at takeoff or landing (see Stacked Waypoints).
  • Priority 2: if no candidate matches Priority 1, the planner scores each candidate by summing the following distances, and keeps the lowest:
    • Cross-track distance: from the vehicle to the projection on the route.
    • Distance along the route to the last-flown segment: from the projection, following the mission path to whichever end of the last-flown segment is closer. This selects the candidate that gets the vehicle back to where it was last flying if available, or the best match for a close in-sequence segment if it is not.

Example 1:

The outbound and inbound legs of this mission run close to each other. While on the outbound leg, the vehicle deviates east to a GoTo location (e.g. due to incoming traffic). The GoTo location is closer to the inbound leg, but both legs are within the margin, so the projection step returns one candidate on each. The outbound leg is the segment the vehicle is expected to fly, so it wins on Priority 1. It would also win on Priority 2: from the inbound projection, the route back to the outbound leg covers almost the whole mission. The vehicle rejoins the outbound leg and continues the mission.

Branch-in selection on a mission with outbound and inbound close segments

Example 2:

The vehicle is flying north and deviates to a GoTo location that has two valid branch-in candidates. Neither projection lies on the current segment, so each candidate is scored by summing its cross-track distance and the distance along the route to the last-flown segment. Take the candidate projected onto the east segment. Its score is the cross-track distance (166.95 m) plus the distance along the route back to the last-flown segment (the red lines). The distance labels in the image add up along this path, so the last label (541.02 m) is the score. The closer end of the last-flown segment is used, and the along-route distance is the sum of the straight lines between waypoints. The other candidate, projected onto the south segment, wins because its total distance is smaller.

Branch-in scoring when no candidate lies on the current segment

Phase 3: Determining the branch-in altitude:

  • Linear interpolation: by default the altitude is interpolated between the start and end waypoint altitudes of the segment (for example, rejoining on segment 2-3 interpolates between waypoint 2 and waypoint 3).
  • Special case (land): if the branch-in point falls on a land segment, the previous waypoint altitude is used.
  • Special case (vertical segments): if both waypoints of the segment share the same latitude and longitude (stacked waypoints), the segment end waypoint altitude is used.
  • Special case (landing): when the first item to fly is LAND and the vehicle is already inside its horizontal acceptance radius, the join keeps the vehicle's current altitude. LAND sits at ground level, and without this rule a vehicle already descending onto it would first be sent back up to the approach altitude. Outside the acceptance radius the rules above apply as usual.

DO_JUMP loop segments: the vehicle can also branch-in on a loop edge. A loop edge is projected and scored like any other segment, so it competes as an ordinary candidate. This matters because the loop edge might be the only valid candidate, for example after a GoTo close to the loop edge.

What happens after joining a loop is described in DO_JUMP Loops.

Point Projection ​

This is the projection step of the Vehicle Projection above.

The planner draws a perpendicular projection from the point onto every route segment and keeps the four closest as candidates. After the Geofence Checks, a candidate is kept only if its cross-track distance is within a search margin of the closest candidate left. The search margin is MIS_MC_SEG_DIST. Projections beyond the four closest are dropped, even inside the margin. They are never checked against the geofence either, which limits the planner in two cases:

  • If the four closest projections all fail the geofence check, the rejoin cannot be planned, even when a farther leg has a clear path.
  • If only some of them fail, the branch-in point is selected among the ones left. A leg beyond the four closest is not considered, even when it would win the selection in Phase 2 of Vehicle Projection.

The mission route planner supports DO_JUMP mission loop commands. The active jump segment is the segment running from the waypoint before the jump command to the first position waypoint at the jump target. A point projects onto a loop segment using the same cross-track and margin rule as any other segment.

Click here for more detail on how projections land on segments and corners

A projection is normally perpendicular to the point on a segment, but it is only kept if it is a local minimum of the distance to the route. This rule decides what happens at a waypoint, where two segments meet:

  • An interior projection, one that lands part-way along a segment, is always kept.
  • A projection that lands exactly on a waypoint (a corner) is kept only at the end of the route, or when the previous segment and the current segment both project onto that same shared corner. This happens when two consecutive segments form a V-shape and the point is closest to the apex:
text
 A \      / C
    \    /          P projects onto corner B from both segments.
     \  /           Both projections land on B, so the shared
    B \/            corner is kept as a single candidate.

       ^
       P

This is why some projections in the images below land on a waypoint instead of perpendicular to a segment.

The example below uses a large margin. The mission route is drawn in white and projections in green. The images also show rally points (R) and their projections; smart rejoin does not use them.

Point projection with a large search margin

Here is the same route with a smaller margin. Some projections are dropped because their cross-track distance is greater than the closest projection's cross-track distance plus the margin.

Point projection with a small search margin

With a margin of zero, each point keeps only its single closest projection.

Click here to see how stacked waypoints (same latitude and longitude) are handled

Two consecutive waypoints that share latitude and longitude form a vertical segment, for example a climb waypoint above TAKEOFF or a descent waypoint above LAND. Every point projects onto such a segment at the same spot. The vehicle keeps the vertical segment as a candidate when it matches the current mission index, at both LAND and TAKEOFF. A vehicle that drifts during a landing therefore keeps LAND as its first target. This exception is disabled during an active DO_JUMP.

Limitation: after a distant GoTo while targeting LAND, the vertical segment at LAND can still be selected. The vehicle may then fly a diagonal path back to the route end instead of joining a closer leg. It flies that path at the approach altitude.

Parameters and Build Configuration ​

SettingPurposeDefault
MIS_ROUTE_JOINEnable smart rejoin when Mission resumes a mission in flight.0
MIS_MC_SEG_DISTSearch margin for the leg to rejoin.30 m

CONFIG_NAVIGATOR_FULL_MISSION_CACHE_SIZE must be greater than zero and large enough for the entire uploaded mission. The parameters above only exist in firmware built with a non-zero cache size. POSIX builds (SITL and Linux boards) default to 500 mission items and other boards to 0; px4_fmu-v6c_visionTargetEstStatic sets 300. To use smart rejoin on a NuttX board, set the cache size in the board configuration and check that the RAM fits; see the mission route cache for its memory use. Builds with the cache also raise the Navigator task stack, and the route planner reserves 312 bytes of static RAM per slot of CONFIG_NAVIGATOR_SAFE_POINT_BATCH_SIZE (16 by default; px4_fmu-v6c_visionTargetEstStatic sets 32, about 10 KB, of which smart rejoin uses one):

ini
CONFIG_NAVIGATOR_FULL_MISSION_CACHE_SIZE=300

An oversized mission can still be flown in Mission mode, but smart rejoin cannot use it.