dji-sdk / Mobile-SDK-Android

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

Control dji enterprise via virtual stick #411

Open NinaVozdvizhenskaya opened 5 years ago

NinaVozdvizhenskaya commented 5 years ago

I am trying to control drone with command sendVirtualStickFlightControlData. To move the drone left I use following code.

sendVirtualStickDataTask = new SendVirtualStickDataTask(0, -5, 0, 0);
sendVirtualStickDataTimer = new Timer();
sendVirtualStickDataTimer.schedule(sendVirtualStickDataTask, 100, 200);

private class SendVirtualStickDataTask extends TimerTask {

private float pitch;
private float roll;
private float yaw;
private float throttle;
private long startTime = System.currentTimeMillis();

public SendVirtualStickDataTask(float inputPitch, float inputRoll, float inputYaw, float inputThrottle) {
    pitch = inputPitch;
    roll = inputRoll;
    yaw = inputYaw;
    throttle = inputThrottle;
}

@Override
public void run() {
    if (System.currentTimeMillis() - startTime > 300) {
        mFlightController.sendVirtualStickFlightControlData(new FlightControlData(0, 0, 0, 0),
                                                            new CommonCallbacks.CompletionCallback() {
            @Override
            public void onResult(final DJIError djiError) {

            }
        });
        cancel();
    } else {
        mFlightController
                .sendVirtualStickFlightControlData(new FlightControlData(pitch,
                                                                         roll,
                                                                         yaw,
                                                                         throttle),
                                                   new CommonCallbacks.CompletionCallback() {
            @Override
            public void onResult(final DJIError djiError) {
            }
        });
    }
}
}

However, the drone moves to the left and then turns and drops down sharply.

What is the reason for this drone behavior? flight control system - ground roll/pitch control mode - angle dji-sdk 4.9 Drone: dji mavic enterprise

dji-sdk[bot] commented 5 years ago

Hi, there are two options for you to ask for help:

  1. Post your issues on StackOverflow: https://stackoverflow.com/questions/tagged/dji-sdk, the community can help you.

  2. Report your issues to dev@dji.com, as it's our official channel for developers to request DJI Developer Support now.

For DJI Developer Support, we have the following three tiers: