dji-sdk / Mobile-SDK-Android

DJI Mobile SDK for Android: http://developer.dji.com/mobile-sdk/
Other
972 stars 579 forks source link

AIRCRAFT_LOCATION KeyListener sends invalid information `NaN` as lat/lon values #1220

Closed brien-crean closed 1 year ago

brien-crean commented 1 year ago

A KeyListener set to listen to AIRCRAFT_LOCATION changes sends invalid information after some time during VirtualStick flight. For example the below configured aircraft location listener sends NaN for the longitude and latitude values. This happens intermittently and when it does no valid information is sent afterwards. It never recovers

fun addAircraftLocationListener() {
    val aircraftLocationKey: DJIKey = FlightControllerKey.create(FlightControllerKey.AIRCRAFT_LOCATION)
    val aircraftLocationListener =
        KeyListener { oldValue: Any?, newValue: Any? ->
            if (newValue is LocationCoordinate3D) {
                val location = newValue as LocationCoordinate3D?
                if (location != null) {
                    println("latitude: ${location.latitude},longitude: ${location.longitude}")
                }
            }
        }
    DJISDKManager.getInstance().keyManager!!.addListener(aircraftLocationKey, aircraftLocationListener)
}

SDK version: 4.16.4 Drones: Mini 2, Mavic Pro running latest available firmware versions

DJI-William commented 1 year ago

Please read this article, Why I have received NaN for aircraft location? You can connect your aircraft with DJI Assistant 2's simulator to mock a GPS signal.

brien-crean commented 1 year ago

This is happening while the simulator is running. I get valid aircraft location values from the simulator and then all of a sudden I get NaN values

DJI-William commented 1 year ago

It means something wrong in the simualtor then such as lost cable connection.