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 has started : true」も出力します

4

1 に答える 1

0

問題の解決策を見つけました。コードに問題はありません。RC には P モードに設定する必要があるボタンが左前領域にあります。

于 2016-11-24T06:10:43.910 に答える