0
private void initFlightController() {

    DJIAircraft aircraft = DJISimulatorApplication.getAircraftInstance();
    if (aircraft == null || !aircraft.isConnected()) {
        log("initFlightController:  aircraft not connected");
        showToast("Disconnected");
        mFlightController = null;
        return;
    } else {
        log("initFlightController:  aircraft CONNECTED");
        mFlightController = aircraft.getFlightController();
        DJISimulator djiSimulator = mFlightController.getSimulator();

        log("initFlightController:  djiSimulator has started : "+djiSimulator.hasSimulatorStarted());
        djiSimulator.setUpdatedSimulatorStateDataCallback(new DJISimulator.UpdatedSimulatorStateDataCallback() {
            @Override
            public void onSimulatorDataUpdated(final DJISimulatorStateData djiSimulatorStateData) {
                log("onSimulatorDataUpdated:  ");
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {

                        String yaw = String.format("%.2f", djiSimulatorStateData.getYaw());
                        String pitch = String.format("%.2f", djiSimulatorStateData.getPitch());
                        String roll = String.format("%.2f", djiSimulatorStateData.getRoll());
                        String positionX = String.format("%.2f", djiSimulatorStateData.getPositionX());
                        String positionY = String.format("%.2f", djiSimulatorStateData.getPositionY());
                        String positionZ = String.format("%.2f", djiSimulatorStateData.getPositionZ());

                        mTextView.setText("Yaw : " + yaw + ", Pitch : " + pitch + ", Roll : " + roll + "\n" + ", PosX : " + positionX +
                                ", PosY : " + positionY +
                                ", PosZ : " + positionZ);
                    }
                });
            }
        });

    }
}

我正在测试 Dji-Developer 中为 android 提供的示例代码。一切都很好,但 onSimulatorDataUpdated() 没有被调用。它甚至打印日志“initFlightController:djiSimulator 已启动:true”

4

1 回答 1

0

我找到了问题的解决方案。代码没有任何问题,RC在左前区域有一个按钮,必须设置为P模式。

于 2016-11-24T06:10:43.910 回答