RTK Tutorial
RTK Tutorial
1. 概述
RTK (Real-time Kinematic) is a commonly used method for global positioning measurement that can provide centimeter-level positioning accuracy. It currently supports access to Qianxun network RTK and Ntrip RTK.
2. Interface Call Flow
2.1 Add RTK Process Status Listener
Example code as follows:
RTKCenter.get().addRTKSystemStateListener(this)
2.2 Initialization
Example code as follows:
RTKCenter.get().init()
Note: By default, the RTK module is set to enabled state in this method.
2.3 RTK Module Enable Status
Get the enable status of RTK, example code:
RTKCenter.get().getAircraftRTKModuleEnabled(onSuccess = {
//success
}, onFailure = { code, msg ->
//failure
})
Set the enable status, example code:
RTKCenter.get().setAircraftRTKModuleEnabled(isChecked, onSuccess = {
//success
}, onFailure = { code, msg ->
//failure
})
2.4 RTK Signal Mode
Get the signal mode, example code:
RTKCenter.get().getRTKSignalMode(onSuccess = { mode ->
//success
}, onFailure = { code, msg ->
//failure
})
Set the signal mode, example code:
RTKCenter.get().switchRTKSignalMode(mode, onSuccess = {
//success
}, onFailure = { code, msg ->
//failure
})
2.5 RTK Signal Type
Get the signal type, example code:
RTKCenter.get().getRTKSignalType(onSuccess = { type ->
//success
}, onFailure = { code, msg ->
//failure
})
Set the signal type, example code:
RTKCenter.get()
.switchRTKSignalType(rtkSignal = type, rtkConfig = getRtkConfig(), onSuccess = {
//success
}, onFailure = { code, msg ->
//failure
})
Note: Setting the signal type will trigger the login operation for the corresponding RTK service.
2.6 Remove Listener
Example code as follows:
RTKCenter.get().removeRTKSystemStateListener(this)
3.Sample Acquisition
Refer to RTKCenterFragment in the Sample
4.Interface Description
/**
* Copyright: Autel Robotics
* @author Autel on 2024/10/16
* RTK Management Class
*/
interface IRTKCenter {
/**
* Initialize
*/
fun init()
/**
* Destroy, release resources
*/
fun destroy()
/**
* Add RTK process status listener
* @param listener
*/
fun addRTKSystemStateListener(listener: RTKSystemStateListener)
/**
* Remove RTK process status listener
*/
fun removeRTKSystemStateListener(listener: RTKSystemStateListener)
/**
* Remove all RTK process status listeners
*/
fun clearAllRTKSystemStateListener()
/**
* Whether RTK module is enabled
* @param isEnabled
* @param onSuccess
* @param onFailure
*/
fun setAircraftRTKModuleEnabled(
isEnabled: Boolean,
onSuccess: () -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit
)
/**
* Get whether RTK module is enabled
* @param onSuccess
* @param onFailure
*/
fun getAircraftRTKModuleEnabled(
onSuccess: (Boolean) -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit,
)
/**
* Switch RTK signal mode
* @param rtkSignalMode Signal mode
* @param onSuccess
* @param onFailure
*/
fun switchRTKSignalMode(
rtkSignalMode: RTKSignalModeEnum,
onSuccess: () -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit,
)
/**
* Get RTK signal mode
* @param onSuccess
* @param onFailure
*/
fun getRTKSignalMode(
onSuccess: (RTKSignalModeEnum?) -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit,
)
/**
* Switch RTK signal type
* @param rtkSignal
* @param rtkConfig
* @param onSuccess
* @param onFailure
*/
fun switchRTKSignalType(
rtkSignal: RTKSignalEnum,
rtkConfig: NetWorkRTKConfig,
onSuccess: () -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit
)
/**
* Get RTK signal type
* @param onSuccess
* @param onFailure
*/
fun getRTKSignalType(
onSuccess: (RTKSignalEnum?) -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit,
)
}
/**
* Copyright: Autel Robotics
* @author Autel on 2024/10/17
* RTK Function System Status Listener
*/
interface RTKSystemStateListener {
/**
* RTK Initialization
* @param status Status information
*/
fun onRTKInitStatus(status: RtkSystemStatusBean?)
/**
* RTK Login Status
*/
fun onLoginStatus(status: RtkSystemStatusBean?)
/**
* Report RTK Data
* @param report
*/
fun onRTKReportInfo(report: RtkReportBean?)
/**
* RTK Logout
*/
fun onLogoutState()
/**
* Release RTK Resources
*/
fun onDestory()
}
/**
* Copyright: Autel Robotics
* @author Autel on 2024/10/22
*/
data class NetWorkRTKConfig(
//General Parameters
var commonConfig: RTKCommonConfig? = null,
//Qianxun Parameters
var qxRtkConfig: QXRTKConfig? = null,
//Is Qianxun
var isQianXun: Boolean? = false
)
//General RT Parameters
data class RTKCommonConfig(
var host: String = "",
var port: Int = 0,
var userName: String = "",
var passWord: String = "",
//This value uses AUTO or null; users can enter their own mount point but it is not recommended.
var mountPoint: String = "AUTO"
)
//Qianxun RTK Parameters
data class QXRTKConfig(
var key: String? = "",
var secret: String? = "",
var deviceType: String? = "",
var deviceId: String? = ""
)
/**
* Copyright: Autel Robotics
* @author Autel on 2024/10/22
*/
data class RtkSystemStatusBean(
//0: Failure, 1 Success
var code: Int = 0,
var msg: String = ""
)