I am developing an AR application using DJI.
As the title says, I am unable to get the values using DJIGigibalParamAttitudeInDegrees.
Version used:
- Mac OS: Monterey 12.4
- Xcode: 10.3
- Swift 5.6.1
- iOS: 11.0
- DJI SDK iOS: 4.16.1
I was able to do the following:
- Register DJI Mobile SDK and build the application using API key.
- Get the drone's attitude using a listener.
To get the drone's attitude, I wrote the following code based on the sample code and it worked.
let aircraftAttitudeKey = DJIFlightControllerKey(param: DJIFlightControllerParamAttitude) DJISDKManager.keyManager()?.startListeningForChanges(on: aircraftAttitudeKey!, withListener: self, andUpdate: {(oldValue: DJIKeyedValue?, newValue: DJIKeyedValue?) in if newValue != nil { let aircraftaAttitudes = newValue!.value! as! DJISDKVector3D self.rollLabel.text = "Roll: \(aircraftaAttitudes.x)" self.pitchLabel.text = "Pitch: \(aircraftaAttitudes.y)" self.yawLabel.text = "Yaw: \(aircraftaAttitudes.z)" } )
In the same way, I'm trying to get the gimbal's attitude with the following code, but it does not work.
let gimbalAttitudeKey = DJIGimbalKey(param: DJIGimbalParamAttitudeInDegrees) DJISDKManager.keyManager()?.startListeningForChanges(on: gimbalAttitudeKey!, withListener: self, andUpdate: {(oldValue: DJIKeyedValue?, newValue: DJIKeyedValue?) in if newValue != nil { let gimbalAttitudes = newValue!.value! as! DJIGimbalAttitude self.gRollLabel.text = "Roll: \(gimbalAttitudes.roll)" self.gPitchLabel.text = "Pitch: \(gimbalAttitudes.pitch)" self.gYawLabel.text = "Yaw: \(gimbalAttitudes.yaw)" } })
|