Sensor fusioning with Kalman filter

前端 未结 3 910
太阳男子
太阳男子 2020-12-23 22:50

I\'m interested, how is the dual input in a sensor fusioning setup in a Kalman filter modeled?

Say for instance that you have an accelerometer and a gyro and want to

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-23 23:20

    The gyro measures rate of angle change (e.g. in radians per sec), while from accelerometer reading you can calculate the angle itself. Here is a simple way of combining these measurements:

    At every gyro reading received:

    angle_radians+=gyro_reading_radians_per_sec * seconds_since_last_gyro_reading
    

    At every accelerometer reading received:

    angle_radians+=0.02 * (angle_radians_from_accelerometer - angle_radians)
    

    The 0.02 constant is for tuning - it selects the tradeoff between noise rejection and responsiveness (you can't have both at the same time). It also depends on the accuracy of both sensors, and the time intervals at which new readings are received.

    These two lines of code implement a simple 1-dimensional (scalar) Kalman filter. It assumes that

    • the gyro has very low noise compared to accelerometer (true with most consumer-grade sensors). Therefore we do not model gyro noise at all, but instead use gyro in the state transition model (usually denoted by F).
    • accelerometer readings are received at generally regular time intervals and accelerometer noise level (usually R) is constant
    • angle_radians has been initialised with an initial estimate (f.ex by averaging angle_radians_from_accelerometer over some time)
    • therefore also estimate covariance (P) and optimal Kalman gain (K) are constant, which means we do not need to keep estimate covariance in a variable at all.

    As you see, this approach is simplified. If the above assumptions are not met, you should learn some Kalman filter theory, and modify the code accordingly.

提交回复
热议问题