How to implement a LowPass Filter?

后端 未结 3 528
余生分开走
余生分开走 2021-02-09 14:20

I\'m doing some math on both gyroscope and accelerometer data combined and I\'d like to low pass filter the resulting data. So could someone post some generic code for a Low Pas

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-09 15:06

    A 1st order IIR low-pass filter can be of the form:

    output_value = rate * input_value + (1.0 - rate) * previous_output_value;
    

    which is pretty much what's inside Apple's AccelerometerGraph example. You select the rate parameter depending on what frequency (very very roughly shakes per second) you want to roll-off or start to attenuate to get a smoother resulting output, and the sample rate of the input data.

提交回复
热议问题