CMDeviceMotion userAcceleration 倒挂? [英] CMDeviceMotion userAcceleration is upside down?

查看:25
本文介绍了CMDeviceMotion userAcceleration 倒挂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CMDeviceMotion 中的 userAcceleration 字段中看到了一些意外读数.当我查看来自 CMAccelerometerData 的原始加速度计数据时,我看到如果 iPhone 平放在桌子上,读数是 1G(在 -Z 轴上为 1G),如果我放下 iPhone(当然是在柔软的表面上)然后加速度计读数按预期变为零.这一切都很好.当我改为使用 CMDeviceMotion 类时,当 iPhone 平放在桌子上时,userAcceleration 读数按预期为零.再次这很好.但是当我放下 iPhone 并读取 CMDeviceManager userAcceleration 时,userAcceleration 值是 1G,按预期直接向上 (+Z) 而不是向下 (-Z).看来用户加速度读数实际上与设备实际经历的加速度完全相反.有没有其他人观察到这一点?我可以在尝试对速度和位置进行积分之前反转(乘以 -1)所有 userAcceleration 值,还是我误解了 userAcceleration 正在读取的内容?

I'm seeing some unexpected readings from the userAcceleration field in CMDeviceMotion. When I look at the raw accelerometer data from CMAccelerometerData, I see that if the iPhone is flat on a table the reading is 1G straight down (1G in -Z axis) and if I drop the iphone (on a soft surface of course) then the acceleromtere reading goes to zero as expected. That's all fine. When I instead use the CMDeviceMotion class, the userAcceleration reading is zero as expected when the iPhone is flat on table. Again this is fine. But when I drop the iPhone and read the CMDeviceManager userAcceleration, the userAcceleration values are 1G straight up (+Z) not down (-Z) as expected. It appears that the userAcceleration readings are actually the exact opposite of what acceleration the device is really experiencing. Has anyone else observed this? Can I just invert (multiply by -1) all the userAcceleration values before I try to integrate for velocity and position, or am I misunerstanding what userAcceleration is reading?

推荐答案

CMAccelerometerData.accelerationCMDeviceMotion.userAcceleration

  1. 原始加速度计数据只是所有测量加速度的总和,即设备的重力和当前加速度的组合.
  2. 设备运动数据是所有 3 个传感器(即加速度计、陀螺仪和磁力计)融合的结果.从而消除偏差和误差(理论上),并将剩余的加速度数据分离为重力和加速度以方便使用.

因此,如果您想比较两者,您必须检查 CMAccelerometerData.accelerationCMDeviceMotion.userAcceleration + CMDeviceMotion.gravity 以进行比较.

So if you want to compare both you have to check CMAccelerometerData.acceleration against CMDeviceMotion.userAcceleration + CMDeviceMotion.gravity to compare like with like.

一般来说,在大多数情况下,当您想要精确的值和硬件独立性时,CMDeviceMotion 是您的首选.

In general CMDeviceMotion is your first choice in most cases when you want precise values and hardware independency.

另一件需要考虑的事情是 CMAttitudeReferenceFrame 您在通过 startDeviceMotionUpdatesUsingReferenceFrame.我不确定使用基本版本时的默认值是什么 startDeviceMotionUpdates

Another thing to consider is the CMAttitudeReferenceFrame you provide when starting Device Motion updates via startDeviceMotionUpdatesUsingReferenceFrame. I am not sure what is the default when using the basic version startDeviceMotionUpdates

您表示要对这些值进行积分以获得速度和位置.对此有几个讨论,归根结底,我可以说不可能获得合理的结果.见:

You stated that you want to integrate the values to get velocity and position. There are several discussions about this and at the bottom line I can say it's impossible to get reasonable results. See:

如果您的应用概念迫使您依赖精确结果超过半秒,请尝试改变它.

If your app concept forces you to rely on precise results for more than half a second, try to change it.

这篇关于CMDeviceMotion userAcceleration 倒挂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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