我试图通过使用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
1 回答
TLDR:您正在以错误的方式使用RTK委托方法 .
didUpdateState:是一个委托方法 . 您需要将委托对象传递给RTK对象 . 当数据来自飞机时,将调用didUpdateState . 您不必手动执行此操作 .
此外,您不应该初始化自己的RTK对象:
1 /确认SDK已注册(DJISDKManager的委托方法)后,获取产品
https://developer.dji.com/api-reference/ios-api/Components/SDKManager/DJISDKManager.html#djisdkmanager_product_inline
2 /确认它是DJIAircraft课程
https://developer.dji.com/api-reference/ios-api/Products/Aircraft/DJIAircraft.html?search=djiaircraft&i=0&
3 /从那里获取RTK对象:
https://developer.dji.com/api-reference/ios-api/Components/FlightController/DJIFlightController.html#djiflightcontroller
4 /将委托设置为RTK(实现DJIRTKDelegate的类 - 假设自己在这里)
rtk.delegate = self;
https://developer.dji.com/api-reference/ios-api/Components/RTK/DJIRTK.html#djirtk_protocol_inline
5 /像您一样在委托方法中获取数据 .
https://developer.dji.com/api-reference/ios-api/Components/RTK/DJIRTK.html#djirtk_updatertkstate_inline