CMDeviceMotion userAcceleration is upside down?

[亡魂溺海] 提交于 2019-12-04 10:47:24
Kay

There are some conceptual differences between CMAccelerometerData.acceleration and CMDeviceMotion.userAcceleration

  1. Raw accelerometer data is just the sum of all accelerations measured i.e. a combination of gravity and current acceleration of the device.
  2. Device motion data is the result of sensor fusion of all 3 sensors i.e. accelerometer, gyroscope and magnetometer. Thus bias and errors are eliminated (in theory) and the remaining acceleration data is separated into gravity and acceleration to be used conveniently.

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

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

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.

It turns out the CMAcceleration is not obey the right hand rule, which x is point to left, y is point to the screen bottom, in that case, with a typical right hand system, z axis should point to the upper side,but its not. It makes me uncomfortable when dealing with motion sensors!

3 years after but still thinks this is an unresolved matter. I don't think it is "all fine" for CMAccelerometerData to read approx 1g in -Z axis, because according to their doc (https://developer.apple.com/library/content/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/motion_event_basics/motion_event_basics.html) +Z is from the screen outwards. When the phone is laying on a table, with screen facing up, it means it is experimenting the upward force of the table. See This google talk at 09:15. The same happens with x and y.

The gyro readings are behaving like described in the documentation, with x to the right, y to the top, and z from the screen outwards.

My conclusion is, you have to invert all accelerometer axes, and you will have the same right hand coordinate system like the gyro and like the documentation.

As a stack overflow newbie, I apparently don't have enough reputation to comment on some of the other posts... But I have reached the same conclusion as cduguet. Based on the advertised iPhone coordinate system (https://developer.apple.com/documentation/coremotion/getting_processed_device_motion_data/understanding_reference_frames_and_device_attitude#2875084), the attitudinal data is consistent with the advertised coordinate axes. That is, a positive rotation of the phone (in a "right hand rule" sense) about any axis registers an appropriately positive gyro velocity increase. What makes sense and what I would expect.

However, when you impart an linear acceleration in the positive direction on any axis, the CMmanager records the data as a negative value. I've done this test dozens of times on all the axes and keep finding the same counterintuitive result.

I can change the sign of all the linear acceleration values to make the equations of motion consistent with the phone coordinate system, but I keep trying to understand why Apple would choose this sign convention. It just doesn't make sense to me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!