Android Question Some question about DJI

schimanski

Well-Known Member
Licensed User
Longtime User
Thank you for posting the new dji-SDK, it's awesome!

I have some questions. Perhaps there is someone, who has already gained some experience:

1. The Mavic Air 2 has a 4K-Zoom mode with up to 4 times digital zoom. Is it possible to use this function? I tried to grow up the camera-panel, but this is only possible up to 3 times and the screen resolution is much poorer than with the dji fly app.

2. The Mavic 2 Enterprise needs a login to bind the drone with the controller. Is it possibel to use this login-function? For now, i start the dji-pilot app, make a login to bind the controller with the drone and after that, i start my own application. That works in some times, but not very reliable.

3. I want, that the Mavic Air 2 is always over the position of my controller. Is it a good solution to use the waypoint-function to load each time the new controller-position to the drone or is there a better way?

Thank you for all your efforts.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Not implemented in the library but if there is a native API for this then it shouldn't be difficult to call with JavaObject: https://developer.dji.com/api-reference/android-api/Components/SDKManager/DJISDKManager.html

2. Are you located in China? As I understand, it is only required when the app is used in China: https://developer.dji.com/mobile-sdk/documentation/android-tutorials/ActivationAndBinding.html

3. I don't think so. It should probably done in a more sophisticated way using: https://developer.dji.com/api-refer...gory_sendvirtualstickflightcontroldata_inline
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Thanks for your effort!

2. Are you located in China? As I understand, it is only required when the app is used in China:

No, in germany. I thougt, it is a normal enterprise-feature.
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Did somebody get's the waypoint-example to work on the mavic air 2?
I always get this exception
B4X:
java.lang.RuntimeException: The execution could not be executed.(255)

in this line

WaypointOperator.LoadMission(builder)

Could it be a problem with the air 2?


B4X:
Sub btnStartMission_Click

    Dim builder As DJIWaypointMissionBuilder
    builder.Initialize
    builder.AutoFlightSpeed = 10
    builder.MaxFlightSpeed = 15
    builder.AddWaypoint(CreateWaypoint(51.8373372, 6.26967794, 40))
    Dim wp As DJIWaypoint = CreateWaypoint(51.83850007, 6.26828855, 30)
    wp.AddAction("STAY", 3000)
    wp.AddAction("GIMBAL_PITCH", -90)
    wp.AddAction("START_TAKE_PHOTO", 0)
    builder.AddWaypoint(wp)
    wp = CreateWaypoint(51.83772032, 6.26845485, 30)
    wp.AddAction("GIMBAL_PITCH", 0)
    wp.AddAction("START_RECORD", 0)
    builder.AddWaypoint(wp)
    wp = CreateWaypoint(51.83707127, 6.26887327, 30)
    wp.AddAction("STOP_RECORD", 0)
    builder.AddWaypoint(wp)
    builder.SetFinishAction("GO_FIRST_WAYPOINT")
        
    WaypointOperator.LoadMission(builder)
    Log(GetMissionOperatorState)
    Wait For (WaypointOperator.UploadMission) WaypointOperator_Result (Success As Boolean, ErrorMessage As String)
    If Success Then
        Sleep(1000) '<--- required. Otherwise it will fail
        Wait For (WaypointOperator.StartMission) WaypointOperator_Result (Success As Boolean, ErrorMessage As String)
        Log("Start: " & Success & ", " & ErrorMessage)
        MissionState(True)
    Else
        Log("Error uploading: " & ErrorMessage)
        ToastMessageShow("Error uploading: " & ErrorMessage, True)
    End If
End Sub
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I need a little bit help. I tried it with the DJI Mavic Air 2, but the system tells, that that it is not able to execute. I think, it is the same problem as waypoint-mission with the Air 2.
I tried it now with my old Mavic Pro. That seems to work. I'm able to start the followme-function with the following code, but not to update the target location with JavaObject.

B4X:
Sub btnStartMission_Click    
    Dim FollowMeMission As DJIFollowMeMission
    FollowMeMission.Initialize(51,6, 5, "TOWARD_FOLLOW_POSITION")
    Wait For (FollowMeOperator.StartMission(FollowMeMission)) FollowMeOperator_Result (Success As Boolean, ErrorMessage As String)
    If Success Then
        Log("StartMission: " & Success, " ") 
        ...UpdateTarget here---

    Else
        Log("StartMission: " & Success & ", " & ErrorMessage)
    End If
End Sub

I now need to update the targetlocation:

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

with

method updateFollowingTarget

void updateFollowingTarget(@NonNull LocationCoordinate2D location,
@Nullable final CompletionCallback callback)

Package:dji.sdk.mission.followme
Description:

Update the Follow Me mission's target location to follow.

Input Parameters:

@NonNull LocationCoordinate2D locationA LocationCoordinate2D object.
@Nullable final CompletionCallback callbackThe execution callback with the execution result returned.

To start the follow me-mission, the drone must fly with more than 10m altitude.
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I found some steps to implement the follow me function here:

https://stackoverflow.com/questions...ement-follow-me-function-into-android-dji-app

I think, that is the part to update the target location after starting the mission. But i'm not able to do it with javaobject. I did al lot of tries, but i don't know well enough the syntax of java. UpdateFollowingTarget in a simple timer should solve my problem, I think...

B4X:
  Public void run() {

                                                While (!Thread.currentThread().isInterrupted()) {

                                                    final Location newLocation = highAccuracyLocationTracker.getLocation();

                                                    missionOperator.updateFollowingTarget(new LocationCoordinate2D(newLocation.getLatitude(), newLocation.getLongitude()), new CommonCallbacks.CompletionCallback() {
                                                        @Override
                                                        Public void onResult(DJIError djiError) {
                                                            If (djiError != Null) {
                                                                MyApplication.getGlobalSettings().getDebugLogger().writeLine("Follow.updateTarget failed: " + djiError.getDescription());
                                                            }
                                                        }
                                                    });

                                                    Try {
                                                        Thread.sleep(100);
                                                    } Catch (InterruptedException e) {
                                                        // The exception clears the interrupt flag so I'll refresh the flag otherwise the thread keeps running
                                                        Thread.currentThread().interrupt();
                                                    }
                                                }
                                            }
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I'm very sorry, but there is no way to initialize the locationšŸ„¶.
I tried it with an initialize waypoint, but it doesn't work.

1616346781223.png


Nervertheless, thank you for all your efforts!!!
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
That's it. I tested the following code with my DJI Mavic Pro just outside. The timer is set to 1000ms. DJI says, that it is possibel to update the target location with 10Hz (100ms). It works perfect. In FollowMe-mission with ititalize it with "CONTROLLED_BY_REMOTE_CONTROLLER", in Mode 2, the right control stick is deactivated and with the left control stick, it is possible to adjust the height and the yaw.

B4X:
Sub Class_Globals
  ...
  Private FollowMeOperator As DJIFollowMeMissionOperator
  Private gmap As GoogleMap
  Private FollowMeTimer As Timer
  ...
end sub

Sub btnStartMission_Click
    Dim FollowMeMission As DJIFollowMeMission
    FollowMeMission.Initialize(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude, 20, "CONTROLLED_BY_REMOTE_CONTROLLER")
    Wait For (FollowMeOperator.StartMission(FollowMeMission)) FollowMeOperator_Result (Success As Boolean, ErrorMessage As String)
    If Success Then
        Log("FollowMeMission started!")
         FollowMeTimer.Enabled=True
    Else
        FollowMeTimer.Enabled=False
        Log("StartMission: " & Success & ", " & ErrorMessage)
    End If
End Sub

Sub CreateLocation2D(Latitude As Double, Longitude As Double) As DJILocation2D
    Dim jo As JavaObject
    jo.InitializeNewInstance("dji.common.model.LocationCoordinate2D", Array(Latitude, Longitude))
    Return jo
End Sub

Sub FollowMeTimer_Tick
    Dim DJILocation As DJILocation2D = CreateLocation2D(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude)
    Wait For (FollowMeOperator.UpdateFollowingTarget(DJILocation)) FollowMeOperator_Result (Success As Boolean, ErrorMessage As String)
    If Success Then
        Log("Target updated!!")
    Else
        Log("Target not updated!" & ErrorMessage)
    End If
End Sub

I try it later again with the mavic air 2 and call back.

Much thanks for all your efforts, Erel!
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I tried it with the DJI Mavic Air 2, but it is not possible to start the followme-Mission. After starting with

B4X:
Dim FollowMeMission As DJIFollowMeMission
FollowMeMission.Initialize(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude, 20, "CONTROLLED_BY_REMOTE_CONTROLLER")
Wait For (FollowMeOperator.StartMission(FollowMeMission)) FollowMeOperator_Result (Success As Boolean, ErrorMessage As String)
....

the success is false with

B4X:
Execution of this process has timed out

Against waypoint-mission, DJI says, that it is only not supported by Spark:

Description:

The class represents a Follow Me mission. In a Follow Me mission, the aircraft is programmed to track and maintain a constant distant relative to some object, such as a person or a moving vehicle. You can use it to make the aircraft follow a GPS device, such as a remote controller with a GPS signal or a mobile device. It is not supported by Mavic Pro when using WiFi connection. It is not supported by Spark.

The Mavic Air 2 is the perfect drone for such feature...Perhaps the sdk is not quite mature...
 
Upvote 0
Top