CMMotionManager and Low-pass filter

lowpass_filterIn Catchup, an iPhone game I recently published on the app store, I am using device motion sensor in order to move the main character. In order to make the character movements smooth I’m using a low-pass filter.

Low-pass filter provides a smoother form of a signal, removing the short-term fluctuations, and leaving the longer-term trend.

More details about the Low-pass filter:

Filter constants:

As the time constant RC increases the smooting factor alpha decreases and the output responds more slowly to the change.

Motion manager:

Reading the filtered values:

If you liked this blog post I’d appreciate if you followed me on Twitter

Related Post

Remember to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInEmail this to someone

2 thoughts on “CMMotionManager and Low-pass filter

  1. There’s no point in setting _motionManager.accelerometerUpdateInterval = dt;

    This property only affects the updates added to an operation queue..

  2. You’re correct, my example shows reading data from the CMMotionManager instance at no particular time hence the parameter is irrelevant. A usual use case is, as you mentioned, when you startAccelerometerUpdates to a queue and provide a handler to observe changes. In that case be sure to set the accelerometerUpdateInterval.

Leave a Reply

Your email address will not be published. Required fields are marked *