RTK模块开启失败,CMCCRTK无法稳定调用
MSDK 5.10.0
机型:M3E
在使用setAircraftRTKModuleEnabled时,有时会出现这种错误,但等待一段时间后就可以正常启用:
FailedErrorImp{errorType='CORE', errorCode='REQUEST_HANDLER_NOT_FOUND', innerCode='', description='null', hint='error code = -1'}
在后续调用启用cmccRTK报错:
RTKCenter.getInstance().cmccrtkManager.startNetworkRTKService(coordinateSystem,callback)
start_CMCC_RTK FailedErrorImp{errorType='CORE', errorCode='REQUEST_HANDLER_NOT_FOUND', innerCode='-1', description='null', hint='error code = -1'}
有时候会报错:
start_CMCC_RTK FailedErrorImp{errorType='CORE', errorCode='INVALID_PARAM', innerCode='-6', description='null', hint='error code = -6'}
此时的RTKSystemState中的rtkReferenceStationSource默认为:NTRIP_NETWORK_SERVICE
在放置了一段时间之后,启用cmccrtkManager.startNetworkRTKService可以成功,请问是否是因为rtk相关调用需要一些前置准备?相关参数设置有哪些?在IRTKCenter中是否可以找到?
-
以下是我的测试代码:
@Composable
fun RtkSettingPage(RtkCenterViewModel: RtkCenterViewModel)
{
val rtkSystemStateLD by RtkCenterViewModel.rtkSystemStateLD.collectAsState()
val rtkEnable by RtkCenterViewModel.aircraftRTKModuleEnabledLD.collectAsState()
val rtkAccuracyMaintainLD by RtkCenterViewModel.rtkAccuracyMaintainLD.collectAsState()
val currentRTKState by RtkCenterViewModel.currentRTKState.collectAsState()
if(rtkSystemStateLD!=null) {
Column {
Text(text = "rtkConnected: ${rtkSystemStateLD!!.rtkConnected}")
Text(text = "isRTKEnabled: ${rtkEnable}")
Text(text = "satelliteInfo:${rtkSystemStateLD!!.satelliteInfo?.mobileStationReceiver1Info?.count()}")
Text(text = "rtkHealthy:${rtkSystemStateLD!!.rtkHealthy}")
Text(text = "rtkMaintainAccuracyEnabled:${rtkAccuracyMaintainLD}")
Text(text = "rtkReferenceStationSource:${rtkSystemStateLD!!.rtkReferenceStationSource}")
Text(text = "currentRTKState:${currentRTKState}")
Row{
Button(onClick = {
XLog.tag("RTK").i("click setAircraftRTKModuleEnabled ")
RtkCenterViewModel.setAircraftRTKModuleEnabled(true) }) {
Text(text = "开启rtk")
}
Button(onClick = {
RtkCenterViewModel.setRTKReferenceStationSource(RTKReferenceStationSource.QX_NETWORK_SERVICE)}
) {
Text(text = "设置QX rtk")
}
Button(onClick = {
RtkCenterViewModel.setRTKReferenceStationSource(RTKReferenceStationSource.NTRIP_NETWORK_SERVICE)}
) {
Text(text = "设置cmcc rtk")
}
Button(onClick = {
XLog.tag("RTK").i("click stop_CMCC_RTK ")
RtkCenterViewModel.stop_CMCC_RTK(object :
CommonCallbacks.CompletionCallback {
override fun onSuccess() {
XLog.tag("RTK").i("stopNetworkRTK success")
}
override fun onFailure(error: IDJIError) {
XLog.tag("RTK").e("stopNetworkRTK failed: ${error}")
}
})}
) {
Text(text = "关闭 CMCC RTK")
}
Button(onClick = {
XLog.tag("RTK").i("click start_CMCC_RTK ")
RtkCenterViewModel.start_CMCC_RTK(CoordinateSystem.WGS84, object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
XLog.tag("RTK").e("start_CMCC_RTK SUCCESS")
}
override fun onFailure(error: IDJIError) {
XLog.tag("RTK").e("start_CMCC_RTK Failed${error.toString()}")
}
})}) {
Text(text = "启动CMCC RTK")
}
}
}
}
}@HiltViewModel
class RtkCenterViewModel@Inject constructor(
val registrationStatus: MutableLiveData<Boolean>
) : ViewModel() {
private val _aircraftRTKModuleEnabledLD= MutableStateFlow<Boolean?>(false)
val aircraftRTKModuleEnabledLD=_aircraftRTKModuleEnabledLD //RTK开启状态
private val _rtkSystemStateLD=MutableStateFlow<RTKSystemState?>(null)
val rtkSystemStateLD =_rtkSystemStateLD //RTK SystemState信息
private val rtkLocationInfoListener = RTKLocationInfoListener {
_rtkLocationInfoLD.value=it
}
private val rtkSystemStateListener = RTKSystemStateListener {
_rtkSystemStateLD.value=it
}
// 网络RTK 状态 报错信息
private val _currentRTKState = MutableStateFlow(RTKServiceState.UNKNOWN)
private val _currentRTKErrorMsg = MutableStateFlow("")
val currentRTKState: StateFlow<RTKServiceState> = _currentRTKState
val currentRTKErrorMsg: StateFlow<String> = _currentRTKErrorMsg
init {
// 在初始化时添加监听器
Log.i("uavtest:","the registrationStatus is ${registrationStatus}")
registrationStatus.observeForever { status ->
if (status == true) {
//网络RTK 获得实例manager 监听
addNetworkRTKServiceInfoCallback()
//RTK模块状态监听
RTKCenter.getInstance().addRTKLocationInfoListener(rtkLocationInfoListener)
RTKCenter.getInstance().addRTKSystemStateListener(rtkSystemStateListener)
Log.i("uavtest:","the RTK initListeners success")
}
}
}
fun setAircraftRTKModuleEnabled(boolean: Boolean) {
RTKCenter.getInstance().setAircraftRTKModuleEnabled(boolean, object :CommonCallbacks.CompletionCallback{
override fun onSuccess() {
//结果以添加的listener结果为准
XLog.tag("RTK").i("setAircraftRTKModuleEnabled Success")
_aircraftRTKModuleEnabledLD.value= _rtkSystemStateLD.value?.isRTKEnabled
}
override fun onFailure(error: IDJIError) {
XLog.tag("RTK").e("setAircraftRTKModuleEnabled Failed${error.toString()}")
_aircraftRTKModuleEnabledLD.value=false
}
})
}
fun setRTKReferenceStationSource(source: RTKReferenceStationSource) {
RTKCenter.getInstance().setRTKReferenceStationSource(source, null)
}
fun start_CMCC_RTK(coordinateSystem: CoordinateSystem, callback: CommonCallbacks.CompletionCallback)
{
RTKCenter.getInstance().cmccrtkManager.startNetworkRTKService(coordinateSystem,callback)
}
fun stop_CMCC_RTK(callback: CommonCallbacks.CompletionCallback)
{
RTKCenter.getInstance().cmccrtkManager.stopNetworkRTKService(callback)
}
//网络 RTK 状态监听
private val networkServiceInfoListener: INetworkServiceInfoListener = object : INetworkServiceInfoListener {
override fun onServiceStateUpdate(state: RTKServiceState?) {
state?.let {
_currentRTKState.value = state
// 如果状态为 TRANSMITTING,则清空历史错误信息
XLog.tag("RTK").i("networkService ${_currentRTKState.value}")
if (it == RTKServiceState.TRANSMITTING) {
_currentRTKErrorMsg.value = ""
}
}
}
override fun onErrorCodeUpdate(code: IDJIError?) {
code?.let {
// 将错误信息更新到 MutableStateFlow
_currentRTKErrorMsg.value = code.toString()
}
}
}
fun addNetworkRTKServiceInfoCallback() {
// RTKCenter.getInstance().customRTKManager.addNetworkRTKServiceInfoListener(
// networkServiceInfoListener
// )
// RTKCenter.getInstance().qxrtkManager.addNetworkRTKServiceInfoListener(
// networkServiceInfoListener
// )
RTKCenter.getInstance().cmccrtkManager.addNetworkRTKServiceInfoListener(
networkServiceInfoListener
)
}
fun removeNetworkServiceInfoListener() {
RTKCenter.getInstance().customRTKManager.removeNetworkRTKServiceInfoListener(
networkServiceInfoListener
)
RTKCenter.getInstance().qxrtkManager.removeNetworkRTKServiceInfoListener(
networkServiceInfoListener
)
RTKCenter.getInstance().cmccrtkManager.removeNetworkRTKServiceInfoListener(
networkServiceInfoListener
)
} -
解决了,感谢您的回答,似乎是crash acra崩溃捕获库的问题,现在可以正常开启cmcc rtk;
但是我出现了闪退的问题,似乎是addNetworkRTKServiceInfoListener造成的,但我不清楚应该怎么设置
2024-11-05 20:43:37.774 4032-4032 AndroidRuntime com.example.app_zt E FATAL EXCEPTION: main
Process: com.example.app_zt, PID: 4032
java.lang.NullPointerException: Attempt to invoke interface method 'void dji.v5.manager.aircraft.rtk.network.INetworkServiceInfoListener.onServiceStateUpdate(dji.sdk.keyvalue.value.rtkbasestation.RTKServiceState)' on a null object reference
at dji.v5.inner.aircraft.rtk.network.co_a.co_e(BaseNetworkRTKManager.java:2)
at dji.v5.inner.aircraft.rtk.network.co_a.addNetworkRTKServiceInfoListener(BaseNetworkRTKManager.java:4)
at dji.v5.inner.aircraft.rtk.network.co_b.addNetworkRTKServiceInfoListener(CMCCRTKManager.java:1)
at com.example.app_zt.viewModel.RtkCenterViewModel.addNetworkRTKServiceInfoCallback(RtkCenterViewModel.kt:327)
at com.example.app_zt.viewModel.RtkCenterViewModel$1.invoke(RtkCenterViewModel.kt:124)
at com.example.app_zt.viewModel.RtkCenterViewModel$1.invoke(RtkCenterViewModel.kt:121)
at com.example.app_zt.viewModel.RtkCenterViewModel$sam$androidx_lifecycle_Observer$0.onChanged(Unknown Source:2)
at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:146)
at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(LiveData.java:483)
at androidx.lifecycle.LiveData.observeForever(LiveData.java:234)
at com.example.app_zt.viewModel.RtkCenterViewModel.<init>(RtkCenterViewModel.kt:121)
at com.example.app_zt.DaggerMyApplication_HiltComponents_SingletonC$ViewModelCImpl$SwitchingProvider.get(DaggerMyApplication_HiltComponents_SingletonC.java:569)
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory$2.createViewModel(HiltViewModelFactory.java:133)
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory$2.create(HiltViewModelFactory.java:104)
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:171)
at androidx.lifecycle.ViewModelProvider$Factory.create(ViewModelProvider.android.kt:158)
at androidx.lifecycle.viewmodel.ViewModelProviderImpl_androidKt.createViewModel(ViewModelProviderImpl.android.kt:34)
at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release(ViewModelProviderImpl.kt:65)
at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release$default(ViewModelProviderImpl.kt:47)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.android.kt:91)
at androidx.lifecycle.viewmodel.compose.ViewModelKt__ViewModelKt.get(ViewModel.kt:162)
at androidx.lifecycle.viewmodel.compose.ViewModelKt.get(Unknown Source:1)
at androidx.lifecycle.viewmodel.compose.ViewModelKt__ViewModel_androidKt.viewModel(ViewModel.android.kt:124)
at androidx.lifecycle.viewmodel.compose.ViewModelKt.viewModel(Unknown Source:1)
at com.example.app_zt.composable.MainPageKt.NavigationGraph(MainPage.kt:420)
at com.example.app_zt.composable.MainPage$onCreate$1.invoke(MainPage.kt:79)
at com.example.app_zt.composable.MainPage$onCreate$1.invoke(MainPage.kt:65)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:441)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:259)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:258)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:216)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:132)
2024-11-05 20:43:37.774 4032-4032 AndroidRuntime com.example.app_zt E at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:131)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:121)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:155)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:154)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:401)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:154)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:133)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:97)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3593)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3520)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:743)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1122)
at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:649)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:635)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:124)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1625)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:124)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:180)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.jvm.kt:320)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.jvm.kt:198)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:124)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1706)
at android.view.View.dispatchAttachedToWindow(View.java:20109)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3430)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2054)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1747)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7792)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1041)
at android.view.Choreographer.doCallbacks(Choreographer.java:864)
at android.view.Choreographer.doFrame(Choreographer.java:798)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1026)
at android.os.Handler.handleCallback(Handler.java:883)
2024-11-05 20:43:37.774 4032-4032 AndroidRuntime com.example.app_zt E at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7400)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
2024-11-05 20:43:37.865 4032-4032 CrashReport com.example.app_zt E Crash md5: 2c00c844dcc9f604369568e2f2310b71
2024-11-05 20:43:37.993 892-892 Layer surfaceflinger E [Surface(name=AppWindowToken{872800f token=Token{a08f16e ActivityRecord{41ce0e9 u0 com.example.app_zt/.composable.MainPage t59}}})/@0x3ca815d - animation-leash#0] No local sync point found
2024-11-05 20:43:38.874 4032-4032 Process com.example.app_zt I Sending signal. PID: 4032 SIG: 9
2024-11-05 20:43:38.906 1590-1812 InputDispatcher system_server E channel '609b22a com.example.app_zt/com.example.app_zt.composable.MainPage (server)' ~ Channel is unrecoverably broken and will be disposed!
---------------------------- PROCESS ENDED (4032) for package com.example.app_zt ----------------------------
请先登录再写评论。
评论
6 条评论