Android Tutorial DJI virtual stick-tutorial, waypoint- and hotpoint-mission for DJI Mini- and Air-series

derez

Expert
Licensed User
Longtime User
Taking photos with overlap enables you to see stereoscopic picture !!!
Rotate the two sequencial pictures by 90 degrees and put the same area on the screen, like in the picture.


Look at the photos and squint until both objects come togeter and then you see the height differences in the picture.
For better viewing you can build a stereoscopic device.
 

derez

Expert
Licensed User
Longtime User
Another mode, "Slant", moves the drone sideways while taking photos of the area to the left or right of the path (or vertically, saving the need to rotate the picture by 90 degrees for stereoscopy).
The parameter slantside in the code below should be 1 for right side and -1 for left.
B4X:
' Slant
Sub SlantVirtualStick(WPLocation As Location)
 
    Dim mPitch As Float = 0
    Dim mYaw As Float = 0
 
    Dim St As DJIFlightControllerCurrentState = controller.CurrentState
 
    Dim DroneLocation As Location
    DroneLocation.Initialize2(St.AircraftLocation.Latitude, St.AircraftLocation.Longitude)
    DroneLocation.Altitude = St.AircraftLocation.Altitude
 
    Dim VirtualStickBearing As Float = DroneLocation.BearingTo(WPLocation) + 90 * slantside
    If VirtualStickBearing > 180 Then VirtualStickBearing = VirtualStickBearing - 360
    If VirtualStickBearing < -180 Then VirtualStickBearing = VirtualStickBearing + 360
 
    Dim VirtualStickDistance As Float = DroneLocation.DistanceTo(WPLocation)
    Dim VirtualStickAltitudeDifference As Double = Abs(Round(DroneLocation.Altitude)-WPLocation.Altitude)
 
    Select True
        Case VirtualStickAltitudeDifference > 2
            mYaw = VirtualStickBearing
     
        Case Abs(St.Attitude.Yaw-VirtualStickBearing ) > 5
            mYaw = VirtualStickBearing
         
        Case VirtualStickDistance > 60
            mYaw = VirtualStickBearing
            mPitch = AutoFLightSpeed
         
        Case VirtualStickDistance > 2 And VirtualStickDistance <= 60
            mYaw = VirtualStickBearing
            mPitch = Min(VirtualStickDistance / 4, AutoFLightSpeed)

        Case Else
            mYaw = VirtualStickBearing
            mPitch = 0

            If camSelect = False Then
                shootphoto
            End If

            waypointCounter = waypointCounter + 1
            If plan.Size = waypointCounter  Then
                ToastMessageShow("End route",True)
                StopVirtualStick
            Else
                Dim ll As LatLng
                ll.Initialize(0,0)
                Log(waypointCounter)
                ll = plan.Get(waypointCounter)
                currentlat = ll.Latitude
                currentlong = ll.Longitude
            End If
    End Select
 
    sendVirtualStickFlightControlData(-mPitch * slantside, 0, mYaw, WPLocation.Altitude)
End Sub
 
Last edited:

PABLO2013

Well-Known Member
Licensed User
Longtime User
Greetings I hope you are well Derez, could you upload the example, great job, I will try this tomorrow thanks.

pd. The only thing missing is the update of the library to the new Sdk.
 

derez

Expert
Licensed User
Longtime User
The file attached is not an example, it is the application that I find suitable for my use, flight tested to verify that all works well. I believe that it does not need explanation about the use, except that the "Mission start" buttons appears after communication with the drone is reached.
Wishes:
1. members who have drones other than mini 2 try and check the video by selecting it in the setup.
2. I would like to add info about the communication signal strength, I think it is important but missing here. I see it here https://developer.dji.com/iframe/mo...mon/airlink/SignalQualityUpdatedCallback.html but I don't know how to implement it.

Thanks.

 

Attachments

  • VirtualStick7.zip
    45.9 KB · Views: 144
Last edited:

derez

Expert
Licensed User
Longtime User
The video does work on the Mini 2 ! , only the setup subs to set the mode do not work. Setting the mode by the small button on the controller, next to the right stick, changes between the modes and the "startvideo" and "shootphoto" subs work, pending the correct mode is selected.
So now the knowledge of what mode is selected is by trial and error: press the photo button, if it shoots then you are in photo mode, else you are in video.
A report from the drone of the mode status will be nice ...
 
Last edited:

PABLO2013

Well-Known Member
Licensed User
Longtime User
Greetings, I'm glad it worked, what do you think you changed so that the video would work video on the mini.

I have not been able to use your application for work but I hope this weekend and I will inform you
 

derez

Expert
Licensed User
Longtime User
Greetings, I'm glad it worked, what do you think you changed so that the video would work video on the mini.
I didn't change anything, except for not calling "setphoto" and "setvideo" which do not work anyway.
To change modes I use the photo-video switching button next to the right stick.
I check - if the red circle turns on when I press "photo" in the application then the drone is in photo mode. If it does not take picture then it is in video mode.
 
Last edited:

derez

Expert
Licensed User
Longtime User
Last edited:

derez

Expert
Licensed User
Longtime User
I will try it next week. I don't have much time at the moment.
Thank you !
I think the class to check is this : https://developer.dji.com/api-refer...djiairlink_signalqualitycallbackupdate_inline
I am trying without too much understanding and I succeeded in initialzing the javaobject :
B4X:
Airlinkinstance = AircraftInstance.RunMethod("getAirLink", Null)
Then I wrote a sub :
B4X:
Sub airlink
    Log("airlink")
    Dim quality As Int
    If Airlinkinstance.IsInitialized Then
        Log("is init")
        Dim callback As Object = Airlinkinstance.CreateEvent("dji.common.airlink.SignalQualityCallback$CompletionCallback", "SignalQualityCallback",Null)
        Log("callback set")
        Airlinkinstance.RunMethod("onUpdate", Array(quality, callback))
        Wait For (Airlinkinstance) SignalQualityCallback_Event (MethodName As String, Args() As Object)
        If Args(0) = Null Then
            Log("answer null")
        Else
            Log(" answer arg " & Args(0))
        End If
    End If
End Sub

The sub fails on "Dim callback..." with these errors:

Please correct it if you can...

Do you mean to set the angel of the gimbal by code???

Yes if possible. for example, in hotpoint the gimbal should be -ATan2D(HotpointAltitude , HotpointRadius)
 
Last edited:

PABLO2013

Well-Known Member
Licensed User
Longtime User
If I also want you to take pity on us, I hope Erel does not lose interest in this, thanks anyway
Schimanski, you will see that if
 

PABLO2013

Well-Known Member
Licensed User
Longtime User
i understand that it is a different and new sdk. I thank you in advance for your attention. I reviewed the sdk and what I would respectfully tell you is whether to at least implement the initial connection to the sdk...drone...and app...with my little knowledge I would try to implement other methods...thanks
 

schimanski

Well-Known Member
Licensed User
Longtime User
After some investigation. This is not a simple upgrade as it is a completely new SDK, and more so, it doesn't support the same list of drones:

It seems to be a complete cut from the second to the third series. Does this mean that in order to support all drone types, both sdks have to be used?
But nonetheless only the drones of the current version are offered by dji. In this respect, switching to the new SDK would be desirable.

There are numerous new usage options, as the new generation now has a flight time of up to 47 minutes.
Maybe there will be an opportunity, although a lot of work will be required.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…