Skip to main content

Perception Tutorial


Perception Tutorial

1. Overview

The MSDK Perception Module enables the aircraft's perception and obstacle avoidance management capabilities. The SDK provides settings for obstacle avoidance types, warning distances for (horizontal, above, below) obstacle avoidance, and stopping distances for (horizontal, above, below) obstacle avoidance. It also supports retrieving visual obstacle information data to continuously monitor distance information between radars and obstacles in multiple directions. Through the perception module, developers can better develop and maintain functions related to perception and obstacle avoidance.

2. Obstacle Avoidance Types

There are three states for obstacle avoidance types: Off, Brake, Go Around. Retrieving and setting obstacle avoidance type data requires a pre-established connection with the aircraft.

2.1 Setting Obstacle Avoidance Type

The example code is as follows:

PerceptionManager.get()
.setObstacleAvoidanceType(type, object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
// success
}

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

The obstacle avoidance type can be set through type, which is the enumeration class of ObstacleAvoidActionenum.

2.2 Obtain obstacle avoidance type

The example code is as follows:

        PerceptionManager.get().getObstacleAvoidanceType(object :
CommonCallbacks.CompletionCallbackWithParam<ObstacleAvoidActionEnum> {
override fun onSuccess(t: ObstacleAvoidActionEnum?) {
//success
}

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

})

This method also obtains data of type ObstackleAvoidActionenum.

3. Warning Distances

3.1 Getting Warning Distances

Warning distances are categorized into warning distances for the upward radar, downward radar, and horizontal radar. Setting and getting warning distances require that a connection with the aircraft has already been established.

The example code is as follows:

        PerceptionManager.get()
.getObstacleAvoidanceWarningDistance(direction = PerceptionDirection.HORIZONTAL,
object : CommonCallbacks.CompletionCallbackWithParam<Double> {
override fun onSuccess(t: Double?) {
//success
}

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

})

Parameter description: direction, see PerceptionDirection.

3.2 Set alarm distance

The example code is as follows:

        PerceptionManager.get().setObstacleAvoidanceWarningDistance(distance = distance.toDouble(),
direction = PerceptionDirection.UPWARD,
object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
//success
}

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

})

Parameter description: Distance: alarm distance Direction: direction

4. Stopping Distances

Stopping distances refer to the distances at which the aircraft will come to a halt when it encounters an obstacle. These distances are categorized into stopping distances for the upward, downward, and horizontal directions. Note that the stopping distance must be less than or equal to the warning distance.

4.1 Getting Stopping Distances

The example code is as follows:

        PerceptionManager.get()
.getObstacleAvoidanceBrakingDistance(direction = PerceptionDirection.HORIZONTAL,
object : CommonCallbacks.CompletionCallbackWithParam<Double> {
override fun onSuccess(t: Double?) {
//success
}

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

})

Parameter Description:

direction: Direction, see PerceptionDirection for details.

4.2 Set the braking distance

The example code is as follows:

        PerceptionManager.get().setObstacleAvoidanceBrakingDistance(distance = distance.toDouble(),
direction = PerceptionDirection.UPWARD,
object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
//success
}

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

})

Parameter Description:

distance: The distance value to set or retrieve. direction: Direction, see PerceptionDirection for details.

5. Obtaining Radar Visual Obstacle Data

5.1 Activate visual radar:

PerceptionManager.get().getRadarManager()?.addRadarInformationListener(this)

5.2 Deactivate visual radar:

 PerceptionManager.get().getRadarManager()?.removeRadarInformationListener(this)

5.3 radar data acquisition:

    override fun onValueChange(
oldValue: List<VisionRadarInfoBean>?,
newValue: List<VisionRadarInfoBean>
) {

}

6.Sample Retrieval

Refer to the PerceptionFragment in the sample for usage.

7.Interface Description

enum class ObstacleAvoidActionEnum(val value: Int) {
CLOSE(0), // Off
STOP(1), // Brake
BYPASS(2) // Go Around
}

enum class PerceptionDirection {
UPWARD, // Upward
DOWNWARD, // Downward
HORIZONTAL // Horizontal, includes front, back, left, and right directions
}

data class VisionRadarInfoBean(
/**
*timestamp
*/
var timeStamp: Long = 0,
/**
*sensor position
*/
var position: VisionSensorPositionEnum = VisionSensorPositionEnum.FRONT,
/**
*distance
*/
var distances: List<Float>? = null

)

enum class VisionSensorPositionEnum(var value: Int) {
FRONT(0),
REAR(1),
BOTTOM(2),
RIGHT(3),
LEFT(4),
TOP(5)
}