Skip to main content

Planning a New Flight Route

1. Overview

A new flight route planning mission allows you to manually select destinations and automatically generates a flight path for you through multiple flight route planning algorithms. You can customize flight parameters for a route and camera actions at waypoints.

2. Flow Chart

To implement the route planning mission, you must perform the following steps in advance:

1. Create a mission class. For details, see Section 3.1.

2. Call an SDK algorithm to generate a flight route mission file. For details, see Section 3.2.

3. Upload the mission file and then start, pause, or cancel the mission. For details, see Section 3.4 and Section 3.5.

航线任务工作流程-EN

The following takes Autel SDK demo as an example to describe how to implement the flight route planning mission using the AUTEL SDK. For a code sample, see Evo2WayPointActivity。

3. Flight Route Planning Mission APIs

3.1 Waypoint Mission

3.1.1 Description

A waypoint mission involves multiple waypoints. When an aircraft flies to a waypoint, it will perform the preconfigured actions. After the actions are performed, it will then fly to the next waypoint to perform the next preconfigured actions until all waypoint missions are completed.

3.1.2 Waypoint Mission APIs

PathMission is mainly used to configure waypoint missions. You need to configure the number of waypoints, the coordinate of the Home point, and the specific information about waypoints.

PathMission.java field description

public class PathMission {
/**
* number of waypoints
*/
public short WPNum;
/**
* whether to use the default radius. Values: 0: no, 1: yes
*/
public short default_R_flag;
/**
* coordinate of Home point
*/
public double[] HomeLLA;//3
/**
* number of pieces of waypoint information (500)
*/
public PathPoint[] WP_Info_strc;//500
}

Use PathPoint to configure the waypoint information including the coordinate, flight attitude, camera actions, and POIs.

PathPoint.java fields

public class PathPoint {
/** Waypoint type: 1: waypoint where the aircraft will stop, 2: waypoint where the aircraft will turns ahead before reaching it */
public short WPTypeUsr;

/** User-defined waypoint, longitude, latitude, and height */
public double[] WPLLAUsr;//3

/** User-defined turning radius*/
public double RadUsr;

/** Speed */
public double VelRefUsr;

/** Waypoint altitude priority 1: indicates that the priority of this waypoint is higher than the previous waypoint, -1: indicates that the priority of this waypoint is lower than the previous waypoint, 0: there is no priority */
public short AltPrioUsr;

/** Heading mode at this waypoint 1: coordinated turn mode, 2: manual, 3: custom mode */
public short Heading_Mode;

/** Whether a POI exists -1: no POI exists, 1: there is a POI*/
public short POI_Valid;

/** Coordinate of the POI, longitude, latitude, and height */
public double[] POIUsr;//3

/** Total number of camera actions at this waypoint */
public short ActionNum;

/** Number of camera actions at this waypoint. The maximum number is 10. */
public CameraActionJNI[] MSN_ActionInfo;//10
}

Use CameraActionJNI to configure camera information.

CameraActionJNI.java field description

public class CameraActionJNI {
/** Action type */
public int Action_Type;

/** Pitch angle of the gimbal */
public float Gimbal_Pitch;

/** Roll angle of the gimbal */
public float Gimbal_Roll;

/** Yaw angle of the gimbal */
public float Action_Yaw_Ref;

/** Interval between periodic shoots (s) */
public int Shoot_Time_Interval;

/** Distance for fixed-distance photography (mm) */
public float Shoot_Dis_Interval;

/** Action execution time (s) */
public int Action_Time;

/** zoom factor */
public int Zoom_Rate;

/** Reserved */
public int[] reserved;//2
}

3.1.3 Create a Waypoint Mission

The following code example shows how to create a waypoint mission. For details, see the com.autel.sdksample.evo2.mission.Evo2WayPointActivity#initData() method.

PathMission autelMission = new PathMission();
autelMission.HomeLLA = new double[]{22.595607081159642, 113.99784043136384, 10.0};
autelMission.WPNum = 3; //number of waypoints
autelMission.WP_Info_strc = new PathPoint[autelMission.WPNum];
//First route
PathPoint first = new PathPoint();
first.WPTypeUsr = 2;
first.WPLLAUsr = new double[]{22.595617689044104, 113.99774410808175, 10.0};
first.RadUsr = 0;
first.VelRefUsr = 10; // Speed m/s
first.AltPrioUsr=0;
first.Heading_Mode= (short) DroneHeadingControl.FOLLOW_WAYLINE_DIRECTION.getValue();
first.POI_Valid = -1;
first.ActionNum = 2; //camera actions: a maximum of 1 route actions and 10 waypoint actions
first.MSN_ActionInfo = new CameraActionJNI[2];
//waypoint action
first.MSN_ActionInfo[0] = new CameraActionJNI();
first.MSN_ActionInfo[0].Action_Type = CameraAction.POINT_TIMELAPSE.getValue();
first.MSN_ActionInfo[0].Shoot_Time_Interval = 2; //interval between periodic shoots in seconds
first.MSN_ActionInfo[0].Action_Time = 6; //duration for periodic shooting in seconds
//route action
first.MSN_ActionInfo[1] = new CameraActionJNI();
first.MSN_ActionInfo[1].Action_Type = CameraAction.DISTANCE.getValue();
first.MSN_ActionInfo[1].Shoot_Dis_Interval = 2; //distance for fixed-distance photography (unit: m)
autelMission.WP_Info_strc[0] = first;

//Second route
PathPoint second = new PathPoint();
second.WPTypeUsr = 2;
second.WPLLAUsr = new double[]{22.595650750293203, 113.9978042383155, 10.0};
second.RadUsr = 4;
second.VelRefUsr = 10; // Speed m/s
second.AltPrioUsr=0;
second.Heading_Mode= (short) DroneHeadingControl.CUSTOM.getValue();
second.POI_Valid = -1;
second.ActionNum = 1; //camera actions: a maximum of 1 route actions and 10 waypoint actions
second.MSN_ActionInfo = new CameraActionJNI[1];
second.MSN_ActionInfo[0] = new CameraActionJNI();
second.MSN_ActionInfo[0].Action_Type = CameraAction.RECORD.getValue();
second.MSN_ActionInfo[0].Gimbal_Pitch = 63;
second.MSN_ActionInfo[0].Action_Yaw_Ref = 179;
autelMission.WP_Info_strc[1] = second;

3.2 Call an Algorithm to Generate a Planned Flight Route

The route planning algorithm is embedded in AirLineCreator. The following shows the required API:

/**
* Generates the flight route for the waypoint mission
**/
public static PathResultMission getWayPointMissionPath(PathMission mission)

Example:

//Transfers the waypoint attributes configured in Section 3.1
PathResultMission m = AirLineCreator.getWayPointMissionPath(autelMission);

3.3 Write the Result of the Flight Route Planning Mission into Your Local Storage

You need to use AirLineCreator to write the result of the flight route planning mission to your local storage. The following shows the required API:

/**
* Generates a mission file and uploads or downloads the mission in a form of a file
*
* @param filePath: path of the generated file
* @param cfg
* @param m
* @return return result: 0: normal;-1:path cannot be left empty;-2:failed to create a file directory;-3:an error occurred when creating a file directory;-4:mission route cannot be left empty
*/
public static int writeMissionFile(String filePath, MissionConfig cfg, PathResultMission m)

Example:

String path = getCacheDir() +"/mission/"+System.currentTimeMillis();
//generates a mission file based on the route planned by the algorithm
MissionConfig cfg = new MissionConfig();
cfg.id = mid++;
cfg.type = MissionType.MISSION_TYPE_WAYPOINT;
cfg.altitudeType = MissionAltitudeType.RELATIVE;
cfg.finishAction = MissionFinishActionType.HOVER;
cfg.lossAction = RemoteControlLostSignalAction.CONTINUE;
cfg.vFov = 44.9f; ///Reads the heartbeat messages from the camera in real time
AirLineCreator.writeMissionFile(path, cfg, m)

3.4 Upload the Route Planning File

3.4.1 Obtain Evo2FlyController

You need to use the Evo2FlyController API to upload the route planning file. Perform the following steps to obtain the Evo2FlyController object method:

1. Obtain the BaseProduct class of the aircraft connected to your app by using the callback of the listener and then further obtain the module APIs.

Autel.setProductConnectListener(new ProductConnectListener() {
@Override
public void productConnected(BaseProduct product) {
//connected
}
@Override
public void productDisconnected() {
//disconnected
}
});

2. Obtain the Evo2FlyController API through the BaseProduct class.

Evo2FlyController javamEvoFlyController = (Evo2FlyController) product.getFlyController();

Example:

Evo2FlyController javamEvoFlyController = (Evo2FlyController) product.getFlyController();
mEvoFlyController.uploadFileData(path, FileDataType.FLY_TASK, new CallbackWithOneParamProgress<Float>() {
@Override
public void onProgress(float var) {
AutelLog.d("waypoint onProgress " + var);
}

@Override
public void onSuccess(Float data) {
flyState = FlyState.Prepare;
AutelLog.d("prepareMission success");
Toast.makeText(Evo2WayPointActivity.this, "prepare success", Toast.LENGTH_LONG).show();
}

@Override
public void onFailure(AutelError error) {
AutelLog.d("prepareMission onFailure");
Toast.makeText(Evo2WayPointActivity.this, "prepare failed", Toast.LENGTH_LONG).show();
}
});

3.5 Execute the Mission

3.5.1 Perform Checks Before Taking Off

To ensure safe flight, before the aircraft takes off, check the following information:

1. Check the battery

EvoBattery battery = (EvoBattery) product.getBattery();
battery.setBatteryStateListener(new CallbackWithOneParam<EvoBatteryInfo>() {
@Override
public void onSuccess(EvoBatteryInfo batteryState) {
isBatteryOk = batteryState.getRemainingPercent() > lowBatteryPercent;
}

@Override
public void onFailure(AutelError autelError) {

}
});

2. Check the IMU, GPS, compass, and whether the aircraft is ready for taking off

Evo2FlyController mEvoFlyController = (Evo2FlyController) product.getFlyController();
mEvoFlyController.setFlyControllerInfoListener(new CallbackWithOneParam<EvoFlyControllerInfo>() {
@Override
public void onSuccess(EvoFlyControllerInfo evoFlyControllerInfo) {
isCompassOk = evoFlyControllerInfo.getFlyControllerStatus().isCompassValid();
isCanTakeOff = evoFlyControllerInfo.getFlyControllerStatus().isTakeOffValid();

isImuOk = evoFlyControllerInfo.getFlyControllerStatus().getArmErrorCode() != ARMWarning.IMU_LOSS
&& evoFlyControllerInfo.getFlyControllerStatus().getArmErrorCode() != ARMWarning.DISARM_IMU_LOSS;

isGpsOk = evoFlyControllerInfo.getFlyControllerStatus().isGpsValid();
}

@Override
public void onFailure(AutelError autelError) {

}
});

3. Check the image transmission signals

AutelRemoteController remoteController = product.getRemoteController();
remoteController.setInfoDataListener(new CallbackWithOneParam<RemoteControllerInfo>() {
@Override
public void onSuccess(RemoteControllerInfo remoteControllerInfo) {
isImageTransOk = remoteControllerInfo.getDSPPercentage() >= 30;
}

@Override
public void onFailure(AutelError autelError) {

}
});

3.5.2 Obtain MissionManager

1. Obtain the BaseProduct class of the aircraft connected to your app by using the callback of the listener and then further obtain the module APIs.

Autel.setProductConnectListener(new ProductConnectListener() {
@Override
public void productConnected(BaseProduct product) {
//connected
}
@Override
public void productDisconnected() {
//disconnected
}
});

2. Obtain the MissionManager API through the BaseProduct class.

MissionManager missionManager = product.getMissionManager()

3.5.3 Execute the Mission

Before you execute the mission, use the following APIs to control the mission progress:

1. startMission(start)

2. pauseMission(pause)

3. resumeMission(resume)

4. cancelMission(cancel)

6. downloadMission(download the mission that is being executed)

MissionManager#startMission

Example:

missionManager.startMission(new CallbackWithNoParam() {
@Override
public void onSuccess() {
flyState = FlyState.Start;
Toast.makeText(Evo2WayPointActivity.this, "start success", Toast.LENGTH_LONG).show();
}

@Override
public void onFailure(AutelError autelError) {

}
});
MissionManager#pauseMission
missionManager.pauseMission(new CallbackWithNoParam() {
@Override
public void onSuccess() {
flyState = FlyState.Pause;
Toast.makeText(Evo2WayPointActivity.this, "pause success", Toast.LENGTH_LONG).show();
}

@Override
public void onFailure(AutelError autelError) {

}
});
MissionManager#resumeMission
missionManager.resumeMission(new CallbackWithNoParam() {
@Override
public void onSuccess() {

}

@Override
public void onFailure(AutelError autelError) {

}
});
MissionManager#cancelMission
missionManager.cancelMission(new CallbackWithNoParam() {
@Override
public void onSuccess() {

}

@Override
public void onFailure(AutelError autelError) {

}
});
MissionManager#downloadMission
missionManager.downloadMission(new CallbackWithOneParamProgress<AutelMission>() {
@Override
public void onProgress(float v) {

}

@Override
public void onSuccess(AutelMission autelMission) {

}

@Override
public void onFailure(AutelError autelError) {

}
});