记录的数据值保持不变 - DJI UXSDKDemo
Data Values Logged Remain Unchanged - DJI UXSDKDemo
我正在通过 iOS DJI UXSDKDemo 从 DJI 无人机记录 IMU 信息。使用下面的方法,我能够收到四个所需值(IMU 状态、IMU 计数、陀螺仪和加速度计)的日志。然而,当我 运行 应用程序连接到无人机时,日志被存储,来自这些航班的日志将四个值中的每一个都列为零。我连接应用程序的无人机没有飞行,但即使我四处移动无人机,值也不会改变。
除了 DefaultLayoutViewController.h 之外,我是否需要将任何文件导入 DefaultLayoutViewController.m?
我的方法不对吗?
- (void)showAlertViewWithMessage:(NSString *)message
{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController* alertViewController = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertViewController addAction:okAction];
UIViewController *rootViewController = [[UIApplication sharedApplication] keyWindow].rootViewController;
[rootViewController presentViewController:alertViewController animated:YES completion:nil];
//Printing Keys to Log; download logs from the page for this app on Itunes
DJIFlightControllerKey *IMUStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUState);
}];
DJIFlightControllerKey *IMUsCountForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUsCount];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUsCountForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUsCountForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUsCountForLog);
NSLog(@"%@", DJIFlightControllerParamIMUsCount);
}];
DJIFlightControllerKey *IMUStateGyroscopeStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUStateGyroscopeState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateGyroscopeStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateGyroscopeStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateGyroscopeStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUStateGyroscopeState);
}];
DJIFlightControllerKey *IMUStateAccelerometerStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUAccelerometerState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateAccelerometerStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateAccelerometerStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateAccelerometerStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUAccelerometerState);
}];
});
}
EDIT/UPDATE:
我实施了建议的更改。值现在正在打印,但它们很少出现并且看起来与加速度计和陀螺仪传感器的预期输出不同。加速度计和陀螺仪不应该输出三个值(x、y、z)吗?日志的代码和屏幕截图可以在下面找到。有什么建议吗?
- (void)viewDidLoad
{
[super viewDidLoad];
//Please enter your App Key in the info.plist file.
[DJISDKManager registerAppWithDelegate:self];
//Printing Keys to Log; download logs from the page for this app on Itunes
//GYROSCOPE
DJIFlightControllerKey *IMUStateGyroscopeStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUStateGyroscopeState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateGyroscopeStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateGyroscopeStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"LOG: GYROSCOPE: %ld", newValue.integerValue);
}];
//ACCELEROMETER
DJIFlightControllerKey *IMUStateAccelerometerStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUAccelerometerState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateAccelerometerStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateAccelerometerStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"LOG: ACCELEROMETER: %ld", newValue.integerValue);
}];
}
您正在尝试记录密钥,而不是在完成块中传回的实际数据。 E.X:
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUState);
}];
应该看起来像这样:
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%d", newValue.integerValue);
}];
与您开始侦听的键关联的值将返回到 DJIKeyedValue class。
我正在通过 iOS DJI UXSDKDemo 从 DJI 无人机记录 IMU 信息。使用下面的方法,我能够收到四个所需值(IMU 状态、IMU 计数、陀螺仪和加速度计)的日志。然而,当我 运行 应用程序连接到无人机时,日志被存储,来自这些航班的日志将四个值中的每一个都列为零。我连接应用程序的无人机没有飞行,但即使我四处移动无人机,值也不会改变。
除了 DefaultLayoutViewController.h 之外,我是否需要将任何文件导入 DefaultLayoutViewController.m?
我的方法不对吗?
- (void)showAlertViewWithMessage:(NSString *)message
{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController* alertViewController = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertViewController addAction:okAction];
UIViewController *rootViewController = [[UIApplication sharedApplication] keyWindow].rootViewController;
[rootViewController presentViewController:alertViewController animated:YES completion:nil];
//Printing Keys to Log; download logs from the page for this app on Itunes
DJIFlightControllerKey *IMUStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUState);
}];
DJIFlightControllerKey *IMUsCountForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUsCount];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUsCountForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUsCountForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUsCountForLog);
NSLog(@"%@", DJIFlightControllerParamIMUsCount);
}];
DJIFlightControllerKey *IMUStateGyroscopeStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUStateGyroscopeState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateGyroscopeStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateGyroscopeStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateGyroscopeStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUStateGyroscopeState);
}];
DJIFlightControllerKey *IMUStateAccelerometerStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUAccelerometerState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateAccelerometerStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateAccelerometerStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateAccelerometerStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUAccelerometerState);
}];
});
}
EDIT/UPDATE: 我实施了建议的更改。值现在正在打印,但它们很少出现并且看起来与加速度计和陀螺仪传感器的预期输出不同。加速度计和陀螺仪不应该输出三个值(x、y、z)吗?日志的代码和屏幕截图可以在下面找到。有什么建议吗?
- (void)viewDidLoad
{
[super viewDidLoad];
//Please enter your App Key in the info.plist file.
[DJISDKManager registerAppWithDelegate:self];
//Printing Keys to Log; download logs from the page for this app on Itunes
//GYROSCOPE
DJIFlightControllerKey *IMUStateGyroscopeStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUStateGyroscopeState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateGyroscopeStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateGyroscopeStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"LOG: GYROSCOPE: %ld", newValue.integerValue);
}];
//ACCELEROMETER
DJIFlightControllerKey *IMUStateAccelerometerStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUAccelerometerState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateAccelerometerStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateAccelerometerStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"LOG: ACCELEROMETER: %ld", newValue.integerValue);
}];
}
您正在尝试记录密钥,而不是在完成块中传回的实际数据。 E.X:
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUState);
}];
应该看起来像这样:
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%d", newValue.integerValue);
}];
与您开始侦听的键关联的值将返回到 DJIKeyedValue class。