Skip to main content

Drone Flight Zone Management Tutorial


Drone Flight Zone Management Tutorial

1. Overview

Drone flight zone management mainly includes no-fly zone management, authorized zone management, and allowable flight zone management. No-fly zones can be further divided into global fixed no-fly zones, temporary no-fly zones, and electronic fences (currently only supports JSON files complying with ED-269 standard). The SDK implements functions related to flight zones and provides interfaces that comply with laws and regulations for external use.

2. API Call Instructions

2.1 Obtain No-Fly Zones within a 100km Radius of the Drone

The example code is as follows:

 
FlyZoneManager.get().getFlyZonesInSurroundingArea(location, object: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneInformation>?>{
override fun onSuccess(t: List<FlyZoneInformation>?) {
//success
}

override fun onFailure(error: IAutelCode, msg: String?) {
//failureL
}
})

Parameter description:

location:position information[LocationCoordinate2D]

2.2 Retrieve aircraft authorization area information from the server

The example code is as follows:


FlyZoneManager.get().downloadAuthFlyZoneFromServer(
aircraftSN,
location,
object: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneAuthInformation>?>{
override fun onSuccess(t: List<FlyZoneAuthInformation>?) {
//success
}

override fun onFailure(error: IAutelCode, msg: String?) {
//failure
}
})

Parameter description:

aircraftSN:Aircraft SN number

location:Center position[LocationCoordinate2D]

2.3 Upload authorization zone files to the aircraft

The example code is as follows:


FlyZoneManager.get().pushAuthFlyZoneToAircraft(device, object: CommonCallbacks.UpLoadFileCallbackWithProgress<Int>{
override fun onStartUploading() {
//start uploading
}

override fun onProgressUpdate(progress: Int) {
// progress info
}

override fun onSuccess() {
// success
}

override fun onFailure(error: IAutelCode) {
//failure
}
})

Parameter description:

device:Drone equipment

Attention: The SN of the authorization area information must match the aircraft SN, otherwise the upload will fail. Once the upload is successful, the authorization area will take effect.

2.4 Obtain authorization area information

The example code is as follows:


FlyZoneManager.get().getAuthFlyZone(device.getDroneSn()!!, object: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneAuthInformation>?>{
override fun onSuccess(t: List<FlyZoneAuthInformation>?) {
//success
}

override fun onFailure(error: IAutelCode, msg: String?) {
// faulure
}
})

2.5 Import authorization area file

The example code is as follows:

        FlyZoneManager.get().importFlySafeDynamicDatabaseToMSDK(filePath, object: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneInformation>> {
override fun onSuccess(t: List<FlyZoneInformation>?) {
//success
}

override fun onFailure(error: IAutelCode, msg: String?) {
//failure
}
})

Parameter description:

filePath:File Path

Attention: Currently, only importing EU geographical perception data is supported. Geographical perception data can be accessed from the official website of the European Aviation Safety Agency( https://www.easa.europa.eu/en/domains/civil-drones/naa )Download.

2.6 Importing geographic perception data into aircraft, currently only supports EU data

The example code is as follows:


FlyZoneManager.get().pushFlySafeDynamicDatabaseToAircraft(object: CommonCallbacks.UpLoadFileCallbackWithProgress<Int>{
override fun onStartUploading() {
// start uploading
}

override fun onSuccess() {
// success
}

override fun onFailure(error: IAutelCode) {
// failure
}

override fun onProgressUpdate(progress: Int) {

}
})

2.7 Obtain the country code for the flight zone of the aircraft

The example code is as follows:

            FlyZoneManager.get().getAircraftFlyZoneCountryCode(aircraftSN, object: CommonCallbacks.CompletionCallbackWithParam<List<FlyableZoneInfo>> {

override fun onSuccess(t: List<FlyableZoneInfo>?) {
//success
}

override fun onFailure(error: IAutelCode,msg: String?) {
//failure
}
})

Parameter description:

aircraftSN:Aircraft SN

3.Sample acquisition

Refer to FlyZoneFragment in the sample

4.Interface Description


interface IFlyZoneManager {

////////////////////////////////////// NO-FLY ZONES /////////////////////////////////////////////
/**
* Gets no-fly zones within a 100km radius of the center position, including fixed no-fly zones, temporary no-fly zones, and electronic fences.
* @param location Center position
* @param callback Callback for the result
*/
fun getFlyZonesInSurroundingArea(
location: LocationCoordinate2D,
callback: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneInformation>?>
)

fun addFlyZoneListener(callback: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneInformation>>)

fun removeFlyZoneListener(callback: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneInformation>>)

fun clearFlyZoneListener()

////////////////////////////////////// AUTHORIZED ZONES ////////////////////////////////////////
/**
* Downloads authorized flight zone information for a specified aircraft from the server.
* @param aircraftSN Aircraft serial number
* @param location Center position, currently unused
* @param callback Callback for the result
*/
fun downloadAuthFlyZoneFromServer(
aircraftSN: String,
location: LocationCoordinate2D,
callback: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneAuthInformation>?>
)

/**
* Downloads authorized flight zone information for a specified aircraft from the server.
* @param aircraftSN Aircraft serial number
* @param token Token obtained from the server during login
* @param location Center position, currently unused
* @param callback Callback for the result
*/
fun downloadAuthFlyZoneFromServer(
aircraftSN: String,
token: String,
location: LocationCoordinate2D,
callback: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneAuthInformation>?>
)

/**
* Uploads authorized flight zone information to the aircraft's flight control system. Note that the SN of the authorized flight zone needs to match the aircraft SN; otherwise, the upload will fail. Upon successful upload, the authorized flight zone becomes effective.
* @param drone Drone device
* @param callback Callback for the result
*/
fun pushAuthFlyZoneToAircraft(
drone: IAutelDroneDevice,
callback: CommonCallbacks.UpLoadFileCallbackWithProgress<Int>
)

/**
* Retrieves authorized flight zone information.
* @param aircraftSN Aircraft serial number
* @param callback Callback for the result
*/
fun getAuthFlyZone(
aircraftSN: String,
callback: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneAuthInformation>?>
)

/**
* Deletes authorized flight zone information from the aircraft.
* @param drone Drone device
* @param callback Callback for the result
*/
fun deleteAuthFlyZoneFromAircraft(
drone: IAutelDroneDevice,
callback: CommonCallbacks.CompletionCallback
)

////////////////////////////////////////// GEO-AWARENESS DATABASE ////////////////////////////////////////////
/**
* Imports the flight geofencing database into the MSDK. Currently, only EU geofencing data is supported.
* Geofencing data can be downloaded from [the EASA website](https://www.easa.europa.eu/en/domains/civil-drones/naa).
* @param filePath Path to the data file, which must be in JSON format and conform to the ED-269 standard.
* @param callback Callback for the result
*/
fun importFlySafeDynamicDatabaseToMSDK(
filePath: String,
callback: CommonCallbacks.CompletionCallbackWithParam<List<FlyZoneInformation>>
)

/**
* Gets the version of the geofencing database, returns an empty string if none is present.
*/
fun getFlySafeDynamicDataVersion(): String

/**
* Pushes the EU geofencing data to the aircraft's flight control system.
* @param callback Callback for the result
*/
fun pushFlySafeDynamicDatabaseToAircraft(callback: CommonCallbacks.UpLoadFileCallbackWithProgress<Int>)

///////////////////////////////////// ALLOWABLE FLIGHT ZONES /////////////////////////////////////
/**
* Retrieves the country code where the aircraft is allowed to fly. The aircraft can only fly within allowable zones.
* @param aircraftSN Aircraft serial number
*/
fun getAircraftFlyZoneCountryCode(
aircraftSN: String,
callback: CommonCallbacks.CompletionCallbackWithParam<List<FlyableZoneInfo>>
)

/**
* Refreshes allowable flight zones. After the aircraft is activated, this method needs to be called to refresh allowable flight zones.
*/
fun refreshFlyZone()

///////////////////////////////////// HOT ZONES /////////////////////////////////////
/**
* Retrieves hot zones where the aircraft is prohibited from flying.
*/
fun getHotZoneCountryCode(callback: CommonCallbacks.CompletionCallbackWithParam<List<String>>)

/**
* Determines whether the current country code is a hot zone.
* @param countryCode Country code
*/
fun isHotZoneCountry(countryCode: String): Boolean
}

/**
* Coordinates information.
*/
data class LocationCoordinate2D(val latitude: Double, val longitude: Double)

/**
* Information about flight restriction zones.
*/
data class FlyZoneInformation(
/**
* ID of the flight restriction zone.
*/
val flyZoneId: Long,
/**
* Name of the flight restriction zone.
*/
val name: String?,
/**
* Type of the flight restriction zone.
*/
val category: FlyZoneCategory,
/**
* Shape of the flight restriction zone.
*/
val shape: FlyZoneShape,
/**
* Lower limit of the flight restriction zone in meters.
*/
val lowerLimit: Double,
/**
* Upper limit of the flight restriction zone in meters.
*/
val upperLimit: Double,
/**
* Center coordinates of the circle.
*/
val circleCenter: LocationCoordinate2D?,
/**
* Radius of the circle in meters.
*/
val circleRadius: Double,
/**
* Points of the polygon.
*/
val polygonPoints: List<LocationCoordinate2D>? = null
)

/**
* Flight restriction policies, including no-fly zones, authorized zones, warning zones, and enhanced warning zones.
*/
enum class FlyZoneCategory(val type: Int) {
UNKNOWN(-1),
/**
* Warning zone.
*/
WARNING(0),
/**
* Authorized zone.
*/
AUTHORIZATION(1),
/**
* Restricted zone.
*/
RESTRICTED(2),
/**
* Enhanced warning zone.
*/
ENHANCED_WARNING(3)
}

/**
* Shapes of flight restriction zones, including circles and polygons.
*/
enum class FlyZoneShape(val type: Int) {
UNKNOWN(-1),
/**
* Circle.
*/
CIRCLE(0),
/**
* Polygon.
*/
POLYGON(1)
}

/**
* Information about authorized flight zones, currently only circular regions are supported.
*/
data class FlyZoneAuthInformation(
/**
* Unique identifier.
*/
val id: String,
/**
* Aircraft serial number.
*/
val aircraftSN: String,
/**
* Name of the authorized flight zone.
*/
val name: String,
/**
* Longitude of the authorized flight zone.
*/
val longitude: Double,
/**
* Latitude of the authorized flight zone.
*/
val latitude: Double,
/**
* Radius of the authorized flight zone.
*/
val radius: Float,
/**
* Height of the authorized flight zone.
*/
val height: Float,
/**
* Start timestamp of the authorized flight zone validity period in seconds.
*/
val startTimeStamp: Long,
/**
* End timestamp of the authorized flight zone validity period in seconds.
*/
val endTimeStamp: Long,
)

/**
* Information about allowable flight zones.
*/
data class FlyableZoneInfo(
/**
* Country code.
*/
val countryCode: String,
/**
* Start timestamp.
*/
val startTimestamp: Long,
/**
* End timestamp.
*/
val endTimestamp: Long,
/**
* Zone type.
*/
val zoneType: Int
)