Closed Filet-0-Fish closed 2 years ago
Thanks for the reply, DJI-William. I know what I can get from DJIFlightControllerState is the attitude of the aircraft. I want to get where the camera is pointing. Maybe I am just missing something and can also get the gimbal attitude from DJIFlightControllerState?
(Sorry, I am new to Github and closed it by mistake.)
I am very sorry, I have missed reading, You wan to get the gimbal attitude. This is the same thing. There is a delegate in Gimbal class, you can get DJIGimbalState through this, and you can get DJIGimbalState.attitudeInDegrees. It is a struct and contains 3 float numbers which represent 3 angles.
Thanks for telling me. I am not sure how to get the DJIGimbalState from the Gimbal delegate. Should I delegate the Gimbal class to the view controller class? I would appreciate it if you could provide a sample code.
Thanks for the sample code. But sorry, do you have this sample in swift version instead of objective-c?
I am sorry, I didn't find it in the Swift demo.
I was able to get it to work by adding this code to the ViewController! Thanks so much for your support!
class DroneConnectionView: ... DJIGimbalDelegate {
override func viewDidLoad() {
super.viewDidLoad()
...
let gimbal = fetchGimbal()
if gimbal != nil {
gimbal?.delegate = self
}
}
func fetchGimbal() -> DJIGimbal? {
guard let product = DJISDKManager.product() else {
return nil
}
if product is DJIAircraft || product is DJIHandheld {
return product.gimbal
}
return nil
}
func gimbal(_ gimbal: DJIGimbal, didUpdate state: DJIGimbalState) {
self.RollLabel.text = "Roll: \(state.attitudeInDegrees.roll)"
self.PitchLabel.text = "Pitch: \(state.attitudeInDegrees.pitch)"
self.YawLabel.text = "Yaw: \(state.attitudeInDegrees.yaw)"
}
}
Hello. I have reported this problem on the forum, but since I could not find a solution, I am posting it here. https://forum.dji.com/forum.php?mod=viewthread&tid=269885
What I want to do
The code
The problem that is occurring
let gimbalAttitudes = newValue!.value! as! DJIGimbalAttitude
section.I hope this issue will be resolved soon.