Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interpret the accelerometer readings from iPhone

I am trying to build a Kinect and iPhone based application.

I am trying to compute the acceleration of my hands over time on each of the X Y and Z axis based on the trajectory returned by the kinect. Basically I am selecting a standard time interval of 0.5 seconds or 15 frames( dt ) and 3 points, ( x0, x1 and x2 ) over time which are separeted by 0.5 seconds. First I should mention that the position of the 3 points is mentioned in meters. By using these points I am computing two speeds(v0 = (x1 - x0) / dt and v1 = (x2 - x1) / dt). Finally, by using these speeds, I am computing the acceleration between x1 and x2 as acc = (v1 - v0) / dt.

I repeat these computation at each frame and I obtain an array of accelerations.

As I've said, I have also an iPhone and I want to see in which hand I have my iPhone, left hand or right hand. I want to do this by trying to match the accelerations of my hand with the accelerations of the iPhone held in the right position so that I have the same axis system.

The only problem is that there is a huge difference between my accelerations and the accelerations of the phone.

The phone acceelaration readings are somewhere between -2 and 2 for each axis, whereas mine are between -10 and 10. How should I interpret the iPhone accelerations in order to obtain similar measures to mine in meter / seconds ?

like image 1000
Simon Avatar asked May 08 '12 07:05

Simon


1 Answers

Accelerometer data on the iPhone is provided in units of g-force. The x-axis is aligned with the top edge of your phone screen, the y-axis is aligned with the left edge, and the z-axis comes straight out of the screen towards you if you're looking at it. So with your phone resting on the table face-up, you should get values of (0, 0, -1) for the x, y, and z axes respectively. If you drop your phone, while it is in free-fall you should get (0, 0, 0).

Assuming you keep the phone aligned like this as you move it around, to get the 3-Dimensional acceleration in metres per second squared:

- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
    float g = 9.80665f;
    float x = acceleration.x * g;
    float y = acceleration.y * g;
    float z = (acceleration.z + 1.0f) * g;
    // x, y, and z now hold the absolute acceleration in ms^-2
}

Notice that you must subtract the effect of Earth's gravity in order to get the acceleration relative to your living room rather than relative to 4-Dimensional space-time.

Also be aware that the iPhone accelerometer is quite noisy and these values jitter around even when the phone is static, so you will want to apply some smoothing. However, if you use a similar technique to what you seem to be doing with the position data, putting the values into an array each frame in order to get a rolling average over the last 0.5 seconds, this will already smooth the data for you.

Another thing to be aware of is that the iPhone accelerometer peaks out at about 2.3g. These g-forces are not difficult to achieve (for example if you clap your hands together) so you may exceed them and techniques that accumulate data will not be very reliable.

like image 89
jhabbott Avatar answered Nov 03 '22 20:11

jhabbott