问题描述
我不知道如何获取简单的状态数据,例如当前的云台俯仰。
我还没有发现DJI SDK与xcode中实际起作用的牢固联系。该SDK给了我一些提示,并与xcode自动补全功能一起缓慢地前进。
Class GimbalState has member getAttitudeInDegrees(),其描述为: “目前的万向架姿态(以度为单位)。如果万向架与飞机水平并且指向北极的向前方向,则横滚,俯仰和偏航为0。” -太好了!
但是,它不会在xcode中自动完成,也不会编译。
测试过的其他方法:
var gimbalStateInformation = DJIGimbalState()
print(gimbalStateInformatoin.attitudeInDegrees.pitch.description)
->所有俯仰和偏航值均为0.0
var gimbalStateInformation = DJUGimbalAttitude()
print(gimbalStateInformatoin.pitch.description)
->所有俯仰和偏航值均为0.0
我试图通过按键来获取信息,但是运行代码时我的应用程序崩溃了。
func getGimbalAttitude(){
// Get the key
guard let gimbalAttitudeKey = DJIGimbalKey(param: DJIGimbalParamAttitudeInDegrees) else {
print("Could not create DJIGimbalParamAttitudeInDegrees key")
return
}
// Get the keyManager
guard let keyManager = DJISDKManager.keyManager() else {
print("Could not get the key manager,manke sure you are registered")
return
}
// Test if key is available
let testing = keyManager.isKeySupported(gimbalAttitudeKey)
self.statusLabel.text = String(testing) // This comes out true
// Use key to retreive info
let gimbalAttitudeValue = keyManager.getValueFor(gimbalAttitudeKey)
let gimbalAttitude = gimbalAttitudeValue?.value as! DJIGimbalState
_ = gimbalAttitude.attitudeInDegrees.pitch
// --> Application crashes on the line above
}
我正在努力打造Mavic Mini。
请概括性地建议如何将DJI Mobile SDK连接到Swift,以及具体如何读取当前的云台俯仰值。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)