I've written an iOS
app that relies on moving the device throughout physical space. I'm dealing with noise on the IMU
and for those of you who know much about accelerometers
you may have heard about the double integration issues.
If I lay my device on the table it picks up enough noise that it thinks it's moving slowly. I incorporated a "minimum" value and this seems to work but it also means if you move the device very slow you won't pick up the movement.
What is a good way to filter out this unwanted noise? Kalman Filter?
float ax = 0, ay = 0, az = 0;
float MIN = 0.002;
int MULT = 5;
...
[self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue]
withHandler:^(CMAccelerometerData *data, NSError *error) {
float x = data.acceleration.x;
float y = data.acceleration.y;
float z = data.acceleration.z;
// find & store difference between last accel amount
float dx = ax - x;
float dy = ay - y;
float dz = az - z;
float diff = fabsf(dx + dy + dz);
NSLog(@"%f %f %f", dx, dy, dz);
if(diff > MIN * MULT) {
// work some magic
}
// save current values for next iteration
ax = x;
ay = y;
az = z;
}];