首页 > 解决方案 > 加速度计和陀螺仪多值 - DJI iOS UXSDKDemo

问题描述

有没有办法从所有三个轴(xyz)获取加速度计和陀螺仪传感器数据?使用下面的代码,我始终记录“LOG:陀螺仪:5.0000”或“LOG:陀螺仪:6.0000”。加速度计也会出现同样的结果。为什么每个轴只输出一个值而不是三个?另外,为什么值恰好是 5 和 6 一致?不应该有更多的变化吗?

//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: %f", newValue.doubleValue);
    }];




//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: %f", newValue.doubleValue);
    }];

标签: objective-cdji-sdktelemetry

解决方案


嗨,我已经对这个问题进行了更多研究。您正在记录的值是在枚举中声明的 IMU 和陀螺仪的整体状态,因此为什么您没有获得您正在寻找的值的恒定状态。对我们而言,此数据不可用似乎是一个错误。


推荐阅读