Estiven Restrepo February 2016

I can't get rotate my phantom 3 dji sdk 3.01

I'm trying to rotate my phantom 3 using the Sdk 3.0.1 but without success,

My code:

DJIFlightController flightController = ((DJIAircraft) mProduct).getFlightController();

flightController.enableVirtualStickControlMode(new DJICompletionCallback() {
    @Override
    public void onResult(DJIError error) {
        if (error == null) {
            showToast("enableVirtualStickControlMode: success");
        } else {
            showToast(error.getDescription());
        }
    }
});
try {
    sleep(5000);
} catch (InterruptedException e) {
    e.printStackTrace();
}
showToast("Set yaw control mode to angle");
flightController.setHorizontalCoordinateSystem(DJIFlightControllerDataType.DJIVirtualStickFlightCoordinateSystem.Body);
flightController.setRollPitchControlMode(DJIFlightControllerDataType.DJIVirtualStickRollPitchControlMode.Angle);
flightController.setVerticalControlMode(DJIFlightControllerDataType.DJIVirtualStickVerticalControlMode.Velocity);
flightController.setYawControlMode(DJIFlightControllerDataType.DJIVirtualStickYawControlMode.Angle);
try {
    sleep(5000);
} catch (InterruptedException e) {
    e.printStackTrace();
}
DJIFlightControllerDataType.DJIVirtualStickFlightControlData flightControlData =
        new DJIFlightControllerDataType.DJIVirtualStickFlightControlData(0, 0, 45, 0);
flightController.sendVirtualStickFlightControlData(flightControlData, new DJICompletionCallback() {
    @Override
    public void onResult(DJIError error) {
        if (error == null) {
            showToast("Rotation: success");
        } else {
            showToast(error.getDescription());
        }
    }
});
try {
    sleep(5000);
} catch (InterruptedException e) {
    e.printStackTrace();
}


flightController.disableVirtualStickControlMode(new DJICompletionCallback() {
    @Override
    public void onResult(DJIError error) {
        if (error == null) {
            showToast("disableVirtualStickControlMode: success");
        } else {
                 

Answers


Xu ChangJian February 2016

I got this problem before. The performance is wired, if you just invoke sendVirtualStickFlightControlData once. I have sent an e-mail to DJI support, they suggest me to invoke this method in such frequency, 5Hz. I tested it and everything was fine.

Something like:

    Timer timer = new Timer();

    timer.schedule(new TimerTask() {

        @Override
        public void run() {
            mFlightController.sendVirtualStickFlightControlData(flightControlData, new DJICompletionCallback() {
                @Override
                public void onResult(DJIError error) {
                    if (error == null) {
                        showToast("Rotation: success");
                    } else {
                        showToast(error.getDescription());
                    }
                }
            });
        }
    }, 0, 200); 

Post Status

Asked in February 2016
Viewed 2,957 times
Voted 14
Answered 1 times

Search




Leave an answer