# Mission Mode
Mission mode causes the vehicle to execute a predefined autonomous mission (flight plan) that has been uploaded to the flight controller. The mission is typically created and uploaded with a Ground Control Station (GCS) application like QGroundControl (QGC).
Note
- This mode requires 3d position information (e.g. GPS).
- The vehicle must be armed before this mode can be engaged.
- This mode is automatic - no user intervention is required to control the vehicle.
- RC control switches can be used to change flight modes on any vehicle. RC stick movement will by default change the vehicle to Position mode when flying as a multicopter unless handling a critical battery failsafe (stick movement is ignored for fixed-wing flight).
# Description
Missions are usually created in a ground control station (e.g. QGroundControl) and uploaded prior to launch. They may also be created by a developer API, and/or uploaded in flight.
Individual mission commands are handled in a way that is appropriate for each vehicle's flight characteristics (for example loiter is implemented as hover for copter and circle for fixed-wing). VTOL vehicles follow the behavior and parameters of fixed-wing when in FW mode, and of copter when in MC mode.
Note Missions are uploaded onto a SD card that needs to be inserted before booting up the autopilot.
At high level all vehicle types behave in the same way when MISSION mode is engaged:
- If a mission is stored and PX4 is flying it will execute the mission/flight plan from the current step.
- If a mission is stored and PX4 is landed:
- On copters PX4 will execute the mission/flight plan. If the mission does not have a
TAKEOFF
command then PX4 will fly the vehicle to the minimum altitude before executing the remainder of the flight plan from the current step. - On fixed-wing vehicles PX4 will not automatically take off (the autopilot will detect the lack of movement and set the throttle to zero). The vehicle may start executing the mission if hand- or catapult- launched while in mission mode.
- On copters PX4 will execute the mission/flight plan. If the mission does not have a
- If no mission is stored, or if PX4 has finished executing all mission commands:
- If flying the vehicle will loiter.
- If landed the vehicle will "wait".
- You can manually change the current mission command by selecting it in QGroundControl.
Note If you have a Jump to item command in the mission, moving to another item will not reset the loop counter. One implication is that if you change the current mission command to 1 this will not "fully restart" the mission.
- The mission will only reset when the vehicle is disarmed or when a new mission is uploaded.
Tip To automatically disarm the vehicle after it lands, in QGroundControl go to Vehicle Setup > Safety, navigate to Land Mode Settings and check the box labeled Disarm after. Enter the time to wait after landing before disarming the vehicle.
Missions can be paused by activating HOLD mode. The mission will then continue from the current mission command when you reactivate the MISSION flight mode. While flying in mission mode, if you decide to discontinue the mission and switch to any other mode e.g. position mode, fly the vehicle elsewhere with RC, and then switch back to mission mode, the vehicle will continue the mission from its current position and will fly to the next mission waypoint not visited yet.
Warning Ensure that the throttle stick is non-zero before switching to any RC mode (otherwise the vehicle will crash).We recommend you centre the control sticks before switching to any other mode.
For more information about mission planning, see:
- Mission Planning
- Plan View (QGroundControl User Guide)
# QGroundControl Support
QGroundControl provides additional GCS-level mission handling support (in addition to that provided by the flight controller). For more information see:
# Mission Parameters
Mission behaviour is affected by a number of parameters, most of which are documented in Parameter Reference > Mission. A very small subset are listed below.
Parameter | Description |
---|---|
NAV_RCL_ACT | RC loss failsafe mode (what the vehicle will do if it looses RC connection) - e.g. enter hold mode, return mode, terminate etc. |
NAV_LOITER_RAD | Fixed-wing loiter radius. |
COM_RC_OVERRIDE | If enabled for auto modes, stick movement gives control back to the pilot (switches to Position mode - except when vehicle is handling a critical battery failsafe). Enabled by default. |
# Supported Mission Commands {#mission_commands}
PX4 "accepts" the following MAVLink mission commands in Mission mode (note: caveats below list). Unless otherwise noted, the implementation is as defined in the MAVLink specification.
- MAV_CMD_NAV_WAYPOINT
- Param3 (flythrough) is ignored. Flythrough is always enabled if param 1 (time_inside) > 0.
- MAV_CMD_NAV_LOITER_UNLIM
- MAV_CMD_NAV_LOITER_TIME
- MAV_CMD_NAV_LAND
- MAV_CMD_NAV_TAKEOFF
- MAV_CMD_NAV_LOITER_TO_ALT
- MAV_CMD_NAV_ROI
- MAV_CMD_DO_SET_ROI
- MAV_CMD_DO_SET_ROI_LOCATION
- MAV_CMD_NAV_VTOL_TAKEOFF
MAV_CMD_NAV_VTOL_TAKEOFF.param2
(transition heading) is ignored. Instead the heading to the next waypoint is used for the transition heading.
- MAV_CMD_NAV_VTOL_LAND
- MAV_CMD_NAV_FENCE_RETURN_POINT
- MAV_CMD_NAV_FENCE_POLYGON_VERTEX_INCLUSION
- MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION
- MAV_CMD_NAV_FENCE_CIRCLE_INCLUSION
- MAV_CMD_NAV_FENCE_CIRCLE_EXCLUSION
- MAV_CMD_NAV_RALLY_POINT
- MAV_CMD_DO_JUMP
- MAV_CMD_NAV_ROI
- MAV_CMD_DO_SET_ROI
- MAV_CMD_DO_CHANGE_SPEED
- MAV_CMD_DO_SET_HOME
- MAV_CMD_DO_SET_SERVO
- MAV_CMD_DO_LAND_START
- MAV_CMD_DO_TRIGGER_CONTROL
- MAV_CMD_DO_DIGICAM_CONTROL
- MAV_CMD_DO_MOUNT_CONFIGURE
- MAV_CMD_DO_MOUNT_CONTROL
- MAV_CMD_IMAGE_START_CAPTURE
- MAV_CMD_IMAGE_STOP_CAPTURE
- MAV_CMD_VIDEO_START_CAPTURE
- MAV_CMD_VIDEO_STOP_CAPTURE
- MAV_CMD_DO_SET_CAM_TRIGG_DIST
- MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL
- MAV_CMD_SET_CAMERA_MODE
- MAV_CMD_DO_VTOL_TRANSITION
- MAV_CMD_NAV_DELAY
- MAV_CMD_NAV_RETURN_TO_LAUNCH
- MAV_CMD_DO_SET_ROI_WPNEXT_OFFSET
- MAV_CMD_DO_SET_ROI_NONE
Note:
PX4 parses the above messages, but they are not necessary acted on. For example, some messages are vehicle-type specific.
PX4 generally does not support local frames for mission commands (e.g. MAV_FRAME_LOCAL_NED).
Not all messages/commands are exposed via QGroundControl.
The list may become out of date as messages are added. You can check the current set by inspecting the code. Support is
MavlinkMissionManager::parse_mavlink_mission_item
in /src/modules/mavlink/mavlink_mission.cpp (list generated in this git changelist).Note Please add an bug fix or PR if you find a missing/incorrect message.
# Inter-Waypoint Trajectory
PX4 expects to follow a straight line from the previous waypoint to the current target (it does not plan any other kind of path between waypoints - if you need one you can simulate this by adding additional waypoints).
MC vehicles will change the speed when approaching or leaving a waypoint based on the jerk-limited tuning.
Vehicles switch to the next waypoint as soon as they enter the acceptance radius.
- For MC this radius is defined by NAV_ACC_RAD
- For FW the radius is defined by the "L1 distance".
- The L1 distance is computed from two parameters: FW_L1_DAMPING and FW_L1_PERIOD, and the current ground speed.
- By default, it's about 70 meters.
- The equation is: $$L_{1_{distance}}=\frac{1}{\pi}L_{1_{damping}}L_{1_{period}}\left | \vec{v}{ {xy}{ground} } \right |$$