Skip to content

Mission Requests

A remote system, such as a dispatch service, can plan missions for the operator. Your plugin sends each one to AMC. AMC shows it to the operator, who loads it into the Plan view, saves it for later, or declines it, and your plugin hears which.

Requires AMC 2.5.0+

Mission requests were added in AMC 2.5.0; older versions don't have the QGroundControl.MissionRequests module.

The operator stays in charge

AMC never uploads a plan, starts a mission or stops a vehicle because of a mission request. The operator loads the mission, checks it, uploads it from the Plan view and starts it as usual.

How it works

  1. Your plugin receives a mission from the remote system, for example with the HTTPS, gRPC or MQTT client (see Secure Connections), and calls offer().
  2. AMC checks the mission. It refuses a malformed one at once with missionInvalid. Otherwise it shows the operator a "Load mission" card with Decline, Later and Load.
  3. Load builds the mission in the Plan view, and your plugin gets missionLoaded. Later saves it as a plan file for the operator to open another time. Decline sends you missionDeclined with the operator's reason.
  4. From then on it is an ordinary plan. AMC keeps no link between the plan and your mission and reports nothing more about it.

A mission is not tied to a vehicle: AMC builds it for the vehicle the Plan view plans for when the operator loads it.


Creating a source

import QGroundControl.MissionRequests

MissionRequestSource is the only type in this module that plugins use. The module's other types belong to AMC's own screens.

Declare one MissionRequestSource in your plugin's data singleton:

pragma Singleton

import QtQuick
import QGroundControl.MissionRequests
import QGroundControl.Plugin

Item {
    MissionRequestSource {
        id: missionSource

        onMissionInvalid: (missionId, error) => PluginManager.log("MyPlugin: " + missionId + " refused: " + error)
        onMissionDeclined: (missionId, reason) => PluginManager.log("MyPlugin: " + missionId + " declined: " + reason)
        onMissionLoaded: missionId => PluginManager.log("MyPlugin: " + missionId + " is in the Plan view")
    }
}
  • In the data singleton. When a source is destroyed, the card of its mission goes away if it still waits. The data singleton lives until AMC quits, so a source there keeps its mission waiting. A source in a view would lose them whenever the view is destroyed.
  • MissionRequestSource has no properties.

Methods

Method Parameters Description
offer(id, content) string, object Sends a mission for the operator to review

offer()

Parameter Type Description
id string Your id for the mission. It comes back with every signal. AMC doesn't interpret it
content object The mission, see Offer content
  • One card at a time. A new offer, from your plugin or another one, takes the place of the mission waiting on the card. The replaced mission's plugin gets missionDeclined with "Replaced by a newer mission."
  • The same id while its card waits updates the mission on the card, so the operator always sees your latest version. This doesn't count as a replacement.
  • The same id after the operator acted on it is a new mission with a new card. AMC doesn't remember ids once a card is gone.
  • An invalid offer gets missionInvalid before offer() returns, and changes nothing: the card keeps its mission.
  • offer() returns no value.

Signals

Signal Parameters Description
missionInvalid(id, error) string, string AMC refused the offer. error names the first problem, for example "Item 2: give altAmsl or altRelative, not both." Nothing was shown to the operator
missionDeclined(id, reason) string, string The operator declined it, or a newer mission took its place on the card. reason is the operator's own text, "The operator declined the mission.", or "Replaced by a newer mission."
missionLoaded(id) string The operator loaded it into the Plan view

When the operator saves a mission with Later, its card goes away and your plugin gets no signal.

Name the handlers' arguments, Qt 6 style, as in the snippet above. error and reason are for people and may be translated: don't parse them.


Offer content

missionSource.offer("WO-1042", {
    name: "Pole inspection WO-1042",
    items: [
        { type: "waypoint", tag: "Pole 14", lat: 47.39775, lon: 8.54560, altRelative: 40 },
        { type: "loiter", tag: "Pole 15", lat: 47.39890, lon: 8.54720, altRelative: 40, radius: 60, seconds: 30 }
    ]
})
Field Type Required Description
name string No Shown to the operator on the card, and offered as the file name for Later. Without it, AMC shows "Unnamed mission"
items array Yes The items, in flight order. At least one must be of a type AMC knows
geofence object No Replaces the Plan view's geofence when the mission is loaded, see Geofence
rallyPoints array No Replace the Plan view's rally points when the mission is loaded, see Rally points

Items

Every item takes these fields:

Field Type Required Description
type string Yes "waypoint", "loiter", "targetLanding", "survey", or "jump" (experimental)
tag string No Your name for the item, unique within the offer. A jump names its target by it, and the card names a jump's target by it

Waypoints, loiters and target landings also take a position:

Field Type Required Description
lat number Yes Latitude in degrees, -90 to 90
lon number Yes Longitude in degrees, -180 to 180
altAmsl number No Altitude in metres above mean sea level
altRelative number No Altitude in metres above the vehicle's home position

waypoint

Flies to the point. It takes only the fields above.

loiter

Loiters around the point. It adds:

Field Type Required Description
radius number No Radius in metres, above 0, flown clockwise. Without it, the loiter gets the Plan view's default for a new loiter
seconds number No How long to loiter, above 0. Without it, the loiter has no time limit
  • A radius outside vehicle.minLoiterRadiusMeters to vehicle.maxLoiterRadiusMeters is flown at the nearest limit.
  • A multirotor holds position at a loiter, so it ignores radius.

targetLanding

Lands at the point, which is the touchdown point. It adds:

Field Type Required Description
startAltAmsl number With altAmsl Altitude of the land start point, where the approach begins, in metres above mean sea level
startAltRelative number With altRelative Altitude of the land start point in metres above the vehicle's home position
heading number No Direction of travel at touchdown, in degrees, from 0 to below 360
  • AMC builds it only for a fixed-wing vehicle that supports target landings: vehicle.fixedWing && vehicle.registryUiAdapter.hasTargetLanding. For any other vehicle it is left out.
  • Once it is built, the flight ends there: AMC builds no item after it.
  • Its altitudes come as a pair or not at all: altAmsl with startAltAmsl, or altRelative with startAltRelative. Without either, both keep the Plan view's defaults for a new target landing.
  • The vehicle refuses a land start that isn't above the touchdown, or that is too steep for its glide slope setting. AMC places the land start at a distance worked out from the vehicle's sink rate; the offer can't set it.
  • Without heading, it lands in the direction of the takeoff AMC adds, as the Plan view does. A vehicle already flying gets no takeoff, and the landing keeps the Plan view's default heading.

survey

Surveys an area. It takes no lat and lon; instead:

Field Type Required Description
polygon array Yes The area's corners in order, each {lat, lon}, at least 3. The first point may be repeated at the end, as in GeoJSON or KML
altAmsl number No Survey altitude in metres above mean sea level
altRelative number No Survey altitude in metres above the vehicle's home position
{ type: "survey", tag: "Field 3", altRelative: 80,
  polygon: [{ lat: 47.4055, lon: 8.5500 }, { lat: 47.4055, lon: 8.5540 },
            { lat: 47.4030, lon: 8.5540 }, { lat: 47.4030, lon: 8.5500 }] }
  • AMC builds the Plan view's survey over the area, as when the operator adds one, with the Plan view's survey settings: camera, overlap and line spacing, grid angle and turnaround. The offer sets only the area and the altitude.
  • An altitude switches the survey to keep that altitude rather than a ground resolution, as the operator would in the survey editor.
  • Without an altitude, the survey takes the previous item's altitude, or the Plan view's default when there is none.

jump

Experimental

jump may change or go away in a later AMC version.

Flies part of the mission again: the vehicle goes back to an earlier item and flies from there to the jump again. It takes no lat and lon; instead:

Field Type Required Description
to string Yes The tag of an earlier waypoint or loiter
repeat number Yes How many more times to fly from to to here, a whole number from 1 to 65535
items: [
    { type: "waypoint", tag: "A", lat: 47.39864, lon: 8.54559, altRelative: 30 },
    { type: "waypoint", tag: "B", lat: 47.39864, lon: 8.54692, altRelative: 30 },
    { type: "jump", to: "A", repeat: 2 }
]

This patrol flies A to B three times: once, then twice more.

  • After the last repeat, the vehicle carries on with the item after the jump. 65535 repeats is the most the vehicle takes.
  • A survey can't be the target: a saved plan can't store a jump to one.
  • AMC builds it as the Plan view's "Jump to item" (MAV_CMD_DO_JUMP). It keeps pointing at its target when the plan is renumbered, for example when a survey before the target works out its lines, or when the operator inserts items.
  • An AMC version without jump skips it as an unknown type, so the vehicle flies the items only once.

Altitudes

  • Give altAmsl or altRelative, not both.
  • Leave both out and the item takes the previous item's altitude, or the Plan view's default when there is none, as when the operator adds it. The operator sees it in the Plan view and can change it before uploading.
  • altRelative is above the vehicle's home position, normally where it armed. For a vehicle already flying it is still home, not where the vehicle is now.
  • A target landing takes its two altitudes as a pair, see targetLanding.

Geofence

geofence: {
    polygons: [
        { inclusion: true, polygon: [{ lat: 47.400, lon: 8.540 }, { lat: 47.400, lon: 8.552 }, { lat: 47.394, lon: 8.552 }, { lat: 47.394, lon: 8.540 }] }
    ],
    circles: [
        { inclusion: false, lat: 47.397, lon: 8.546, radius: 150 }
    ]
}
Field Type Description
polygons array Each {inclusion, polygon}: polygon as a survey's, at least 3 {lat, lon} points
circles array Each {inclusion, lat, lon, radius}, radius in metres, above 0
  • inclusion is true for an area the vehicle must stay in and false for one it must stay out of. It is required.
  • At most one polygon or circle is an inclusion area, as in the Plan view.
  • Empty lists clear the Plan view's geofence when the mission is loaded. Without geofence, the Plan view keeps the one it has.
  • Uploading a plan sends its geofence too, so what the Plan view holds replaces the vehicle's.

Rally points

rallyPoints: [
    { lat: 47.3990, lon: 8.5430, altRelative: 60 },
    { lat: 47.3955, lon: 8.5510 }
]
  • Each point is {lat, lon} with altAmsl or altRelative, as for a waypoint. Without an altitude, the point gets the Plan view's default.
  • An empty list clears the Plan view's rally points when the mission is loaded. Without rallyPoints, the Plan view keeps the ones it has.
  • Uploading a plan sends its rally points too.

Unknown types and fields

AMC skips what it doesn't use instead of refusing the offer, so a newer remote system still works with an older AMC.

  • An item of another type is skipped. Apart from tag, AMC checks none of its fields.
  • A field AMC doesn't use, at the top level or in an item, is skipped. Fields belong to their type: heading on a waypoint is skipped.

Invalid offers

AMC refuses the whole offer with missionInvalid when:

  • items is missing, is not an array, is empty, or has no item of a type AMC knows.
  • An item is not an object, or its type is missing, empty or not text.
  • Two items share a tag.
  • In a waypoint, loiter or target landing, lat or lon is missing or out of range.
  • An item gives both altAmsl and altRelative, or both startAltAmsl and startAltRelative.
  • A target landing's altitudes aren't a pair: altAmsl without startAltAmsl, altRelative without startAltRelative, a start altitude alone, or the two in different frames.
  • heading is not from 0 to below 360, or radius or seconds is not above 0.
  • A survey's polygon has fewer than 3 points, not counting a repeated first point, or a point without a valid lat and lon.
  • A jump's to is not the tag of an earlier waypoint or loiter, or its repeat is not a whole number from 1 to 65535.
  • geofence is not an object, a polygon or circle breaks the rules in Geofence, or more than one area is an inclusion area.
  • rallyPoints is not an array, or a point has no valid lat and lon, or both altitudes.

A name or tag that is not text counts as missing. Every number must be finite: a string such as "47.39" is refused. A field set to null counts as given, so altAmsl: null is refused too: leave out a field you have no value for. The error counts items from 1.


How AMC builds the plan

When the operator presses Load, AMC opens the Plan view and, if the plan there has unsaved changes, asks before replacing its mission. Then it:

  • replaces the mission. The geofence and rally points are replaced only by the ones your offer brings.
  • builds for the vehicle the Plan view plans for: the active vehicle, or the offline planning vehicle when none is connected. Loading doesn't switch vehicles.
  • adds a takeoff first if that vehicle is a fixed-wing, VTOL or multirotor on the ground, and at least one of your items can be built. A fixed-wing or VTOL climbs out along the vehicle's current heading. Other vehicles, and a vehicle already flying, get no takeoff.
  • adds your items in order, except those it can't build for that vehicle.
  • adds no landing of its own. The plan lands only where you offered a targetLanding.
  • takes your values as given. Anything you leave out gets the Plan view's own default and limits, as when the operator adds the item.

The plan then belongs to the operator, who can change anything, save it and upload it like any other plan.

Later builds the mission the same way for the active vehicle, outside the Plan view, and saves it as an ordinary plan file in AMC's mission folder, under a name the operator picks. The file keeps that vehicle's geofence and rally points unless your offer brings its own. The operator opens it from the Plan view like any saved plan. The file holds no trace of your mission id.

What the operator sees

  • A "Load mission" card in the middle of the main window for the mission that waits: your name, what your items are, the target's position when you send a targetLanding, and the geofence and rally points you sent. Its buttons are Decline, Later and Load.
  • Decline asks for an optional reason, which comes back to you with missionDeclined.
  • Later asks for a file name, starting from your name, and asks before replacing a saved plan with the same name.

Restarts and plugin removal

AMC keeps the waiting mission in memory only. When AMC quits, its card goes, without a signal to your plugin. After a restart, send again whatever is still open on your side. Loaded and saved missions are ordinary plans and stay as they are.

Deleting your plugin takes effect only when AMC restarts. Until then your data singleton keeps running, so its card stays and offer() still works.


Example: inspection work order

A data singleton, saved as InspectionData.qml, that sends a two-waypoint inspection and logs what the operator does with it. Other files of the plugin call InspectionData.offerInspection("WO-1042"), for example when the remote system assigns a work order.

pragma Singleton

import QtQuick
import QGroundControl.MissionRequests
import QGroundControl.Plugin

Item {
    id: root

    function offerInspection(workOrderId) {
        missionSource.offer(workOrderId, {
            name: "Pole inspection " + workOrderId,
            items: [
                { type: "waypoint", tag: "Pole 14", lat: 47.39775, lon: 8.54560, altRelative: 40 },
                { type: "waypoint", tag: "Pole 15", lat: 47.39890, lon: 8.54720, altRelative: 40 }
            ]
        })
    }

    MissionRequestSource {
        id: missionSource

        onMissionInvalid: (workOrderId, error) => PluginManager.log("Inspection: " + workOrderId + " refused: " + error)
        onMissionDeclined: (workOrderId, reason) => PluginManager.log("Inspection: " + workOrderId + " declined: " + reason)
        onMissionLoaded: workOrderId => PluginManager.log("Inspection: " + workOrderId + " loaded")
    }
}