我正在使用具有精确着陆能力的 Phantom 4 Pro 无人机。我正在使用 Swift 和 iPad 来控制无人机。在 DJI Go 软件中,我可以启用它,并且它可以正常工作。但是,在我正在开发的应用程序中,任何启用它的调用都会失败。
这是尝试启用它的代码:
static func setPrecisionLandingEnabled(precisionLandingEnabled: Bool, _ completeFunction: @escaping (Error?) -> Void) throws {
guard let djiKeyManager = DJISDKManager.keyManager() else {
GLog.Log("Error in Flight Controller Observer. Problem getting djiKeyManager in \(#file) \(#function)")
throw FlightControllerManager.FlightControllerError.cantGetKeyManager
}
guard let precisionLandingEnabledKey = DJIFlightControllerKey(param: DJIFlightAssistantParamPrecisionLandingEnabled) else {
GLog.Log("Error in Flight Controller Observer. Problem getting precisionLandingEnabledKey in \(#file) \(#function)")
throw FlightControllerManager.FlightControllerError.cantGetKey
}
djiKeyManager.setValue(precisionLandingEnabled, for: precisionLandingEnabledKey, withCompletion: completeFunction)
}
调用函数时,DJI SDK的补全函数返回如下错误:
Error Domain=DJISDKErrorDomain Code=-1013 \"Current product does not support this feature.(code:-1013)\"
我查了下,精准降落相关的“起飞”调用没有传入参数。那么,为什么我知道无人机具有此功能(已通过 DJI 自己的应用程序验证)却出现此错误?在启用此功能之前,无人机是否必须先飞行?还是在启用此功能之前必须满足其他条件?
最佳答案
在我看来,您应该创建一个 DJIFlightAssistant
对象,然后使用现有方法 setPrecisionLandingEnabled(_: Bool, completion: DJICompletionBlock)
为什么要编写自己的 setPrecisionLandingEnabled()
方法?
关于swift - api调用无法开启精准落地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49162549/