ios accelerometer values at any orientation
Asked Answered
A

1

2

Accelerometer values are provided with respect to the device orientation..

My goal is to get these values irrespective of the device position.

In a considered scenario, if the device is placed in a vehicle, placed face up or horizontally, the accelerometer values along y would indicate the vehicles acceleration.

What if the device is placed in the glove box with random orientation? We can get the roll pitch and yaw values, and convert them into degrees to get the angular displacement of device from the normal face up orientation position but at that random orientation moment, can I get/convert the acceleration values into the the normal face up orientation position values?

Basically what I am following is: get the angular displacement of device -> convert the accelerometer values received at the distorted position to a normal face up orientation position -> get the Y to see the actual acceleration of vehicle irrespective of the device position.

Reference (Point 3.1): http://www.itsasiapacificforum2014.co.nz/files/3314/0194/4873/Abstract_-_Automatic_Accelerometer_Reorientation_for_Driving_Event_Detection_Using_Smartphone_by_Passakon_Prathombutr.pdf

Aphorism answered 10/3, 2015 at 9:21 Comment(2)
This might help? blog.sallarp.com/iphone-accelerometer-device-orientationMiyokomizar
Just to note that, as of today, that link has goneDoretheadoretta
C
0

Its quite simple actually, just start generating device motion updates using a reference frame:

- (void)startDeviceMotionUpdatesUsingReferenceFrame:(CMAttitudeReferenceFrame)referenceFrame

Depending on what you want to achieve you can select one of the different options

typedef enum {
   CMAttitudeReferenceFrameXArbitraryZVertical = 1 << 0,
   CMAttitudeReferenceFrameXArbitraryCorrectedZVertical = 1 << 1,
   CMAttitudeReferenceFrameXMagneticNorthZVertical = 1 << 2,
   CMAttitudeReferenceFrameXTrueNorthZVertical = 1 << 3
} CMAttitudeReferenceFrame;

For example, by using "CMAttitudeReferenceFrameXMagneticNorthZVertical" the readings you get from the acceleration would be constant regardless of the device position (they get aligned with "gravity" bellow" and "north" in front). I don't remember the exact reference position but i believe the "top of the phone" points north while the "screen of the phone" points up.

Coheman answered 11/3, 2015 at 4:17 Comment(2)
I have plotted a graph using this and what I expect is no matter how the device is kept I should be able to get the real acceleration of device on Y axis, but that's not what I got. That's why I am calculating the angular displacement of device from the normal position (face up and placed horizontally). So, I can somehow translate the 3 axis back and calculate the acceleration at the normal positionAphorism
For the records, this is the current definition of CMAttitudeReferenceFrameXMagneticNorthZVertical: "Describes a reference frame in which the Z axis is vertical and the X axis points toward magnetic north. Note that using this reference frame may require device movement to calibrate the magnetometer."Doretheadoretta

© 2022 - 2024 — McMap. All rights reserved.