views:

355

answers:

2

Hi,

I found the following piece of code in apple guidelines:

- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
    //Use a basic low-pass filter to only keep the gravity in the accelerometer values
    accel[0] = acceleration.x * kFilteringFactor + accel[0] * (1.0 - kFilteringFactor);
    accel[1] = acceleration.y * kFilteringFactor + accel[1] * (1.0 - kFilteringFactor);
    accel[2] = acceleration.z * kFilteringFactor + accel[2] * (1.0 - kFilteringFactor);
}

What does it exactly do? What is this low-pass filter? Why do I have to apply it?

Thank you in advance.

+3  A: 

What you need to do depends on what you need the value for, but the basic idea is to reduce the effect of vibrations from hand movements and such. If you take the raw acceleration values and treat them as a gravity vector, you’ll get a lot of jitter.

Ahruman
A: 

I also want to know the same thing that if i am calculating acceleration values for a runner then what should be the kFilteringFactor ,and exactly what it is ,what should be the the KUpdateFrequency? Can anybody please help me as i need it asap for my project. Thanks in advance ..

RChaudhary