使用MSDK4.15进行启动RTK出错
Completed//先设置RTK数据源
rtk.setReferenceStationSource(ReferenceStationSource.CUSTOM_NETWORK_SERVICE) { djiError ->
if (djiError != null) {
LogUtils.x_e(TAG, "设置RTK数据源失败:${djiError}")
}
}
//设置坐标系
RTKNetworkServiceProvider.getInstance().setNetworkServiceCoordinateSystem(CoordinateSystem.WGS84) { djiError ->
if (djiError != null) {
LogUtils.x_e(TAG, "设置坐标系失败:${djiError}")
}
}
//设置开启RTK
rtk.setRtkEnabled(true) { djiError ->
if (djiError != null) {
LogUtils.x_e(TAG, "setRtkEnabled 失败:${djiError}")
}
}
//开启网络RTK服务
//设置rtk账号信息
val builder = NetworkServiceSettings.Builder()
builder.userName("sddd")
builder.password("fghjjkd")
builder.ip("203.107.45.154")
builder.port(8002)
builder.mountPoint("AUTO")
RTKNetworkServiceProvider.getInstance().customNetworkSettings = builder.build()
//开启网络RTK服务
RTKNetworkServiceProvider.getInstance()?.startNetworkService { djiError ->
if (djiError != null) {
LogUtils.x_e(TAG, "startNetworkService 失败:${djiError}")
}
}
//监听RTK状态
rtk.setStateCallback { rtkState ->
var rtkStateInfo = ""
rtkStateInfo += " RTK is being used: ${rtkState.isRTKBeingUsed}\n"
rtkStateInfo += " Positioning solution: ${rtkState.positioningSolution.name}\n"
rtkStateInfo += " Fusion latitude: ${rtkState.fusionMobileStationLocation.latitude}\n"
rtkStateInfo += " Fusion longitude: ${rtkState.fusionMobileStationLocation.longitude}\n"
rtkStateInfo += " Fusion altitude: ${rtkState.fusionMobileStationAltitude}\n"
rtkStateInfo += " Heading valid: ${rtkState.isHeadingValid}\n"
rtkStateInfo += " Fusion heading: ${rtkState.fusionHeading}\n"
rtkStateInfo += " HomePoint Location: ${rtkState.homePointLocation?.latitude} ${rtkState.homePointLocation?.longitude}\n"
rtkStateInfo += " Distance to HomePoint: ${rtkState.distanceToHomePoint}\n"
LogUtils.x_d(TAG, "RTK状态:${rtkStateInfo}")
}
//监听RTK网络服务状态
RTKNetworkServiceProvider.getInstance().addNetworkServiceStateCallback { netWorkState ->
LogUtils.x_d(TAG, "RTK网络服务状态:${netWorkState.channelState.name}")
}
//监听RTK使用状态
rtk.getRtkEnabled(object : CommonCallbacks.CompletionCallbackWith<Boolean> {
override fun onSuccess(isEnable: Boolean) {
if (isEnable) {
LogUtils.x_d(TAG, "RTK已启用")
} else {
LogUtils.x_d(TAG, "RTK已关闭")
}
}
override fun onFailure(djiError: DJIError) {
LogUtils.x_e(TAG, "获取RTK失败: $djiError")
}
})
//监听RTK连接状态
rtk.setRtkConnectionStateWithBaseStationCallback { rtkConnectionStationReferenceSource, rtkBaseStationInformation ->
LogUtils.x_d(TAG,"与基站参考源的RTK连接状态: $rtkConnectionStationReferenceSource RTK基站信息:${rtkBaseStationInformation}");
}
错误日志如下:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Enum.ordinal()' on a null object reference
at dji.common.remotecontroller.RCMode.getCurrentMode()
at dji.sdk.network.RTKNetworkServiceProvider.startNetworkService()
Please sign in to leave a comment.
Comments
1 comment