Accelerometer Low Pass Filtering

两盒软妹~` 提交于 2019-11-27 12:56:49
accelX = (acceleration.x * kFilteringFactor) + (accelX * (1.0 - kFilteringFactor));

Whats happening in this code you are multiplying the acceleration at the moment by the Filtering factor 0.1 and then adding it to the filtered acceleration of the last time an update was called by 0.9.

This is pretty much getting the new value and adding it as 10% of the total accelX the other 90% is made up of the previous value which depends on the value before that, which depends on the value before that and so on. This cuts out high frequency values as only allows 10% of any change to go through to the new accelX value.

The KFilteringFactor of 0.1 makes this filter cut out all high frequencies. You will definitely want to experiment by changing this value to suit your particular application.

Since you're working through the Big Nerd Ranch Book - a good idea would be to go on to the Book's discussion forum.

For more information have a look at the Wikepedia article about low pass filters.

And for another example of filtering have a look at Apple's AccelerometerGraph example

Also - think if you take kFilteringFactor to be 0.2 which gives the multipliers for the current value to be 0.8 which is 1 - 0.2, and the multiplier for the new value is 2.0 because it's 0.2 x 10

I suppose 10 is the scaling factor to give reasonable values.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!