Mobile-SDK-Android-V5
Mobile-SDK-Android-V5 copied to clipboard
DistanceRCWidget not working
Hi, I use DJI RC Pro model RM510 dji_version = '5.8.0' Problem - Distance not shown I debug DistanceRCWidgetModel
override fun updateStates() {
if (productConnectionProcessor.value) {
val location = aircraftLocationProcessor.value
if(!location.latitude.isNaN() && !location.longitude.isNaN() ) {
Log.e(TAG, "updateStates aircraftLocation = ${aircraftLocationProcessor.value}")
} else {
Log.e(TAG, "updateStates aircraftLocation = NAN")
}
val rcGPSData = rcGPSDataProcessor.value
Log.e(TAG, "updateStates rcGPSData location = ${rcGPSData.location}, isValid = ${rcGPSData.isValid}")
val isLatitude = LocationUtil.checkLatitude(aircraftLocationProcessor.value.latitude)
val isLongitude = LocationUtil.checkLongitude(aircraftLocationProcessor.value.longitude)
val isRemoteData = rcGPSDataProcessor.value.isValid
Log.e(TAG, "updateStates isLatitude = $isLatitude, isLongitude = $isLongitude, isRemoteData = $isRemoteData")
if (isLatitude && isLongitude && isRemoteData) {
distanceRCStateProcessor.onNext(
CurrentDistanceToRC(
distanceBetween(
aircraftLocationProcessor.value.latitude,
aircraftLocationProcessor.value.longitude,
rcGPSDataProcessor.value.location.latitude,
rcGPSDataProcessor.value.location.longitude
)
.toDistance(unitTypeDataProcessor.value),
unitTypeDataProcessor.value
)
)
} else {
Log.e(TAG, "-> LocationUnavailable")
distanceRCStateProcessor.onNext(LocationUnavailable)
}
} else {
Log.e(TAG, "-> ProductDisconnected")
distanceRCStateProcessor.onNext(ProductDisconnected)
}
}
Logs for this (Drone not connected): updateStates aircraftLocation = NAN updateStates rcGPSData location = null, isValid = false updateStates isLatitude = false, isLongitude = false, isRemoteData = false -> LocationUnavailable
My controller has GPS location, I get location by google api, but rcGPSDataProcessor - no location data Can you check? Thanks
Agent comment from yating.liao in Zendesk ticket #99321:
Please wait for a while as we will go and check the effect of RemoteControllerKey.KeyRcGPSInfo.
°°°
Agent comment from yating.liao in Zendesk ticket #99321:
The RemoteControllerKey.KeyRcGPSInfo retrieves location information from the built-in GPS module in the remote controller. However, the current interface provided by Android allows for obtaining location services through network connectivity. Therefore, the situation you are experiencing is a possibility.
To address this, you can make modifications to the DistanceRCWidget so that it utilizes the Android interface to retrieve the current device's location.
°°°
@dji-dev Hi, ok. I hoped that when receiving satellites the widget would start working. It turns out that at the moment if there is an Internet connection, then this widget does not work?
Agent comment from yating.liao in Zendesk ticket #99321:
The DistanceRCWidgetModel uses the RemoteControllerKey.KeyRcGPSInfo to obtain the position of the remote controller. The RemoteControllerKey.KeyRcGPSInfo is only generated when the GPS module of the remote controller is able to locate the current position. Therefore, the DistanceRCWidgetModel may not be able to obtain the position information when it is possible to obtain the position through the Android interface, as the Android interface can obtain the position information through the internet, while the RemoteControllerKey.KeyRcGPSInfo only relies on GPS.
You can add the part about obtaining the position information of the remote controller through the internet based on your use case, so that the DistanceRCWidgetModel can work in more environments.
°°°
Hi, I am experiencing that bug. The GPS is correctly obtained, based through other apps. I disconnected the remote controller from internet to be sure that the position used is the one get by the GPS signal. It did not solved the problem, position data never arrives.
Agent comment from yating.liao in Zendesk ticket #99321:
Can you please record a video for us to see the remote control you are using, as well as the performance of other apps and the DistanceRCWidget? Please note that there may be location caching within the app, but the DistanceRCWidget does not cache location information. To confirm if other apps are obtaining location information through the GPS module, you can either create a simple app yourself or clear the cache of this app.
Also, please note that generally, there is no GPS signal indoors. Here is the upload address: https://pan-sec.djicorp.com/s/3P96NJXPcT5EWYP The password is dji123. @pouss06
°°°