android - 我无法旋转我的 phantom 3 dji sdk 3.01

标签 android dji-sdk

我正在尝试使用 Sdk 3.0.1 旋转我的 phantom 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());
        }
    }
});

我收到消息“旋转:成功”,但飞机没有移动。 难道我做错了什么? 非常感谢任何帮助。

最佳答案

我以前遇到过这个问题。如果您只调用一次 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); 

关于android - 我无法旋转我的 phantom 3 dji sdk 3.01,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35270559/

相关文章:

java - 将谷歌地图集成到 DJI mapWidget 中

android - 视频录制模式屏幕不适合手机屏幕

android - Google nexus 7 从 px 到 dp 的转换

android - Actionbarsherlock IcsSpinner - 宽度始终设置为最宽的项目

c# - 是什么导致 DEVICE_COMMAND_RESPONSE_ERROR 在 Microsoft Band 2 上创建磁贴

android - 我们可以在不连接无人机(实际设备)的情况下使用应用程序测试Dji Sdk吗?通过虚拟设备或使用 PC 模拟器的任何其他方式

android - DJI SDK 4.7.1 突然崩溃,而 4.6 不会

ios - 从 DJI 无人机检索带有 EXIF 数据的图像

android - 在Android的MVVM模式中使用ViewModel和实时数据类是强制性的吗?否则我们可以不使用MVVM模式而使用它们吗?

c# - RequestPermissions 不显示对话框 xamarin c#