1. Mission Command Overview:
There are three types of commands:- NAVigation commands (MAV_CMD_NAV_*) are used to control vehicle movement, including takeoff, moving to and around waypoints, changing altitude, and landing.
- DO commands (MAV_CMD_DO_*) are for auxiliary functions that do not affect the vehicle’s position (for example, setting the camera trigger distance, or setting a servo value).
- CONDITION commands (MAV_CMD_CONDITION_*) are used to delay DO commands until some condition is met. For example MAV_CMD_CONDITION_DISTANCE will prevent DO commands executing until the vehicle reaches the specified distance from the waypoint.
2. Download current mission:
The mission commands for a vehicle are accessed using the Vehicle.commands attribute. The attribute is of type CommandSequence, a class that provides ‘array style’ indexed access to the waypoints which make up the mission.Waypoints are not downloaded from vehicle until download() is called. The download is asynchronous; use wait_ready() to block your thread until the download is complete:
# Connect to the Vehicle (in this case a simulated vehicle at 127.0.0.1:14550)
vehicle = connect('127.0.0.1:14550', wait_ready=True)
# Download the vehicle waypoints (commands). Wait until download is complete.
cmds = vehicle.commands
cmds.download()
cmds.wait_ready()
3. Clearing current mission:
To clear a mission you call clear() and then Vehicle.commands.upload() (to upload the changes to the vehicle):# Connect to the Vehicle (in this case a simulated vehicle at 127.0.0.1:14550)
vehicle = connect('127.0.0.1:14550', wait_ready=True)
# Get commands object from Vehicle.
cmds = vehicle.commands
# Call clear() on Vehicle.commands and upload the command to the vehicle.
cmds.clear()
cmds.upload()
Note: If a mission that is underway is cleared, the mission will continue to the next waypoint. If you don’t add a new command before the waypoint is reached then the vehicle mode will change to RTL (return to launch) mode.