2

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;
     }];
Community
  • 1
  • 1
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
  • 1
    I know this is old, but I was having the same problem with my app that records device movement to be played back later and I found a workaround by collecting data every 1/30 seconds and filling in the remaining 50% of my 60fps recording by averaging the two positions. Maybe this could help? – Adalex3 Jul 15 '19 at 21:32
  • @Adalex3 Clever solution, thanks for the comment. At some point I started leveraging optical slam which works on pretty much any device with a camera. Cheers! – Jacksonkr Jul 16 '19 at 21:13

0 Answers0