记录的数据值保持不变-DJI UXSDKDemo [英] Data Values Logged Remain Unchanged - DJI UXSDKDemo

查看:102
本文介绍了记录的数据值保持不变-DJI UXSDKDemo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过iOS DJI UXSDKDemo从DJI无人机记录IMU信息.使用以下方法,我可以接收四个所需值(IMU状态,IMU计数,陀螺仪和加速度计)的日志.但是,当我运行连接到无人机的应用程序时,将存储日志,这些航班的日志将四个值中的每一个都列为零.我连接应用程序的无人机没有飞行,但是即使我四处移动无人机,其值也不会改变.

I am logging IMU Information from a DJI Drone via the iOS DJI UXSDKDemo. Using the method below, I am able to receive a log of the four desired values (IMU State, IMU Count, Gyroscope, and Accelerometer). When I run the app connected to a drone, however, the logs are stored, the logs from these flights list each of the four values as zero. The drone I am connecting the app to is not flying, yet even when I move the drone around, the values do not change.

我是否需要将除DefaultLayoutViewController.h以外的任何文件导入到DefaultLayoutViewController.m?

Do I need to import any files to the DefaultLayoutViewController.m other than DefaultLayoutViewController.h?

我的方法不正确吗?

- (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);

            }];


    });
}

编辑/更新: 我实施了建议的更改.现在正在打印值,但是它们很少出现,并且看起来与加速度计和陀螺仪传感器的预期输出不同.加速度计和陀螺仪是否应该输出三个值(x,y,z)?可以在下面找到日志的代码和屏幕截图.有什么建议吗?

EDIT/UPDATE: I implemented the suggested changes. Values are now printing, but they occur infrequently and seem different than the expected output of the accelerometer and gyroscope sensors. Shouldn't the accelerometer and gyroscope be outputting three values (x,y,z)? The code and a screenshot of the log can be found below. Any suggestions?

- (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:

You are trying to log the key not the actual data that is being passed back in the completion block. 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类内部返回.

The value associate with the key you start listening on will be returned inside of the DJIKeyedValue class.

这篇关于记录的数据值保持不变-DJI UXSDKDemo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆