Fixed-wing UAV Pre-flight Check Tutorial
UAV Pre-flight Check Tutorial
1. Overview
Before mission takeoff, it is necessary to perform a pre-flight check on the aircraft to ensure all modules are functioning normally. Only after confirming everything is working properly can the mission route file be uploaded to the aircraft for execution.
2. Pre-flight Check Process
3. Pre-flight Check Example Code
3.1 Listening to Pre-flight Check Results
AutoCheckManager.setAutoCheckListener(object : AutoCheckListener {
/**
* Pre-flight check started successfully
*/
override fun onStartCheckSuccess() {
SDKLog.i(TAG, "autoSafeCheck Success")
}
/**
* Pre-flight check failed to start
*/
override fun onStartCheckFail(error: IAutelCode) {
SDKLog.e(TAG, "autoSafeCheck Fail: $error")
}
/**
* Pre-flight check results
*/
override fun onAutoCheckResult(result: DFAutoCheckResultBean?) {
dealAutoCheckResult(result)
}
})
3.2 Starting Pre-flight Check
val checkType = AutoCheckTypeEnum.ALL
AutoCheckManager.startAutoCheck(checkType)
//Pre-flight check type enumeration
enum class AutoCheckTypeEnum {
FONT_MOTOR, //Check front motor
BEHIND_MOTOR, //Check rear motor
LEFT_MOTOR, //Check left motor
RIGHT_MOTOR, //Check right motor
LEFT_STEER, //Check left servo
RIGHT_STEER, //Check right servo
BEHIND_STEER, //Check rear servo
AIRSPEED, //Check airspeed sensor
ULTRASONIC, //Check ultrasonic sensor
RTK, //Check RTK
GPS, //Check GPS
BAROMETER, //Check barometer
REMOTE, //Check RC
PAYLOAD, //Check payload
MAGNETOMETER_1, //Check magnetometer 1
IMU_1, //Check IMU 1
MAGNETOMETER_2, //Check magnetometer 2
IMU_2, //Check IMU 2
ALL; //Check all
}
3.3 Querying Pre-flight Check Results
Example code:
private fun dealAutoCheckResult(t: DFAutoCheckResultBean?) {
SDKLog.d(TAG, "KeyDroneGetAutoCheckResult onSuccess: $t")
//All modules passed pre-flight check, ready to execute mission
val isCheckOK = t?.isLeftSteerNormal() == true
&& t?.isRightSteerNormal() == true
&& t?.isBehindSteerNormal() == true
&& t?.isAirSpeedNormal() == true
&& t?.isImu1Normal() == true
&& t?.isImu2Normal() == true
&& (t?.isGPSNormal() == true || t?.isRTKNormal() == true)
&& t?.isMagnetometer1normal() == true
&& t?.isMagnetometer2normal() == true
&& t?.isUltrasonicNormal() == true
&& t?.isBarometerNormal() == true
&& t?.isBatteryNormal() == true
&& t?.isGimbalNormal() == true
&& t?.isRemoteControllerNormal() == true
&& t?.isFontMotorNormal() == true
&& t?.isLeftMotorNormal() == true
&& t?.isRightMotorNormal() == true
&& t?.isBehindMotorNormal() == true
&& t?.isPayloadNormal() == true
&& t?.isAttitudeNormal() == true
&& t?.isRTKHeadingNormal() == true
&& t?.isNavigationAttitudeNormal() == true
&& t?.isMaintenancReminder() == true
&& t?.isVersionMatching() == true
&& t?.isElectronicFenceNormal() == true
&& t?.isNavigationAndRTKNormal() == true
})
data class DFAutoCheckResultBean(var autoCheckResult: Int = 0) {
/**
* Front motor
*
* @return true-normal, false-abnormal
*/
fun isFontMotorNormal(): Boolean {
return (autoCheckResult and 0x1) == 0
}
/**
* Rear motor
*/
fun isBehindMotorNormal(): Boolean {
return (autoCheckResult shr 1 and 0x1) == 0
}
/**
* Left motor
*/
fun isLeftMotorNormal(): Boolean {
return (autoCheckResult shr 2 and 0x1) == 0
}
/**
* Right motor
*/
fun isRightMotorNormal(): Boolean {
return (autoCheckResult shr 3 and 0x1) == 0
}
/**
* Left servo
*/
fun isLeftSteerNormal(): Boolean {
return (autoCheckResult shr 4 and 0x1) == 0
}
/**
* Right servo
*/
fun isRightSteerNormal(): Boolean {
return (autoCheckResult shr 5 and 0x1) == 0
}
/**
* Rear servo
*/
fun isBehindSteerNormal(): Boolean {
return (autoCheckResult shr 6 and 0x1) == 0
}
/**
* Airspeed sensor
*/
fun isAirSpeedNormal(): Boolean {
return (autoCheckResult shr 7 and 0x1) == 0
}
/**
* Ultrasonic sensor
*/
fun isUltrasonicNormal(): Boolean {
return (autoCheckResult shr 8 and 0x1) == 0
}
/**
* RTK
*/
fun isRTKNormal(): Boolean {
return (autoCheckResult shr 9 and 0x1) == 0
}
/**
* GPS
*/
fun isGPSNormal(): Boolean {
return (autoCheckResult shr 10 and 0x1) == 0
}
/**
* Barometer
*/
fun isBarometerNormal(): Boolean {
return (autoCheckResult shr 11 and 0x1) == 0
}
/**
* Remote controller
*/
fun isRemoteControllerNormal(): Boolean {
return (autoCheckResult shr 12 and 0x1) == 0
}
/**
* Payload
*/
fun isPayloadNormal(): Boolean {
return (autoCheckResult shr 13 and 0x1) == 0
}
/**
* Magnetometer
*/
fun isMagnetometer1normal(): Boolean {
return (autoCheckResult shr 14 and 0x1) == 0
}
/**
* IMU
*/
fun isImu1Normal(): Boolean {
return (autoCheckResult shr 15 and 0x1) == 0
}
/**
* Magnetometer 2
*/
fun isMagnetometer2normal(): Boolean {
return (autoCheckResult shr 16 and 0x1) == 0
}
/**
* IMU
*/
fun isImu2Normal(): Boolean {
return (autoCheckResult shr 17 and 0x1) == 0
}
/**
* Battery
*/
fun isBatteryNormal(): Boolean {
return (autoCheckResult shr 18 and 0x1) == 0
}
/**
* Gimbal
*/
fun isGimbalNormal(): Boolean {
return (autoCheckResult shr 19 and 0x1) == 0
}
/**
* Altimeter
*/
fun isAttitudeNormal(): Boolean {
return (autoCheckResult shr 20 and 0x1) == 0
}
/**
* RTK heading normal
*/
fun isRTKHeadingNormal(): Boolean {
return (autoCheckResult shr 21 and 0x1) == 0
}
/**
* Navigation attitude
*/
fun isNavigationAttitudeNormal(): Boolean {
return (autoCheckResult shr 22 and 0x1) == 0
}
/**
* Maintenance reminder
*/
fun isMaintenancReminder(): Boolean {
return (autoCheckResult shr 23 and 0x1) == 0
}
/**
* Version matching
*/
fun isVersionMatching(): Boolean {
return (autoCheckResult shr 24 and 0x1) == 0
}
/**
* Electronic fence
*/
fun isElectronicFenceNormal(): Boolean {
return (autoCheckResult shr 25 and 0x1) == 0
}
/**
* Magnetic heading matches RTK heading
*/
fun isNavigationAndRTKNormal(): Boolean {
return (autoCheckResult shr 31 and 0x1) == 0
}
}
4. Reference Code
For complete implementation of the pre-flight check interface, please refer to the PreFlightCheckHelper in the Sample.