Softivation

Drone hovers in place after the Mission Planner mission ends

If the drone hangs in the air when the Mission Planner mission ends, look at the last line. If the list has no RTL or LAND, the drone waits over the last waypoint in Auto mode.

Furkan IŞIKAY 6 min read

You drew the route in Mission Planner, pressed Write, and the drone flew cleanly up to the last waypoint. Then it stopped there: it doesn't land or return home, and the mode on screen still says Auto.

The drone isn't broken. The mission list has ended, and the autopilot doesn't do anything on its own that isn't written in the list.

Why the drone waits at the last point

ArduPilot runs the mission line by line. When a line finishes, it moves on to the next. If there's no next line, it considers the mission complete. If the drone is in the air at that moment, the autopilot holds it where it is; if it's on the ground, it DISARMs the motors.

The confusing part is that the mode doesn't change. While the drone hangs at the last point, the mode in Mission Planner's HUD stays Auto; it doesn't say LOITER or RTL. If the position estimate is bad, the drone can't hold its place. The autopilot then switches to LAND mode and lands.

The last line of the mission list decides what happens

The last line of the mission list decides what happens
Look at the red branch: if the last line has no RTL or LAND, the drone waits at the last point in AUTO mode.

Look at the red branch in the figure: if there's no RETURN_TO_LAUNCH or LAND line at the end of the list, the drone waits above line 3 in Auto mode. The two branches above bring the drone down and shut off the motors once the landing is complete.

On a team doing an area survey at TEKNOFEST, the route ends at the far end of the field, the drone hangs at 15 meters, and the pilot sees Auto in Mission Planner and thinks the mission is still running. The drone burns battery there until someone intervenes from the transmitter.

How to tell from the screen that the mission is over

Look at the Messages tab on the DATA screen. When the last waypoint is reached, a "Reached command #3" line appears. If no new "Mission:" line follows, the list has ended. The mode label won't tell you this.

The autopilot also broadcasts this in telemetry. The mission state field in the MISSION_CURRENT message is 3 while the mission is being flown and becomes 5 when it ends. If you're writing your own ground station or flying from a companion computer, read this field, not the mode.

The most common mistake: switching the drone to LOITER from the transmitter when the mission ends, then switching back to AUTO a bit later. Returning to AUTO after the mission has ended starts the list from the beginning. Even with MIS_RESTART at 0, the drone flies back to the first waypoint.

The fix: end the list with RTL or LAND

  1. Add the last line. On the PLAN screen, add a line at the end of the route and select RETURN_TO_LAUNCH in the Command column. If you want the drone to land at the last point, select LAND.
  2. Write and read back. Send it to the autopilot with Write, then press Read. You should see RETURN_TO_LAUNCH on the last line of the list. If you don't, the write was incomplete; repeat Write.
  3. Watch Messages in flight. Right after the "Reached command #3" line, "Mission: 4 RTL" should follow. When the drone returns home and lands, you'll see a "Disarming motors" line. The mode still stays Auto; that's normal.
  4. If the mission has ended, don't switch back to AUTO. If the last line isn't RTL and the drone waits in the air, switch it to LOITER from the transmitter and bring it home by hand, or switch it to RTL. If you go back to AUTO, the route starts over.

If you want to monitor the mission state in code, the code below listens to the MISSION_CURRENT message. It warns you if the mission has ended, the motors are armed and the mode is still Auto. If the drone has landed, it tells you that too.

Python
from pymavlink import mavutil

BAGLANTI = "tcp:127.0.0.1:5760"   # put your own connection address here
DURUM = {0: "UNKNOWN", 1: "NO MISSION", 2: "NOT STARTED", 3: "FLYING", 4: "DURAKLADI", 5: "FINISHED"}

m = mavutil.mavlink_connection(BAGLANTI)
m.wait_heartbeat()
m.mav.request_data_stream_send(m.target_system, m.target_component,
                               mavutil.mavlink.MAV_DATA_STREAM_ALL, 4, 1)

son = None
while True:
    msg = m.recv_match(type="MISSION_CURRENT", blocking=True, timeout=5)
    if msg is None:
        print("MISSION_CURRENT not arriving, check the connection")
        continue
    durum = getattr(msg, "mission_state", 0)
    motor = "ARM" if m.motors_armed() else "DISARM"
    satir = (m.flightmode, motor, msg.seq, DURUM.get(durum, durum))
    if satir != son:
        print("mode=%s motor=%s row=%d mission=%s" % satir)
        son = satir
    if durum == 5 and motor == "DISARM":
        print("Mission finished, drone landed")
        break
    if durum == 5 and m.flightmode == "AUTO":
        print("Mission finished but mode is still AUTO: drone is holding at the last point")
        break

Put your own connection address on the BAGLANTI line. The code only reads; it doesn't send any commands to the drone. It can stay open during the flight.

What you'll see

If you run the code after a mission whose list ends with WAYPOINT has finished, you'll see this:

Output
mode=AUTO motor=ARM row=3 mission=FINISHED
Mission finished but mode is still AUTO: drone is holding at the last point

If you add RETURN_TO_LAUNCH to the end of the same mission and fly it, the drone returns home and lands, and the code prints this:

Output
mode=AUTO motor=DISARM row=0 mission=FINISHED
Mission finished, drone landed

In the second output the mode is still AUTO. The difference is in the motor state and the line number: once the landing is complete, the autopilot rewinds the list and the line goes back to 0.

Error Messages

In this problem the autopilot doesn't print an error; these lines in the Messages tab tell you what happened.

Reached command #3

The autopilot reached line 3. If no line starting with "Mission: 4" follows, the list has ended and the drone waits in Auto mode.

Mission: 1 Takeoff

If you entered AUTO again after the mission ended, this line shows the list starting over. If the drone is already in the air, the takeoff line is passed immediately and the drone flies to the first waypoint.

Auto: Missing Takeoff Cmd

The drone is on the ground and armed, and the first line of the list isn't a takeoff. The autopilot refuses to switch to AUTO. Add a TAKEOFF line at the start of the route.

Radio Failsafe - Continuing Auto

The transmitter signal was lost, and the FS_OPTIONS setting says to continue in Auto. If the mission has ended, the drone doesn't switch to RTL; it keeps waiting at the last point. Making the last line RTL covers this case too.

More in the course

Code that reads the list on the autopilot before takeoff and checks the last line and the failsafe setting, the decision order the firmware follows when a mission ends, and how to find this case in the flight log are in the Mission Planner from Scratch course.

Was this article helpful?

Free resourceTEKNOFEST UAV software readiness checklistCheck off your team's software readiness stage by stage on a printable list.