Android Question [Solved] DJI and JavaObject, get maxangularvelocity and airsense

schimanski

Well-Known Member
Licensed User
Longtime User
1.
I want to get the MaxAngularVelocity for a hotspot-mission. The following code works sometimes, but not alway:

B4X:
If HotPointOperator.IsInitialized Then
        Dim HotPointMissionControl As JavaObject = HotPointOperator
        Dim RadiusSicherung As Double=50

        Dim cc As Object=HotPointMissionControl.CreateEventFromUI("dji.common.util.CommonCallbacks$CompletionCallbackWith", "callback", Null)
        HotPointMissionControl.RunMethod("getMaxAngularVelocityForRadius", Array(RadiusSicherung,cc))
        Wait For Callback_Event (MethodName As String, args() As Object)
        Dim MaxAngularVelocity As Float = args(0)
End If

Sometimes, i get the following error in args(0):

B4X:
java.lang.NumberFormatException: For input string: "dji.common.gimbal.GimbalState@f794e52d"

Is it the wrong callback-event?

2.
The second problem is, that i want to read the warninglevel of the AirSenseSystemInformation:

https://developer.dji.com/api-refer...sesysteminformation_systemwarninglevel_inline


B4X:
Dim flightcontrollerjo As JavaObject = controller
Dim airsense As JavaObject = flightcontrollertjo.RunMethod("AirSenseSystemInformation", Null)
If airsense.IsInitialized Then
        Log("AirSense initialisiert!")
        Dim cc As Object = airsense.CreateEventFromUI("dji.common.flightcontroller.adsb$Callback", "callback", Null)
        airsense.RunMethod("setStateCallback", Array As Object(cc))
        Wait For (airsense) callback_Event (MethodName As String, Args() As Object)
        Dim airsensestate As JavaObject= Args(0)
        Dim WarningLevel As String = airsensestate.RunMethod("getWarningLevel", Null)
        Log("Warning-Level:" & WarningLevel)
Else
        Log("ADSP not ready!")
End If

It is already failing by initializing the airsense-object. Could somebody, who is familar with javaobject, help me? Thank you very much...
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. First step is to add:
B4X:
Log(MethodName)
What is the output when the error appears?

2. Something like:
B4X:
Dim callback As Object = flightcontrollerjo.CreateEventFromUI("dji.common.flightcontroller.adsb.AirSenseSystemInfomration$Callback", "AirSenseCallback", Null)
flightcontrollerjo.RunMethod("setASBInformationCallback", Array(callback))

Sub AirSenseCallback_Event (MethodName As String, Args() As Object) As Object
 Log(MethodName)
 Return Null
End Sub
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
1. Changing "Wait For Callback_Event (MethodName As String, args() As Object)" to "Wait For (HotPointMissionControl) Callback_Event (MethodName As String, args() As Object)" solved the problem. Sometimes, i'm getting the callback from another sub ?:

B4X:
If HotPointOperator.IsInitialized Then
     Dim HotPointMissionControl As JavaObject = HotPointOperator
     Dim RadiusSicherung As Double=50

     Dim cc As Object=HotPointMissionControl.CreateEventFromUI("dji.common.util.CommonCallbacks$CompletionCallbackWith", "callback", Null)
     HotPointMissionControl.RunMethod("getMaxAngularVelocityForRadius", Array(RadiusSicherung,cc))
     Wait For (HotPointMissionControl) Callback_Event (MethodName As String, args() As Object)
     Dim MaxAngularVelocity As Float = args(0)
End If

2. And reading the airsense informations work with with this code:
B4X:
    Dim flightcontrollerjo As JavaObject = controller
    Dim cc As Object = flightcontrollerjo.CreateEventFromUI("dji.common.flightcontroller.adsb.AirSenseSystemInformation$Callback", "callback", Null)
    flightcontrollerjo.RunMethod("setASBInformationCallback", Array(cc))
   
    Wait For (flightcontrollerjo) callback_Event (MethodName As String, Args() As Object)
    Dim airsensestate As JavaObject= Args(0)
    Dim WarningLevel As String = airsensestate.RunMethod("getWarningLevel", Null)
    Log("Warning-Level:" & WarningLevel)

Thank you for your efforts...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…