objective-c - 加速度计和陀螺仪多值 - 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);
}];
解决方案
嗨,我已经对这个问题进行了更多研究。您正在记录的值是在枚举中声明的 IMU 和陀螺仪的整体状态,因此为什么您没有获得您正在寻找的值的恒定状态。对我们而言,此数据不可用似乎是一个错误。
推荐阅读
- r - 在 R 传单中显示 David Rumsey 的地理参考图块
- java - 在 Android Studio 3.1 中的当前主题中找不到样式“coordinatorLayoutStyle”
- python - Plotly 中的 Numpy 3D 数组切片查看器
- python - 如何计算 Python 3.6 中函数的调用次数?
- node.js - 如何在 nodejs 中从 goDaddy 安装 SSL 证书?
- php - 在同一文件夹中找不到可用文件
- three.js - three.js 是否计算面列表中未引用的顶点?
- javascript - 提取传单中标记的属性,onClick 事件
- javascript - 如何迁移cookie域并保留值
- python - 有没有办法只标记一个要运行的测试?