Is Sensor.TYPE_LINEAR_ACCELERATION in Android same as userAcceleration in IOS

933 Views Asked by At

Hi I was wondering if the readings you get from TYPE_LINEAR_ACCELERATION which are the accelerometer readings without gravity the equivalent of the readings you get from userAcceleration in IOS. From what I can see they are the accelerometer readings minus gravity but just want to make sure since Apple doesn't release any source code.

1

There are 1 best solutions below

0
On

Yes, they are the same, as both of them measure the total acceleration minus gravity (i.e. the acceleration imparted on the device by the user).

One important thing to note is that the measurement units and the reference frames of iOS and Android are different. Android measures acceleration in m/s^2, while iOS measures in g's (roughly 9.81 m/s^2). The reference frames appear to be identical in the documentation (see links below), but iOS reference frame is in fact the opposite of Android reference frame. For instance, when the device is stationary on a table, iOS measures approximately -1.0 on the z axis, while Android measures approximately 9.81 m/s^2 (note that iOS value is negative and Android value is positive).

To convert iOS readings to the Android reference frame and measurement units, you can multiply iOS readings from all axes (x, y and z) by -g (roughly -9.81):

acc_x_iOS * -9.81 ≡ acc_x_Android
acc_y_iOS * -9.81 ≡ acc_y_Android
acc_z_iOS * -9.81 ≡ acc_z_Android

iOS docs: https://developer.apple.com/documentation/coremotion/getting_processed_device-motion_data/understanding_reference_frames_and_device_attitude

Android docs: https://developer.android.com/guide/topics/sensors/sensors_overview