Skip to main content

Waypoint Mission Tutorial

1. Overview

Waypoint is an important module of the Mobile SDK. After you establish the waypoints on a map and configure waypoint action parameters and route parameters, the aircraft can fly through the established waypoints and perform preset route actions and waypoint actions.

This tutorial describes all classes and APIs that are involved and provides API call examples.

2. Waypoint flow

航线任务工作流程-EN

3. Key classes and APIs

3.1 Classes involved in a waypoint mission

ClassDescriptionRemarks
AUTELWaypointMissionHandlerInherits from AUTELMissionHandler. As the protocol manager that handles waypoint missions, it can download, upload, execute, and stop a mission.
AUTELWaypointMissionInherits from AUTELMission. It is the base class of a waypoint mission.
AUTELGen2WaypointMissionAUTELWaypointMission,
AUTELMCWaypointMissionInherits from AUTELGen2WaypointMission. It is a waypoint mission class for EVO II V1 and EVO II V2.
AUTELWaypointG2Inherits from AUTELWaypoint. It is a waypoint class in a waypoint mission of EVO I.
AUTELWaypointMCInherits from AUTELWaypointG2. It is a waypoint class in a waypoint mission of EVO II V1 or EVO II V2.
AUTELMissionProgressStatusBase class of the current mission execution status class. Report the mission execution status using theonNavigationMissionStatusChanged method.
AUTELWaypointMissionStatusInherits from AUTELMissionProgressStatus. It indicates the execution status of the current waypoint mission.

3.1.1 AUTELMCWaypointMission Class

It is the waypoint mission class for EVO II V1 and EVO II V2. The relevant parameters and methods are described below:

ParameterTypeDescriptionRemarks
missionNameNSStringMission name
guidNSStringUnique identifier of the mission
missionTypeAUTELMissionTypeMission type. See the enumerated values of AUTELMissionType. AUTELMissionTypeWaypoint : waypoint mission. AUTELMissionTypeRectangle: rectangle. AUTELMissionTypePolygon: polygon. AUTELMissionTypeObliquePhoto: oblique.
altitudeTypeintAltitude type. Values: 0: relative height, 1: altitude.This parameter is only applied to waypoint missions.
lostConnectActionAUTELMission SignalLostHandleTypeAction performed when the aircraft is lost. The default value is AUTELMissionSignalLostHandleTypeNone. If the value is AUTELMissionSignalLostHandleTypeGoHome, the aircraft returns to the Home points. If the value is AUTELMissionSignalLostHandleTypeContinue, the aircraft continues to execute the mission until the battery is insufficient or the mission is completed.
finishModeAUTELNavigation MissionFinishModeMission finish action. The default value is AUTELNavigationMissionFinishModeGoHome. If the value is AUTELNavigationMissionFinishModeGoHome, the aircraft automatically returns to the Home point after completing the mission. If the value is AUTELNavigationMissionFinishModeHover, the aircraft hovers at the current location after completing the mission.
poiListNSArray<InterestPointModel >A collection of POIs. An POI can be associated with one or multiple waypoints. However, a waypoint can only be associated with only one POI. For waypoints associated with POIs, the aircraft faces towards the POIs when flying through or hovering at these waypoints.This parameter is only applied to waypoint missions.
totalTimesintThe total flight time, which is calculated and returned by the route planning algorithm. Currently, the value is set to -1.This parameter is only applied to waypoint missions.
totalDistanceintThe total flight distance, which is calculated and returned by the route planning algorithm. Currently, the value is set to -1.This parameter is only applied to waypoint missions.

3.1.2 AUTELWaypointMC class

This is a waypoint class in a waypoint mission of EVO II V1 or EVO II V2 aircraft.

A waypoint mission contains one or multiple waypoints. You can configure the route actions or waypoint actions for each waypoint.

ParameterTypeDescriptionRemarks
coordinateCLLocationCoordinate2DCoordinate of a waypoint.
styleAUTELWaypointStyleWaypoint type. See enumerated values of AUTELWaypointStyle. Currently, only two types of waypoint types are supported: AUTELWaypointStyleNormal: flg over, which means that the aircraft continues to fly after arriving at a preset waypoint; AUTELWaypointStyleHover: hover, which means that the aircraft stops at a preset waypoint and perform the waypoint actions if they are configured.
altitudefloatAltitude, which is relative to the height of the aircraft takeoff point. The value cannot exceed the maximum altitude of the aircraft.
speedfloatFlight speed.
headingModeAUTELWaypointHeadingModeWaypoint heading mode. If the value is AUTELWaypointHeadingModeTowardsNext, the aircraft faces towards the next waypoint when arriving at a waypoint. If the value is AUTELWaypointHeadingModeCustom, the aircraft faces towards the direction defined by the user when arriving at a waypoint. If the value is AUTELWaypointHeadingModeFreedom, the heading is random and controlled by the user. It changes according to the pull-and-push operations performed by the user on the command sticks.
userDefinedHeadingfloatUser-defined nose heading.
poiIndexintAssociated POI. If no POI is associated, the value -1 is transferred. A waypoint can only be associated with only one POI.
actionsNSArray <AUTELWaypointAction > Waypoint action list. For details, see the description of the AUTELWaypointAction class.

3.1.3 AUTELWaypointAction Class

This class describes the waypoint action information. It supports EVO II V1 and EVO II V2 series aircraft.

ParameterTypeDescriptionRemarks
actionIdintcurrent action ID, which corresponds to the index of the waypoint action list.
actionTypeAUTELWaypointActionTypeWaypoint action type. For details, see 3.1.5 AUTELWaypointActionType enumeration class.
actionParaAUTELWaypointActionParaWaypoint action parameter list. For details, see 3.1.4 AUTELWaypointActionPara class.

If the waypoint type is fly over, you configure 1 group of waypoint actions or no waypoint actions for this waypoint. The supported action type and the number of parameters are shown below:

Supported action typeNumber of parametersDescriptionRemarks
Starts recording0No parameter
Stops video recording0No parameter
Photo taking0No parameter
Periodic1Period for timed shot (s)
Fixed-distance shooting1Period for fixed-distance shooting (unit: m)

If the waypoint type is hover, you can configure multiple groups of waypoint actions or no waypoint action for this waypoint. If the camera action is photo taking, no parameter is required. If the camera action is video recording, a parameter (recording duration) is required. If the camera action is timed shot, two parameters (photo taking period and duration) are required.

Supported action typeNumber of parametersDescriptionRemarks
Photo taking0No parameter
Video recording1Recording duration (s)
Periodic2Photo-taking period (s), photo-taking duration (s)

3.1.4 AUTELWaypointActionPara class

This class describes the waypoint action information. It supports EVO II V1 and EVO II V2 series aircraft.

Waypoint actions are classified into two types: route actions or waypoint actions

ParameterTypeDescriptionRemarks
cameraPitchfloatThe gimbal pitch angle. The range is 0 -90 (0 indicates a horizontal level while 90 indicates that the gimbal faces vertically downwards).
cameraYawfloatThe yaw angle of the aircraft.
cameraRollfloatRoll angle of the gimbalThis parameter is invalid.
timeIntervalfloatPeriod for timed shot (s)
timeIntervalTimeDurationfloatThe total duration for a timed shot (s).
distanceIntervalfloatPeriod for fixed-distance shooting (unit: m)
recordVideoTimeDurationfloatRecording duration (s)
cameraZoomfloatThe zoom level of the camera. The default value is 1.

3.1.5 AUTELWaypointActionType enumeration class

This class defines the waypoint action type. It is defined below.

/**
* Define Waypoint Action Type
*
*/
typedef NS_ENUM(int, AUTELWaypointActionType) {
/**
* @brief Invalid
*
*/
AUTELWaypointActionTypeInvalid = 0,

/**
* @brief TakePhoto
*
*/
AUTELWaypointActionTypeTakePhoto = 1,

/**
* @brief Start Video Record
*
*/
AUTELWaypointActionTypeStartRecordVideo = 2,

/**
* @brief Stop Video Record
*
*/
AUTELWaypointActionTypeStopRecordVideo = 3,

/**
* @brief TakePhoto Interval
*
*/
AUTELWaypointActionTypeTimeInterval = 11,

/**
* @brief TakePhoto Distance
*
*/
AUTELWaypointActionTypeDistance= 12,

/**
* @brief Unknown
*
*/
AUTELWaypointActionTypeUnknown = 0xff
};

3.1.6 AUTELWaypointMissionStatus class

This class describes the execution status of the current waypoint mission.

ParameterTypeDescriptionRemarks
execStateAUTELWaypointMissionExecuteStateThe current status of the waypoint mission. For details, see 3.1.7 AUTELWaypointMissionExecuteState enumeration class
targetWaypointIndexintThe index of the waypoint towards which the aircraft is flying.
residualTimefloatThe remaining flight time for the current waypoint mission.
residualDistancefloatThe remaining route distance for the current waypoint mission.
photoCountfloatThe number of photos that have already been taken during the current waypoint mission.

3.1.7 API for reporting the waypoint mission status

/**
* @brief Updates the navigation mission status. If the missionType is of type AUTELNavigationMissionWaypoint
* then the missionStatus will be of class AUTELWaypointMissionStatus.
*
* @param missionStatus Mission status based on the current mission.
*
* @see AUTELWaypointMissionStatus
*/
- (void)onNavigationMissionStatusChanged:(AUTELMissionProgressStatus* _Nonnull)missionStatus;

/**
* @brief The mission status information is pushed in real time during mission flight execution.Specifically refers to mission flight (waypoint flight, rectangular mission, polygonal mission)
*
* @param missionStatus Mission status based on the current mission.
*
* @see AUTELMissionProgressStatus
*/
- (void)onMissionCurrentStatusUpdateNote:(AUTELWaypointMissionStatus* _Nonnull)missionStatus;

4. Implement a waypoint mission

1. Monitor the reporting of the waypoint mission status

Register a listener for monitoring the reporting of the waypoint mission status.
AUTELNavigationDelegateConnection.shared.addProtocol(self)
Monitor the reporting of the waypoint mission status.
func onNavigationMissionStatusChanged(_ missionStatus: AUTELMissionProgressStatus!) {
DispatchQueue.main.async {

}

}

- (void)onMissionCurrentStatusUpdateNote:(AUTELWaypointMissionStatus* _Nonnull)missionStatus {
DispatchQueue.main.async {

}
}

2. Start a mission

Before you start the mission, perform the following steps:

  1. Configure the mission data model
  2. Upload the mission data
  3. Start executing the mission
3.1 Create a waypoint mission
private func creatMissionForMC() -> AUTELMCWaypointMission {
let mission = AUTELMCWaypointMission()
mission.missionId = 5
let finishModeIndex = 0
mission.finishMode = finishModeIndex == 0 ? .goHome : .hover
mission.totalTimes = -1
mission.totalDistance = -1
mission.executeIndex = 0
mission.executePhotos = 0
mission.lostConnectAction = .continue

mission.guid = "0fd18b3fca64b83089d5c9bad4420c94"// An MD5 string, which contains a maximum of 32 characters.
mission.missionName = "Waypoint Mission"

mission.missionType = .waypoint
mission.addGen2Waypoints(setWayPointTypeForHover())

return mission
}
3.2 Configure task data (example 1)

If the waypoint type is fly over, set the yaw angle to 135°, the pitch angle of the gimbal to 45 degree, and the camera action to timed shot.

private func setWayPointTypeForflyOver() -> [AUTELWaypointMC] {
var items = [AUTELWaypointMC]()

typealias dataSetTuple = (curFlyTime: Float, curFlyDistance: Float, waypoint: WayPointModel)
var dataSets = [dataSetTuple]()

WayPointManager.shared.wayPoints.enumerated().forEach { (index, element) in
let dataSetTuple = (Float(19*index), Float(36*index), element)
dataSets.append(dataSetTuple)
}

for i in 0..<dataSets.count {
let mc = AUTELWaypointMC()
mc.coordinate = coordinateAntiCorrectIfNeeded(dataSets[i].waypoint.coordinate)
mc.altitude = dataSets[i].waypoint.height
mc.speed = dataSets[i].waypoint.speed
mc.userDefinedHeading = 0
mc.headingMode = .custom// Sets the yaw angle to a custom value.
mc.poiIndex = -1
mc.curFlyTime = dataSets[i].curFlyTime
mc.curFlyDistance = dataSets[i].curFlyDistance
mc.style = .normal// Sets the waypoint type to “Fly Over”’.

// Camera action example
var actions = [AUTELWaypointAction]()// Creates an action group.
let waypointAction = AUTELWaypointAction()// Configures Action 1.
waypointAction.actionId = 0
waypointAction.actionType = AUTELWaypointActionType.timeInterval// Sets the action type to Timed Shot.

let actioinPara = AUTELWaypointActionPara.init()// Configures action parameters.
actioinPara.cameraPitch = 45// Sets the gimbal pitch angle to a downward angle of 45 degrees.
actioinPara.cameraYaw = 135// Sets the yaw angle of the aircraft to 135°. If you set this to 0°, the aircraft flies due north. If you set this to 90°, the aircraft flies along the route.
actioinPara.cameraZoom = 1// Sets the zoom level to 1.
actioinPara.timeInterval = 2// Sets the time-lapse interval for timed shot to 2 s.

waypointAction.actionPara = actioinPara
actions.append(waypointAction)

mc.actions = actions

items.append(mc)
}

return items
}
3.3 Configure task data (example 2)

If the waypoint type is hover, you can define multiple groups of camera actons, specific the yaw angle, and customize the gimbal pitch angle by referring to the following code:

private func setWayPointTypeForHover() -> [AUTELWaypointMC] {
var items = [AUTELWaypointMC]()

typealias dataSetTuple = (curFlyTime: Float, curFlyDistance: Float, waypoint: WayPointModel)
var dataSets = [dataSetTuple]()

WayPointManager.shared.wayPoints.enumerated().forEach { (index, element) in
let dataSetTuple = (Float(19*index), Float(36*index), element)
dataSets.append(dataSetTuple)
}

for i in 0..<dataSets.count {
let mc = AUTELWaypointMC()
mc.coordinate = coordinateAntiCorrectIfNeeded(dataSets[i].waypoint.coordinate)
mc.altitude = dataSets[i].waypoint.height
mc.speed = dataSets[i].waypoint.speed
mc.userDefinedHeading = 0
mc.headingMode = .custom// Sets the yaw angle to a custom value. This parameter is used together with actioinPara.cameraYaw for defining a yaw angle.
mc.poiIndex = -1
mc.curFlyTime = -1//dataSets[i].curFlyTime
mc.curFlyDistance = -1//dataSets[i].curFlyDistance

mc.style = .hover// Sets the waypoint type to “Hover”, which means that the aircraft will stop at the waypoint and perform waypoint actions once the aircraft arrives at the waypoint.
mc.holdTime = 0

let actioinPara = AUTELWaypointActionPara.init()// Configures parameters for Action 1.
waypointAction.actionId = 0

if i == 0 {// Action parameter for Waypoint 0
waypointAction.actionType = AUTELWaypointActionType.takePhoto// Sets the action type to “Single”.


} else if i == 1 {// Action parameter for Waypoint 1
waypointAction.actionType = AUTELWaypointActionType.timeInterval// Sets the action type to “Single”.
actioinPara.timeIntervalTimeDuration = 20// Sets the time-lapse interval for timed shot to 20 s.
actioinPara.timeInterval = 3// Sets the time-lapse interval for timed shot to 3 s.
actioinPara.cameraPitch = 70// Sets the gimbal pitch angle to a downward angle of 45 degrees.
actioinPara.cameraYaw = 0// Sets the yaw angle of the aircraft to 0°, indicating that the aircraft will fly due north. If you set this to 90°, the aircraft will fly along the route.
} else if i == 2 {// Action parameter for Waypoint 1

actioinPara.timeIntervalTimeDuration = 21// Sets the time-lapse interval for timed shot to 21 s.
actioinPara.timeInterval = 3// Sets the time-lapse interval for timed shot to 3 s.
actioinPara.cameraPitch = 0// Sets the gimbal pitch angle to a downward angle of 0 degree.

} else {

actioinPara.cameraPitch = 90// Sets the gimbal pitch angle to a downward angle of 45 degrees.
actioinPara.cameraYaw = 180// Sets the yaw angle of the aircraft to 180°. If you set this to 0°, the aircraft will fly due north. If you set this to 90°, the aircraft will fly along the route.
}

waypointAction.actionPara = actioinPara
actions.append(waypointAction)

mc.actions = actions

items.append(mc)
}

return items
}
3.4 Upload the task and start to perform the mission
//1. Configure the mission data model
let mission = creatMissionForMC()
//2. Upload the mission data
let handler = DroneConnection.shared.drone?.mainController.navigationManager.waypointMissionHandler
handler?.prepare(mission, withProgress: { (progress) in
print("waypoint:\(progress)\n");

}, withCompletion: { (error) in
if let err = error {
print("prepare waypoint mission error: " + err.localizedDescription);
DispatchQueue.main.async {
completionHandler(error)
}
return
} else {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
//3. Start executing the mission
handler?.startMissionExecution(completion: { (error) in
if let err = error {
DispatchQueue.main.async {
print("2. Start the mission error: " + err.localizedDescription);
completionHandler(error)
}

} else {

DispatchQueue.main.async {
completionHandler(nil)
}
}
})

}
}

})

4. Pause the mission

DroneConnection.shared.drone?.mainController.navigationManager.waypointMissionHandler.pauseMissionExecution(completion: { (error) in
if let err = error {
print("pause waypoint error: \(err.localizedDescription)")
DispatchQueue.main.async {

}
} else {

}
})

5. Continue the mission

DroneConnection.shared.drone?.mainController.navigationManager.waypointMissionHandler.resumeMissionExecution(completion: { (error) in
if let err = error {
print("resume waypoint error: \(err.localizedDescription)")
DispatchQueue.main.async {

}
} else {

}

})

6. Stop the mission

When a waypoint mission is being executed, you can call the following method to stop the mission. Based on the input parameter, the aircraft will return to the Home point or hover in the sky after stopping the mission.

DroneConnection.shared.drone?.mainController.navigationManager.waypointMissionHandler.stopMissionExecution(.goHome, withCompletion: { [weak self] (error) in
guard let _ = self else { return }
if let err = error {
DispatchQueue.main.async {

}
print("exit waypoint mission error: \(err.localizedDescription)")
} else {

}
})

This is the end of the tutorial.