gpt4 book ai didi

ios - DJI sdk 获取RTK信息

转载 作者:行者123 更新时间:2023-11-28 20:57:00 25 4
gpt4 key购买 nike

我正在尝试使用 ios 应用程序从 DJI M600 Pro 中的 RTK 获取 gps 信息,我查看了 DJI Mobile SDK API 引用,并找到了一些 RTK API 。无人机启动时,“isRTKBeingUsed”属性应该是“YES”,但我无法得到结果。

任何帮助将不胜感激!这是我的代码:

#import "ViewController.h"
#import <DJISDK/DJISDK.h>
#import "DJIAppActivationManager_InternalTesting.h"
#import<DJISDK/DJIRTK.h>

#define WeakRef(__obj) __weak typeof(self) __obj = self
#define WeakReturn(__obj) if(__obj ==nil)return;

void ShowResult(NSString *format, ...)
{...
}

@interface ViewController ()<DJIAppActivationManagerDelegate, DJISDKManagerDelegate,DJIRTKDelegate>
...
...
@property (weak, nonatomic) IBOutlet UILabel *isusing;
@property(strong, nonatomic) DJIRTK * rtk1;
@property(strong, nonatomic) DJIRTKState * rtkstate1;

@end

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self registerApp];
[self updateUI];

self.rtk1 = [[DJIRTK alloc] init];
self.rtkstate1 = [[DJIRTKState alloc] init];
[self rtk:_rtk1 didUpdateState:_rtkstate1];


}

- (void)viewDidLoad {
[super viewDidLoad];
}


-(void) rtk:(DJIRTK *)rtk didUpdateState:(DJIRTKState *)state
{
self.shifoushiyong.text = [NSString stringWithFormat:@"%d",state.isRTKBeingUsed];

}



- (void)registerApp
{
[DJISDKManager registerAppWithDelegate:self];
}

-(void)updateUI
{
...
}

...

@end

最佳答案

TLDR:您以错误的方式使用了 RTK 委托(delegate)方法。

didUpdateState:是一个委托(delegate)方法。您需要将委托(delegate)对象传递给您的 RTK 对象。当数据来自飞机时,将调用 didUpdateState。您不必手动执行此操作。

此外,您不应该初始化自己的 RTK 对象:

1/确认SDK已经注册后(DJISSDKManager的委托(delegate)方法),获取产品

- (void)appRegisteredWithError:(NSError *_Nullable)error {
DJISDKManager.product
// continue here
}

https://developer.dji.com/api-reference/ios-api/Components/SDKManager/DJISDKManager.html#djisdkmanager_product_inline

2/验证它是一个 DJIAircraft 类

if ([[DJISDKManager.product class] isKindOf:[DJIAircraft class]) {
// Continue here
}

https://developer.dji.com/api-reference/ios-api/Products/Aircraft/DJIAircraft.html?search=djiaircraft&i=0&

3/从那里获取 RTK 对象:

DJIRTK *rtk = aircraft.flightController.RTK;

https://developer.dji.com/api-reference/ios-api/Components/FlightController/DJIFlightController.html#djiflightcontroller

4/将委托(delegate)设置为 RTK(一个实现了 DJIRTKDelegate 的类——这里假设为 self)

rtk.delegate = self;

https://developer.dji.com/api-reference/ios-api/Components/RTK/DJIRTK.html#djirtk_protocol_inline

5/像你一样在委托(delegate)方法中获取数据。

- (void)rtk:(DJIRTK *_Nonnull)rtk didUpdateState:(DJIRTKState *_Nonnull)state {
// Show me the data
}

https://developer.dji.com/api-reference/ios-api/Components/RTK/DJIRTK.html#djirtk_updatertkstate_inline

关于ios - DJI sdk 获取RTK信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51297295/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com