I want to use the accelerometer in android for my app.
In documentation its given as below:
final float alpha = 0.8;
// Isolate the force of gravity with the low-pass filter.
gravity[0] = alpha * gravity[0] + (1 - alpha) * event.values[0];
But lowpass filter works as below:
output = alpha*input + (1-alpha)*previousoutput;
My query is why we are taking gravity as input and sensor event as previous output?
It must be other way around.
Technically it uses linear mix of two inputs:
mix(α,x,y) = α * x + (1-α) * y.Now
mix(α,x,y)is equivalent tomix(1-α,y,x).So you can reverse signals as you wanted, make
alpha = 0.2and everything will work the same.