DJI Mobile SDK 3.0

时间:2016-01-22 17:42:27

标签: android dji-sdk

当通过DJIMissionManager.getInstance()或djiAircraftInstance.getMissionManager()获取任务管理器时,任务管理器实例永远不会连接,即taskManagerInstance.isConnected()始终返回false,并且在没有isConnected检查的情况下继续执行会导致崩溃。我是否错过了设置或撤回任务管理员的一步?

一分钟前,我在他们的论坛here上问了同样的问题。

任何帮助将不胜感激。我已经对他们的例子进行了一千次,但似乎所有的例子都使用了旧版本的sdk。

编辑:您可以弄清楚的更多信息,但我会加入其中。

任务管理器实例不为null,因为调用isConnected()会返回false,并且无人机也会连接。

1 个答案:

答案 0 :(得分:0)

我只测试了isMissionReadyToExecute和MissionManager.isConnected,我发现无论何时调用它们,它们总是返回true。所以我认为它应该是SDK中的错误。

我找到了解决此问题的解决方案。

初始化任务。

    // Step 1: create mission
    DJIWaypointMission waypointMission = new DJIWaypointMission();
    waypointMission.maxFlightSpeed = 14;
    waypointMission.autoFlightSpeed = 4;
    List<DJIWaypoint> waypointsList = new LinkedList<>();

    // Step 2: create waypoints and prepare coordinates
    DJIWaypoint northPoint = new DJIWaypoint(mHomeLatitude + 10 * Utils.ONE_METER_OFFSET, mHomeLongitude, 10f);
    DJIWaypoint eastPoint = new DJIWaypoint(mHomeLatitude, mHomeLongitude + 10 * Utils.calcLongitudeOffset(mHomeLatitude), 20f);
    DJIWaypoint southPoint = new DJIWaypoint(mHomeLatitude - 10 * Utils.ONE_METER_OFFSET, mHomeLongitude, 30f);
    DJIWaypoint westPoint = new DJIWaypoint(mHomeLatitude, mHomeLongitude - 10 * Utils.calcLongitudeOffset(mHomeLatitude), 40f);

    //Step 3: add actions
    northPoint.addAction(new DJIWaypoint.DJIWaypointAction(DJIWaypoint.DJIWaypointActionType.GimbalPitch, -60));
    northPoint.addAction(new DJIWaypoint.DJIWaypointAction(DJIWaypoint.DJIWaypointActionType.StartTakePhoto, 0));
    eastPoint.addAction(new DJIWaypoint.DJIWaypointAction(DJIWaypoint.DJIWaypointActionType.StartTakePhoto, 0));
    southPoint.addAction(new DJIWaypoint.DJIWaypointAction(DJIWaypoint.DJIWaypointActionType.RotateAircraft, 60));
    southPoint.addAction(new DJIWaypoint.DJIWaypointAction(DJIWaypoint.DJIWaypointActionType.StartRecord, 0));
    westPoint.addAction(new DJIWaypoint.DJIWaypointAction(DJIWaypoint.DJIWaypointActionType.StopRecord, 0));

    //Step 4: add waypoints into the mission
    waypointsList.add(northPoint);
    waypointsList.add(eastPoint);
    waypointsList.add(southPoint);
    waypointsList.add(westPoint);
    waypointMission.addWaypoints(waypointsList);

    mDJIMission = waypointMission;

准备任务。

 mMissionManager.prepareMission(mDJIMission, new DJIMission.DJIMissionProgressHandler() {

        @Override
        public void onProgress(DJIMission.DJIProgressType type, float progress) {
            setProgressBar((int)(progress * 100f));
        }

    }, new DJICompletionCallback() {

        @Override
        public void onResult(DJIError error) {
            if (error == null) {
                Utils.setResultToToast(mContext, "Success!");
            } else {
                Utils.setResultToToast(mContext, "Prepare: " + error.getDescription());
            }
        }
    });