swift - api调用无法开启精准落地

标签 swift dji-sdk

我正在使用具有精确着陆能力的 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)\"

有问题的 API 可在此处找到:https://developer.dji.com/api-reference/ios-api/Components/IntelligentFlightAssistant/DJIIntelligentFlightAssistant.html?search=precision&i=0&#djiintelligentflightassistant_setprecisionlandingenabled_inline

我查了下,精准降落相关的“起飞”调用没有传入参数。那么,为什么我知道无人机具有此功能(已通过 DJI 自己的应用程序验证)却出现此错误?在启用此功能之前,无人机是否必须先飞行?还是在启用此功能之前必须满足其他条件?

最佳答案

在我看来,您应该创建一个 DJIFlightAssistant 对象,然后使用现有方法 setPrecisionLandingEnabled(_: Bool, completion: DJICompletionBlock)

为什么要编写自己的 setPrecisionLandingEnabled() 方法?

关于swift - api调用无法开启精准落地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49162549/

相关文章:

ios - 如何在 Swift 中将 UILabel 居中?

ios - 在没有 StoryBoard 的情况下通过 Swift 中的 View Controller 以编程方式传递变量

android - 大疆Spark : missing support for FlightController. setMaxFlightHeight() FlightController.setMaxFlightRadius()

ios - 是否可以只构建一次 Pod?

ios - 泛型属性

Swift Generics - 如果它们是 Equatable 则返回 equals,否则返回 nil

dji-sdk - Mavic Pro - Microsoft Build 2018 Windows SDK

ios - 如何设置单元测试来测试自定义 DJI 任务?

dji-sdk - DJI Phantom API 或可破解程序