Please select Into the mobile phone version | Continue to access the computer ver.
Timeline best practice 1, iOS swift 5, virtual stick
102 1 5-11 07:10
Uploading and Loding Picture ...(0/1)
o(^-^)o
hdrpano
lvl.2
Flight distance : 442185 ft
  • >>>
Switzerland
Offline

Timeline best practise 1

If you use a timeline mission it is important that the aircraft keeps the position even under windy conditions.
The advanced virtual stick mode is made for these conditions. At the end of the mission you must stop virtual stick mode.
You can always check if virtual stick or advanced virtual stick is still on.

You can find below all swift functions to use virtual stick.
//MARK: Start Virtual Stick
    func startVirtualStick(enabled: Bool = true) {
        guard let virtualStickKey = DJIFlightControllerKey(param: DJIFlightControllerParamVirtualStickControlModeEnabled) else {
            return;
        }

        DJISDKManager.keyManager()?.setValue(NSNumber(value: enabled), for: virtualStickKey, withCompletion: { (error: Error?) in
            if error != nil {
                print("Error start virtual stick")
            }
            print("Start virtual stick \(enabled)")
        })
    }

//MARK: Start Advanced Virtual Stick
    func startAdvancedVirtualStick(enabled: Bool = true) {
        guard let virtualStickKey = DJIFlightControllerKey(param: DJIFlightControllerParamVirtualStickAdvancedControlModeEnabled) else {
            return;
        }

        DJISDKManager.keyManager()?.setValue(NSNumber(value: enabled), for: virtualStickKey, withCompletion: { (error: Error?) in
            if error != nil {
                print("Error start advanced virtual stick")
            }
            print("Start advanced virtual stick \(enabled)")
        })
    }

    //MARK: Stop Virtual Stick
    func stopVirtualStick() {
        guard let virtualStickKey = DJIFlightControllerKey(param: DJIFlightControllerParamVirtualStickControlModeEnabled) else {
            return;
        }

        DJISDKManager.keyManager()?.setValue(NSNumber(value: false), for: virtualStickKey, withCompletion: { (error: Error?) in
            if error != nil {
                print("Error stop virtual stick")
            }
            print("Stop virtual stick")
        })
    }

    //MARK: Stop Advanced Virtual Stick
    func stopAdvancedVirtualStick() {
        guard let virtualStickKey = DJIFlightControllerKey(param: DJIFlightControllerParamVirtualStickAdvancedControlModeEnabled) else {
            return;
        }

        DJISDKManager.keyManager()?.setValue(NSNumber(value: false), for: virtualStickKey, withCompletion: { (error: Error?) in
            if error != nil {
                print("Error stop advanced virtual stick")
            }
            print("Stop advanced virtual stick")
        })
    }

    //MARK: Is Virtual Stick
    func isVirtualStick() -> Bool {
        guard let virtualStickKey = DJIFlightControllerKey(param: DJIFlightControllerParamVirtualStickControlModeEnabled) else {
            return false
        }

        guard let vs = DJISDKManager.keyManager()?.getValueFor(virtualStickKey) else {
            return false
        }

        let vsValue = vs.boolValue
        print("Virtual Stick on: \(vsValue)")

        return vsValue
    }

    //MARK: Is Advanced Virtual Stick
    func isVirtualStickAdvanced() -> Bool {
        guard let virtualStickKey = DJIFlightControllerKey(param: DJIFlightControllerParamVirtualStickAdvancedControlModeEnabled) else {
            return false
        }

        guard let vs = DJISDKManager.keyManager()?.getValueFor(virtualStickKey) else {
            return false
        }

        let vsValue = vs.boolValue
        print("Advanced Virtual Stick on: \(vsValue)")

        return vsValue
    }

    //MARK: Prepare Virtual Stick
    func prepareVirtualStick() {
        let fc = ProductCommunicationManager.shared.fetchFlightController()
        if fc != nil {
            let fcMode = DJIFlightOrientationMode.aircraftHeading
            fc?.setFlightOrientationMode(fcMode, withCompletion: { (error: Error?) in
                if error != nil {
                    print("Error setting FlightController Orientation Mode");
                }
            })

            fc?.setMultipleFlightModeEnabled(true, withCompletion: { (error: Error?) in
                if error != nil {
                    print("Error setting multiple flight mode");
                }
            })
        }
    }


5-11 07:10
Use props
DJI_Lisa
lvl.4
South Africa
Offline

Hi HDRPano - thank you for sharing your knowledge here but I noticed you're not getting any community love on your post.  If you'd like more traffic on this, try changing the topic location of your post to Technical Discussion > MSDK by clicking the edit button.
5-27 12:04
Use props
Advanced
You need to log in before you can reply Login | Register now

Credit Rules