Please select Into the mobile phone version | Continue to access the computer ver.
drone controlling via virtual stick
1167 2 2019-5-14
Uploading and Loding Picture ...(0/1)
o(^-^)o
djiuser_dJlEdvK7ZfgR
lvl.1
Russia
Offline

Hello!
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 drops down sharply.

What is the reason for this drone behavior?

2019-5-14
Use props
A J
Captain
Flight distance : 13838848 ft
  • >>>
United Kingdom
Offline

No idea - use the RC - much easier and safer
2019-5-14
Use props
BKahuna
Second Officer
Flight distance : 7425909 ft
United States
Offline

Wow, I didn't know DJI provided developer support.  Thanks for the head's up!  Sorry, as a brand new DJI developer(!), I don't know the answer to your question.  I wonder if there is a community on StackOverflow?
2019-5-14
Use props
Advanced
You need to log in before you can reply Login | Register now

Credit Rules