Coder Social home page Coder Social logo

kalmanfilterav's Introduction

1、概述

这是一个针对编码器采集的速度的卡尔曼滤波。原汁原味的卡尔曼滤波代码参考:

https://github.com/TKJElectronics/KalmanFilter,是关于mpu6050之类的imu的滤波算法

详细的推到过程参考:

http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it/

有关卡尔曼滤波和卡尔曼增益的详细推导过程,目前我所找到的最好的教程参考B站:

CAN神 https://www.bilibili.com/video/BV1ez4y1X7eR

kalmanfilter.ods是用LibreOffice做的可视化图表,用EXCEL打开就行。

2、推导过程

系统状态$x_k$

上一时刻的后验估计状态用${\hat{x}}{k-1|k-1}$表示;先验状态( priori state)用${\hat{x}}{k|k-1}$表示,先验状态是根据上一个状态估计出的先验值;后验状态(posteriori state)用${\hat{x}}_{k|k}$表示;$x_k$代表真实值。

系统k时刻的状态为:

image-20210609173646802

其中 state matrix

image-20210609173814640

其中v是速度,a是加速度,速度的导数。

状态转移矩阵 state transition model:

image-20210609173900131

$w_k$0均值的高斯分布的过程噪声

image-20210609173918899

$Q_K$过程误差协方差矩阵

image-20210609173933896

$Q_k$协方差矩阵依赖于时间,时间越久误差越大,$Q_k$设置的越大,状态估计的噪声会越多,设置对于状态估计的置信度,可以通过更改Excel中这两个参数观察曲线变化,关于$Q_k$的值初始化参考kalman滤波理解三:协方差矩阵的计算_JK-CSDN博客_误差协方差矩阵

测量值$z_k$

观测空间observation 获取测量值$z_k$和真实值$x_k$:

image-20210609173956207

本文中的观测量是速度v,其中$v_k$是测量噪声measurement noise,$H$是观测模型observation model

image-20210609174340868

观测噪声符合高斯分布:

image-20210609174519504

$R$是测量噪声协方差矩阵,可通过测一组传感器数据获取或者传感器说明书获取,此处就等于$v$的方差:

image-20210609174021731

$R$越小,对于数据的跟随性越好,越大,平滑度越好,更改观察Excel表中数据和图。

接下来是两个主要步骤,预测和校正

预测

image-20210609174039952

下面是先验误差状态协方差矩阵priori error covariance matrix:

image-20210609174052876

此矩阵代表对于当前估计值的置信度,这里$P$是一个2x2矩阵:

image-20210609174112624

校正

首先计算测量值与通过先验状态观测值的差,可正可负,叫做innovation,革新?

image-20210609174130737

观测模型$H$ 的作用是,将先验状态${\hat{x}}_{k|k-1}$映射到传感器测量值所在的观测空间

计算innovation协方差矩阵:

image-20210609174143904

同理,$H$的作用是将先验误差协方差矩阵映射到观测空间。测量值的噪音越大,则$S$越大,代表我们不太相信新的测量值。

接下来是卡尔曼增益Kalman gain,指明我们相信innovation的程度:

image-20210609174159548

例如我们不太相信innovation而是相信先验估计值,则$P$会比较小,$S$会比较大。

如果不知到初始状态值可以设置误差协方差矩阵为:

image-20210609174211132

如果已知初始状态:

image-20210609174228803

然后更新后验状态

image-20210609174243553

最后更新后验误差协方差矩阵posteriori error covariance matrix:

image-20210609174256987

其中$I$是单位对角矩阵。

3、具体公式推导

kalmanfilterav's People

Contributors

mm-x avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.