Stop a mission in ArduCopter

I am trying to develop a way stop a mission in ArduCopter.
For now, I saw that there is already a method in AP_Mission called AP_Mission::stop(), that just changes the state flag of the mission and prevents it from being updated via AP_Mission::update() method.

Well, I managed to make Mission Planner to send a MAVLink message that, when received, calls this AP_Mission::stop() method. After I call the method, I can see that the flag turns to MISSION_STOPPED right away, but the drone only stops when it reaches the waypoint that it is going to (assuming that there is a NAV command running). I am doing these tests with SITL for now.

I wanted to know if this behavior is correct and if someone could help me understand more about how does the relationship between the mission commands and the drone movement works. Thanks :relaxed:

I believe Tower and Misson Planner use the Brake Mode to stop the copter in mid flight. This switches the flight mode from Auto to Brake and stops the copter in its tracks. I have tested this a couple of times and works great.

Mike