DJI-Mobile-SDK-Tutorials / iOS-SimulatorDemo

This demo shows you how to use the DJISimulator of DJI Mobile SDK.
MIT License
20 stars 6 forks source link

Unable to execute DJIGoToStep mission using DJICustomMission in Simulator Mode #3

Open EonKid opened 7 years ago

EonKid commented 7 years ago

I am using DJI Phantom 3 -DJI SDK 3.5 -iPad I am unable to start DJIGoToStep mission using Simulator mode is ON .I am using following code:-

    if let flightController = DroneUtility.fetchFlightController(){
        if CLLocationCoordinate2DIsValid(self.droneLocationCoordinate) {
         self.min_height = proxy.sharedProxy().getAltitudeDictionary(arrTemp: zoneCreateModal.zones).object(forKey: "minimum_height") as! Float
            self.takeOffCoordinates = self.droneLocationCoordinate

            let max_height = proxy.sharedProxy().getAltitudeDictionary(arrTemp: self.zoneCreateModal.zones).object(forKey: "maximum_height") as! Float
            let stepsToGo = DJIGoToStep.init(coordinate: self.droneLocationCoordinate, altitude: self.min_height)
            let customMission = DJICustomMission.init(steps: [stepsToGo!])
            DJIMissionManager.sharedInstance()!.prepare(customMission!, withProgress: { (value) in
            }, withCompletion: { (error) in
                if error?.localizedDescription.characters.count > 0{
                    proxy.sharedProxy().displayStatusCodeAlert("Error: \(error!.localizedDescription)")
                }else{
                    DJIMissionManager.sharedInstance()!.startMissionExecution(completion: { (error) in
                        if error?.localizedDescription.characters.count > 0{
                            proxy.sharedProxy().displayStatusCodeAlert("Error: \(error!.localizedDescription)")
                        }else{
                         proxy.sharedProxy().displayStatusCodeAlert("Take off succeeded...")
                            flightController.setFlightOrientationMode(.courseLock, withCompletion: { (error) in
                                if error?.localizedDescription.characters.count > 0{
                                }else{
                                    //Set maximum flight height
                                    proxy.sharedProxy().displayStatusCodeAlert("Maximum : \(max_height)")
                                    flightController.flightLimitation?.setMaxFlightHeight(max_height, withCompletion: nil)

                                    }
                            })
                        }
                    })
                }
            })

        }else{
            proxy.sharedProxy().displayStatusCodeAlert("Error: Unable to fetch current location")
        }
    }else{
        proxy.sharedProxy().displayStatusCodeAlert("Please connect drone")
    }
oliverou commented 7 years ago

Hi @EonKid, do you have any log messages when you failed to execute DJIGoToStep mission? Also, DJI Phantom 3 is a product series, which Phantom 3 you are using (Like Phantom 3 Professional, Phantom 3 Advanced, etc). To help us investigate the issue, could you help to provide more infos of "Unable to execute DJIGoToStep mission"?

BTW, you can check the iOS SDK Swift Sample Code: https://github.com/dji-sdk/Mobile-SDK-iOS/tree/master/Sample%20Code/SwiftSampleCode/DJISDKSwiftDemo/Missions/CustomMission to learn how to use the Custom Mission and Simulator in Swift.

Hope this help!

EonKid commented 7 years ago

@oliverou I am using DJI Phantom 3 Advanced and also tested it on Phantom 4,Phntom 4 Pro.It says "Bad GPS signal" for DJI Phantom 4 and DJI Phantom 4 Pro .Also Simulator mode is not working in "DJI Phantom 4 Pro".It giving error "Unknown aircraft"

dji-dev commented 7 years ago

@EonKid, it seems that you haven't start the simulator successfully before you run the DJICustomMission, also, to start the simulator, you should pass the location, frequency and number parameters in the following method:

- (void)startSimulatorWithLocation:(CLLocationCoordinate2D)location
                   updateFrequency:(NSUInteger)frequency
               GPSSatellitesNumber:(NSUInteger)number
                    withCompletion:(DJICompletionBlock)block;

So, it's unreasonable to have the "Bad GPS signal" logs if you set the GPS Satellite Number.

BTW, it should not show the "Unknown aircraft" error log when you use the simulator and Custom Mission. Could you help to paste the full log in the Xcode console for us to investigate the issue?

EonKid commented 7 years ago

@oliverou @dji-dev I have started the simulator. It is giving same error for DJI Phantom 3 Advance "Bad gps signal Error code : -5001". Can it follow the object in simulator mode . -DJI SDK Version 3.5