RTK教程
RTK教程
1. 概述
RTK(Real-time Kinematic)即载波相位动态实时差分技术,是常用的全球定位测量方法,可提供厘米级的定位精度。目前支持机载千寻网络RTK和Ntrip RTK的接入。
2. 接口调用流程
2.1 添加RTK流程状态监听
示例代码如下:
RTKCenter.get().addRTKSystemStateListener(this)
2.2 初始化
示例代码如下:
RTKCenter.get().init()
注意:方法中默认设置RTK模块为启用状态。
2.3 RTK模块启用状态
获取RTK启用状态,示例代码:
RTKCenter.get().getAircraftRTKModuleEnabled(onSuccess = {
//success
}, onFailure = { code, msg ->
//failure
})
设置启用状态,示例代码:
RTKCenter.get().setAircraftRTKModuleEnabled(isChecked, onSuccess = {
//success
}, onFailure = { code, msg ->
//failure
})
2.4 RTK信号模式
获取信号模式,示例代码如下:
RTKCenter.get().getRTKSignalMode(onSuccess = { mode ->
//success
}, onFailure = { code, msg ->
//failure
})
设置信号模式,示例代码如下:
RTKCenter.get().switchRTKSignalMode(mode, onSuccess = {
//success
}, onFailure = { code, msg ->
//failure
})
2.5 RTK信号类型
获取信号类型,示例代码:
RTKCenter.get().getRTKSignalType(onSuccess = { type ->
//success
}, onFailure = { code, msg ->
//failure
})
设置信号类型,示例代码:
RTKCenter.get()
.switchRTKSignalType(rtkSignal = type, rtkConfig = getRtkConfig(), onSuccess = {
//success
}, onFailure = { code, msg ->
//failure
})
注意:设置信号类型会触发相应RTK服务的登录操作。
2.6 移除监听器
示例代码如下:
RTKCenter.get().removeRTKSystemStateListener(this)
3.Sample获取
参考Sample中RTKCenterFragment
4.接口说明
/**
* Copyright: Autel Robotics
* @author Autel on 2024/10/16
* RTK管理类
*/
interface IRTKCenter {
/**
* 初始化
*/
fun init()
/**
* 销毁,释放资源
*/
fun destroy()
/**
* 添加RTK流程状态监听器
* @param listener
*/
fun addRTKSystemStateListener(listener: RTKSystemStateListener)
/**
* 移除RTK流程状态监听器
*/
fun removeRTKSystemStateListener(listener: RTKSystemStateListener)
/**
* 移除所有RTK流程状态监听器
*/
fun clearAllRTKSystemStateListener()
/**
* 是否开启RTK模块
* @param isEnabled
* @param onSuccess
* @param onFailure
*/
fun setAircraftRTKModuleEnabled(
isEnabled: Boolean,
onSuccess: () -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit
)
/**
* 获取是否开启RTK模块
* @param onSuccess
* @param onFailure
*/
fun getAircraftRTKModuleEnabled(
onSuccess: (Boolean) -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit,
)
/**
* 切换RTK信号模式
* @param rtkSignalMode 信号模式
* @param onSuccess
* @param onFailure
*/
fun switchRTKSignalMode(
rtkSignalMode: RTKSignalModeEnum,
onSuccess: () -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit,
)
/**
* 获取RTK信号模式
* @param onSuccess
* @param onFailure
*/
fun getRTKSignalMode(
onSuccess: (RTKSignalModeEnum?) -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit,
)
/**
* 切换RTK信号类型
* @param rtkSignal
* @param rtkConfig
* @param onSuccess
* @param onFailure
*/
fun switchRTKSignalType(
rtkSignal: RTKSignalEnum,
rtkConfig: NetWorkRTKConfig,
onSuccess: () -> Unit,
onFailure: (code: IAutelCode, msg: String?) -> Unit
)
/**
* 获取RTK信号类型
* @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 功能系统状态监听
*/
interface RTKSystemStateListener {
/**
* RTK 初始化
* @param status 状态信息
*/
fun onRTKInitStatus(status: RtkSystemStatusBean?)
/**
* RTK 登录状态
*/
fun onLoginStatus(status: RtkSystemStatusBean?)
/**
* 上报RTK数据
* @param report
*/
fun onRTKReportInfo(report: RtkReportBean?)
/**
* RTK 登出
*/
fun onLogoutState()
/**
* RTK 释放资源
*/
fun onDestory()
}
/**
* Copyright: Autel Robotics
* @author Autel on 2024/10/22
*/
data class NetWorkRTKConfig(
//通用参数
var commonConfig: RTKCommonConfig? = null,
//千寻参数
var qxRtkConfig: QXRTKConfig? = null,
//是否千寻
var isQianXun: Boolean? = false
)
//通用RT参数
data class RTKCommonConfig(
var host: String = "",
var port: Int = 0,
var userName: String = "",
var passWord: String = "",
//该值使用AUTO或null,用户可以输入自己获取的挂载点,但不建议这样
var mountPoint: String = "AUTO"
)
//千寻RTK 参数
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:失败,1成功
var code: Int = 0,
var msg: String = ""
)