Softivation

Mission Planner returns the route with an extra row

The route you read back in Mission Planner comes out one item longer. Item zero is the Home point. Read the MISSION_CURRENT fields and the DO_JUMP target with that in mind.

Furkan IŞIKAY 6 min read

You drew the route, clicked Write, then read it back with Read. There were six rows on screen, and the list that came back has seven items. Or you connected with code and read the count, and it came out one more than what you drew. Deleting the route and drawing it again changes nothing.

Item zero of the mission list is the Home point. You didn't draw it; the autopilot wrote it itself. That's the extra row you see when reading back.

Which number the row you see on screen has in the autopilot

The table on the Flight Plan screen starts at 1. The list in the autopilot's memory starts at 0, and position 0 is reserved for the Home point. So row 1 on screen is also position 1 in the autopilot. Row numbers and sequence numbers match one to one; the extra item in the list is Home at the very beginning.

Flight Plan screenSequence in the autopilot (seq)Command
(no equivalent)0Home
Row 11TAKEOFF
Row 22WAYPOINT
Row 33DO_SET_ROI
Row 44WAYPOINT
Row 55WAYPOINT
Row 66RTL

Note the DO_SET_ROI row in the table. The drone doesn't fly to that point; it only turns its nose. But it uses up a sequence number in the list. So the fourth row on screen becomes the third point flown.

The same message, two different counts

The MISSION_CURRENT message the autopilot sends has two fields: seq, which says which item it's on, and total, which says how many items there are in total. These two don't count Home the same way.

MISSION_CURRENT fields on a five-row route

On a five-row route, the MISSION_CURRENT seq field climbs to 5 while the total field stays fixed at 5. Item 4, the DO_JUMP, isn't reported.
Where to look: the moment the blue step touches the dashed red line. When seq reaches the last item it becomes equal to total; Home is counted differently in the two fields.

On a five-row route, seq climbs up to 5 while total stays fixed at 5. If you're writing your own ground control station and calculating progress as seq divided by total, you'll see one hundred percent while the last item is still being flown.

Look at the seq jumps in the graph too. It goes straight from 3 to 5, because item 4 in between is a DO_JUMP command and this field only reports flight-related commands. The jump at the start of the sequence has a different cause: since the vehicle entered AUTO mode in the air, the takeoff item isn't reported.

How to check on your own vehicle

Instead of interpreting the screen, ask the vehicle for the list directly. The code below connects, reads the number of stored items, and prints each item's seq number next to its row on screen.

Python
from pymavlink import mavutil

arac = mavutil.mavlink_connection("tcp:127.0.0.1:5760")
arac.wait_heartbeat()

# Request the vehicle's mission list from start to end
arac.mav.mission_request_list_send(arac.target_system, arac.target_component)
sayim = arac.recv_match(type="MISSION_COUNT", blocking=True, timeout=10)
print("Items stored on the vehicle:", sayim.count)

ADLAR = {16: "WAYPOINT", 20: "RTL", 21: "LAND", 22: "TAKEOFF",
         177: "DO_JUMP", 201: "DO_SET_ROI"}

for i in range(sayim.count):
    arac.mav.mission_request_int_send(arac.target_system, arac.target_component, i)
    oge = arac.recv_match(type="MISSION_ITEM_INT", blocking=True, timeout=10)
    if oge is None:
        print(i, "no reply")
        break
    ekran = "Home (not shown on screen)" if oge.seq == 0 else f"row {oge.seq}"
    print(f"seq={oge.seq:<3} {ADLAR.get(oge.command, oge.command):<10} -> {ekran}")

# Reading done, send the acknowledgement to the vehicle
arac.mav.mission_ack_send(arac.target_system, arac.target_component, 0)

If you run it with a six-row route loaded, you get this output:

Output
Items stored on the vehicle: 7
seq=0 WAYPOINT -> Home (not shown on screen)
seq=1 TAKEOFF -> row 1
seq=2 WAYPOINT -> row 2
seq=3 DO_SET_ROI -> row 3
seq=4 WAYPOINT -> row 4
seq=5 WAYPOINT -> row 5
seq=6 RTL -> row 6

seq 0 in the first line is the item you didn't draw. The remaining six lines correspond exactly to the six rows you see on screen.

When writing the DO_JUMP target

The number you write in the target field of a DO_JUMP command isn't which flight point of the route it is, but its sequence number in the list. Since helper commands like DO_SET_ROI also use up sequence numbers, these two numbers diverge.

Example: in a payload drop mission you want to fly the route twice, so you put a DO_JUMP on the last row. In the route from the table above, the third point flown is the fourth row on screen, so you write 4 as the target. If you write 3, the target becomes the DO_SET_ROI row, not the waypoint you want to return to. After uploading, read it back with Read and check that the target lands on the row you want.

If you want to return to the start of the route, the value to write is 1. 0 belongs to Home, and the autopilot rejects this item during upload. Here's how to tell the three symptoms apart:

SymptomWhat it means
The count read back is 1 more than the rows you drewExpected behavior. The difference is the Home item.
You wrote 0 as the DO_JUMP targetThe upload is rejected and the acknowledgment returns MAV_MISSION_ERROR.
seq becomes equal to the total fieldThe two fields count differently: seq includes Home, total doesn't.

Error Messages

These are the actual return codes you'll run into when uploading a mission.

MAV_MISSION_ERROR

If the mission upload acknowledgment returns this code, one of the items wasn't accepted. If you write 0 as the DO_JUMP target, this code comes back. If you set the target to 1 and send the same route, you get MAV_MISSION_ACCEPTED.

MAV_MISSION_INVALID_SEQUENCE

Returned when you don't send the items in the order the autopilot requests them. Don't track yourself which seq number is requested during the upload. Read the seq field of the incoming request and send that item.

MAV_MISSION_NO_SPACE

The number of items you send is more than the autopilot can store. Remember that the count includes the Home item too.

Which course covers this topic

The course that covers the route planning screen, the parameter list, and the mission upload steps from start to finish: Mission Planner from Scratch. The long version of the mapping table in this article, log signatures, and board-specific differences are in the lesson inside the course.

Was this article helpful?

Free resourcePixhawk and ArduPilot error message glossaryThe 3 messages in this article and similar ones are in the glossary: what they mean, why they appear, what to check first.