首页 文章

我无法旋转我的幻影3 dji sdk 3.01

提问于
浏览
1

我正在尝试使用Sdk 3.0.1旋转我的幻像3,但没有成功,

我的代码:

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 {
            showToast(error.getDescription());
        }
    }
});

我收到消息“轮换:成功”,但飞机不动 . 难道我做错了什么?我非常感谢任何帮助 .

1 回答

  • 4

    我以前遇到过这个问题 . 如果您只调用一次 sendVirtualStickFlightControlData ,则性能是有线的 . 我已经向DJI支持发送了一封电子邮件,他们建议我以5Hz的频率调用这种方法 . 我测试了一切都很好 .

    就像是:

    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);
    

相关问题