CMDeviceMotion userAcceleration upside down?

I see 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 the table, then reading is 1G down (1G in the Z axis), and if I reset the iphone (on a soft surface, of course), then the accelerator’s reading zero as expected. This is all wonderful. When I use the CMDeviceMotion class instead, the userAcceleration reading is zero as expected when the iPhone is flat on the table. Again, this is wonderful. But when I drop the iPhone and read the CMDeviceManager user control, the userAcceleration values ​​are 1G (+ Z), not down (-Z), as expected. It seems that the userAcceleration readings are actually the exact opposite of what kind of acceleration the device actually experiences. Has anyone else noticed this? Can I just invert (multiply by -1) all userAcceleration values ​​before trying to integrate for speed and position, or I don’t understand what userAcceleration is reading?

+4
source share
4 answers

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

  • Raw accelerometer data is just the sum of all measured accelerations, i.e. a combination of gravity and current acceleration of the device.
  • The device’s motion data is the result of the fusion of the sensors of all three sensors, that is, the accelerometer, gyroscope and magnetometer. Thus, deviations and errors are eliminated (theoretically), and the remaining acceleration data is divided into gravity and acceleration, which will be used conveniently.

So, if you want to compare both, you should check CMAccelerometerData.acceleration on CMDeviceMotion.userAcceleration + CMDeviceMotion.gravity for comparison as with similar ones.

In general, CMDeviceMotion is your first choice in most cases when you want to get accurate values ​​and equipment independence.

Another thing to consider is the CMAttitudeReferenceFrame , which you provide when starting Device Motion updates through startDeviceMotionUpdatesUsingReferenceFrame . I am not sure what is the default when using the base version of startDeviceMotionUpdates


You have stated that you want to integrate values ​​to obtain speed and position. There are several discussions about this, and on the bottom line I can say that it is impossible to get reasonable results. Cm:

If your application concept makes you rely on accurate results for more than half a second, try changing it.

+6
source

It turns out that CMAcceleration does not obey the rule of the right hand, which x points to the left, y points to the bottom of the screen, in this case with a typical right hand, the z axis should point to the upper side, but it does not. This makes me uncomfortable when working with motion sensors!

0
source

After 3 years, but still thinks that this is an unresolved issue. I don’t think that for CMAccelerometerData “everything is fine” read about 1 g in the Z axis, because according to their document ( https://developer.apple.com/library/content/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/motion_event_basics/motion_event_basics .html ) + Z from the screen to the outside. When the phone is placed on a table with the screen facing up, it means that it is experimenting with the upward power of the table. See the google talk section at 09:15. The same thing happens with x and y.

The gyro readings behave as described in the documentation, with x on the right, y at the top and z from the screen to the outside.

My conclusion is that you must invert all the axes of the accelerometer, and you will have the same coordinate system on the right as the gyroscope, and as the documentation.

0
source

As a newbie stack overflow, I apparently don't have enough reputation to comment on some other posts ... But I came to the same conclusion as cduguet. Based on the declared iPhone coordinate system ( https://developer.apple.com/documentation/coremotion/getting_processed_device_motion_data/understanding_reference_frames_and_device_attitude#2875084 ), these relationships are consistent with the declared coordinate axes. That is, the positive rotation of the phone (in the sense of "right right") around any axis registers a correspondingly positive increase in the gyroscope speed. What makes sense and what I expect.

However, when you transmit linear acceleration in a positive direction on any axis, CMmanager writes the data as a negative value. I did this test dozens of times on all axes and continued to find the same conflicting result.

I can change the sign of all the linear acceleration values ​​so that the equations of motion match the phone’s coordinate system, but I’m constantly trying to understand why Apple would choose this sign convention. It just doesn't make sense to me.

0
source

Source: https://habr.com/ru/post/1480543/


All Articles