简体   繁体   中英

DJI Mobile SDK 3.0

When getting the mission manager, either by DJIMissionManager.getInstance() or djiAircraftInstance.getMissionManager(), the mission manager instance is never connected, ie missionManagerInstance.isConnected() always returns false, and proceeding without the isConnected check causes a crash. Am I missing a step in setting up or retreiving the mission manager?

A minute ago I asked the same question on their forums here .

Any help would be appreciated. I have been over their examples a thousand times but it seems all of the examples are using an older version of the sdk.

EDIT: More information that you could figure out but I'll add in for the heck of it.

Mission manager instance is not null because calling isConnected() returns false, and the drone is connected as well.

I just test the isMissionReadyToExecute and MissionManager.isConnected, i found that no matter when I call them, they always return true. So I consider that it should be the bugs inside the SDK.

And I found a walk around solution for this problem.

Initialize the mission.

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

prepare the mission.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM