Question

How to detect the iPhone fell on the ground using the UIAccelerometer? I am using the following delegate to calculate the falling detection but it's not working correctly.

Is this calculation correct or not?
Please suggest any other type of detection.

Calculation : currentDeviceAcceleration = sqrt(9.81*x*x + 9.81*y*y + 9.81*z*z)

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{

    float x = acceleration.x;
    float y = acceleration.y;
    float z = acceleration.z;

    float currentDeviceAcceleration = sqrt(9.81*x*x + 9.81*y*y + 9.81*z*z);
        if (currentDeviceAcceleration > 8.5) {
             //Device felt on ground
        }

}
Was it helpful?

Solution

I suppose, the variables x to z store the acceleration in m/s².

So, the total acceleration in m/s² of the device is sqrt (x*x + y*y + z*z).

The conclusion however, that the device fell to the ground is false. any acceleration can reach that value.

I have 2 ideas how to solve this particular Problem

1) acceleration has to be constant (within a range) for a given time (e.g the time of the fall from a hand to the ground which would be about 0.35 seconds.)

2) after the free fall, the acceleration goes insanely up, depending on the surface the device is landing on. Maybe you could catch that. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top