卡尔曼滤波1

 

卡尔曼滤波——做传感器想用的算法

只是不知道单片机是否跑得动……
以下内容摘自维基百科

卡尔曼滤波是一种高效率的递归滤波器(自回归滤波器), 它能够从一系列的不完全包含噪声测量(英文:measurement)中,估计动态系统的状态。

目录

[隐藏]
<script type="text/javascript"> // </script>

[编辑] 应用实例

卡尔曼滤波的一个典型实例是从一组有限的,包含噪声的,对物体位置的观察序列(可能有偏差)预测出物体的位置的坐标速度. 在很多工程应用(如雷达, 计算机视觉)中都可以找到它的身影. 同时,卡尔曼滤波也是控制理论以及控制系统工程中的一个重要课题.

例如,对于雷达来说,人们感兴趣的是其能够跟踪目标.但目标的位置,速度,加速度的测量值往往在任何时候都有噪声.卡尔曼滤波利用目标的动态信息,设法去掉噪声的影响,得到一个关于目标位置的好的估计。这个估计可以是对当前目标位置的估计(滤波),也可以是对于将来位置的估计(预测),也可以是对过去位置的估计(插值或平滑).

[编辑] 命名

这种滤波方法以它的发明者鲁道夫.E.卡尔曼(Rudolph E. Kalman)命名,但是根据文献可知实际上Peter Swerling在更早之前就提出了一种类似的算法。

斯坦利.施密特(Stanley Schmidt)首次实现了卡尔曼滤波器。卡尔曼在NASA埃姆斯研究中心访问时,发现他的方法对于解决阿波罗计划的轨道预测很有用,后来阿波罗飞船的导航电脑便使用了这种滤波器。 关于这种滤波器的论文由Swerling (1958)、Kalman (1960)与 Kalman and Bucy (1961)发表。

目前,卡尔曼滤波已经有很多不同的实现.卡尔曼最初提出的形式现在一般称为简单卡尔曼滤波器。除此以外,还有施密特扩展滤波器,信息滤波器以及很多Bierman, Thornton 开发的平方根滤波器的变种。也许最常见的卡尔曼滤波器是锁相环,它在收音机、计算机和几乎任何视频或通讯设备中广泛存在。


以下的讨论需要线性代数以及概率论的一般知识。


[编辑] 基本动态系统模型

卡尔曼滤波建立在线性代数隐马尔可夫模型(hidden Markov model)上。其基本动态系统可以用一个马尔可夫链表示,该马尔可夫链建立在一个被高斯噪声(即正态分布的噪声)干扰的线性算子上的。系统的状态可以用一个元素为实数的向量表示。 随着离散时间的每一个增加,这个线性算子就会作用在当前状态上,产生一个新的状态,并也会带入一些噪声,同时系统的一些已知的控制器的控制信息也会被加入。同时,另一个受噪声干扰的线性算子产生出这些隐含状态的可见输出。

为了从一系列有噪声的观察数据中用卡尔曼滤波器估计出被观察过程的内部状态,我们必须把这个过程在卡尔曼滤波的框架下建立模型。也就是说对于每一步k,定义矩阵Fk, Hk, Qk, Rk,有时也需要定义Bk,如下。

卡尔曼滤波器的模型。圆圈代表向量,方块代表矩阵,星号代表高斯噪声,其协方差矩阵在右下方标出。
卡尔曼滤波器的模型。圆圈代表 向量,方块代表 矩阵,星号代表 高斯噪声,其 协方差矩阵在右下方标出。

卡尔曼滤波模型假设k时刻的真实状态是从(k − 1)时刻的状态演化而来,符合下式

/textbf{x}_{k} = /textbf{F}_{k} /textbf{x}_{k-1} + /textbf{B}_{k}/textbf{u}_{k}  + /textbf{w}_{k}

其中

  • Fk 是作用在xk−1上的状态变换模型(/矩阵/矢量)。
  • Bk 是作用在控制器向量uk上的输入-控制模型。
  • wk 是过程噪声,并假定其符合均值为零,协方差矩阵Qk多元正态分布
/textbf{w}_{k} /sim N(0, /textbf{Q}_k)

时刻k,对真实状态 xk的一个测量zk满足下式:

/textbf{z}_{k} = /textbf{H}_{k} /textbf{x}_{k} + /textbf{v}_{k}

其中Hk是观测模型,它把真实状态空间映射成观测空间,vk 是观测噪声,其均值为零,协方差为Rk,且服从正态分布

/textbf{v}_{k} /sim N(0, /textbf{R}_k)

初始状态以及每一时刻的噪声{x0, w1, ..., wk, v1 ... vk} 都为认为是互相独立的.

实际上,很多真实世界的动态系统都并不确切的符合这个模型;但是由于卡尔曼滤波器被设计在有噪声的情况下工作,一个近似的符合已经可以使这个滤波器非常有用了。更多其它更复杂的卡尔曼滤波器的变种,在下边讨论中有描述。

[编辑] 卡尔曼滤波器

卡尔曼滤波是一种递归的估计,即只要获知上一时刻状态的估计值以及当前状态的观测值就可以计算出当前状态的估计值,因此不需要记录观测或者估计的历史信息。卡尔曼滤波器与大多数滤波器不同之处,在于它是一种纯粹的时域滤波器,它不需要像低通滤波器频域滤波器那样,需要在频域设计再转换到时域实现。

卡尔曼滤波器的状态由以下两个变量表示:

  • /hat{/textbf{x}}_{k|k},在时刻k 的状态的估计;
  • /textbf{P}_{k|k},误差相关矩阵,度量估计值的精确程度。

卡尔曼滤波器的操作包括两个阶段:预测更新。在预测阶段,滤波器使用上一状态的估计,做出对当前状态的估计。在更新阶段,滤波器利用对当前状态的观测值优化在预测阶段获得的预测值,以获得一个更精确的新估计值。

[编辑] 预测

/hat{/textbf{x}}_{k|k-1} = /textbf{F}_{k}/hat{/textbf{x}}_{k-1|k-1} + /textbf{B}_{k} /textbf{u}_{k} (预测状态)
/textbf{P}_{k|k-1} =  /textbf{F}_{k} /textbf{P}_{k-1|k-1} /textbf{F}_{k}^{T} + /textbf{Q}_{k} (预测估计协方差)

[编辑] 更新

/tilde{/textbf{y}}_{k} = /textbf{z}_{k} - /textbf{H}_{k}/hat{/textbf{x}}_{k|k-1} (测量革新或余量,英文分别为measurement innovation与residual,请见 [1])
/textbf{S}_{k} = /textbf{H}_{k}/textbf{P}_{k|k-1}/textbf{H}_{k}^{T} + /textbf{R}_{k} (测量革新(余量)协方差)
/textbf{K}_{k} = /textbf{P}_{k|k-1}/textbf{H}_{k}^{T}/textbf{S}_{k}^{-1} (卡尔曼增益)
/hat{/textbf{x}}_{k|k} = /hat{/textbf{x}}_{k|k-1} + /textbf{K}_{k}/tilde{/textbf{y}}_{k} (更新的状态估计)
/textbf{P}_{k|k} = (I - /textbf{K}_{k} /textbf{H}_{k}) /textbf{P}_{k|k-1} (更新的协方差估计)

使用上述公式计算/textbf{P}_{k|k}仅在最优卡尔曼增益的时候有效。使用其他增益的话,公式要复杂一些,请参见推导

[编辑] 不变量(Invariant)

如果模型准确,那么/hat{/textbf{x}}_{0|0}/textbf{P}_{0|0} 的值准确的反映了最初状态的分布,那么以下的不变量就得到了保存:所有估计的均值都为零

  • /textrm{E}[/textbf{x}_k - /hat{/textbf{x}}_{k|k}] = /textrm{E}[/textbf{x}_k - /hat{/textbf{x}}_{k|k-1}] = 0
  • /textrm{E}[/tilde{/textbf{y}}_k] = 0

并且 协方差矩阵 准确的反映了以下估计的协方差:

  • /textbf{P}_{k|k} = /textrm{cov}(/textbf{x}_k - /hat{/textbf{x}}_{k|k})
  • /textbf{P}_{k|k-1} = /textrm{cov}(/textbf{x}_k - /hat{/textbf{x}}_{k|k-1})
  • /textbf{S}_{k} = /textrm{cov}(/tilde{/textbf{y}}_k)

请注意,其中/textrm{E}[/textbf{a}] = 0, /textrm{cov}(/textbf{a}) = /textrm{E}[/textbf{a}/textbf{a}^T]

[编辑] 实例

考虑在无摩擦的、无限长的直轨道上的一辆车。该车最初停在位置 0 处,但时不时受到随机的冲击。我们每隔Δt秒即测量车的位置,但是这个测量是非精确的;我们想建立一个关于其位置以及速度的模型。我们来看如何推导出这个模型以及如何从这个模型得到卡尔曼滤波器。

因为车上无动力,所以我们可以忽略掉Bkuk。由于FHRQ 是常数,所以时间下标可以去掉。

车的位置以及速度(或者更加一般的,一个粒子的运动状态)可以被线性状态空间描述如下:

/textbf{x}_{k} = /begin{bmatrix} x // /dot{x} /end{bmatrix}

其中/dot{x}是速度,也就是位置对于时间的导数。

我们假设在(k − 1)时刻与k时刻之间,车受到ak的加速度,其符合均值为0,标准差为σa正态分布。根据牛顿运动定律,我们可以推出

/textbf{x}_{k} = /textbf{F} /textbf{x}_{k-1} + /textbf{G}a_{k}

其中

/textbf{F} = /begin{bmatrix} 1 & /Delta t // 0 & 1 /end{bmatrix}

/textbf{G} = /begin{bmatrix} /frac{/Delta t^{2}}{2} // /Delta t /end{bmatrix}

我们可以发现

/textbf{Q} = /textrm{cov}(/textbf{G}a) = /textrm{E}[(/textbf{G}a)(/textbf{G}a)^{T}] = /textbf{G} /textrm{E}[a^2] /textbf{G}^{T} = /textbf{G}[/sigma_a^2]/textbf{G}^{T} = /sigma_a^2 /textbf{G}/textbf{G}^{T} (因为 σ a 是一个标量).

在每一时刻,我们对其位置进行测量,测量受到噪声干扰.我们假设噪声服从正态分布,均值为0,标准差为σz

/textbf{z}_{k} = /textbf{H x}_{k} + /textbf{v}_{k}

其中

/textbf{H} = /begin{bmatrix} 1 & 0 /end{bmatrix}

/textbf{R} = /textrm{E}[/textbf{v}_k /textbf{v}_k^{T}] = /begin{bmatrix} /sigma_z^2 /end{bmatrix}

如果我们知道足够精确的车最初的位置,那么我们可以初始化

/hat{/textbf{x}}_{0|0} = /begin{bmatrix} 0 // 0 /end{bmatrix}

并且,我们告诉滤波器我们知道确切的初始位置,我们给出一个协方差矩阵:

/textbf{P}_{0|0} = /begin{bmatrix} 0 & 0 // 0 & 0 /end{bmatrix}

如果我们不确切的知道最初的位置与速度,那么协方差矩阵可以初始化为一个对角线元素是B的矩阵,B取一个合适的比较大的数。

/textbf{P}_{0|0} = /begin{bmatrix} B & 0 // 0 & B /end{bmatrix}

此时,与使用模型中已有信息相比,滤波器更倾向于使用初次测量值的信息。

[编辑] 推导

[编辑] 推导后验协方差矩阵

按照上边的定义,我们从误差协方差Pk|k开始推导如下:

/textbf{P}_{k|k}  = /textrm{cov}(/textbf{x}_{k} - /hat{/textbf{x}}_{k|k})

代入/hat{/textbf{x}}_{k|k}

/textbf{P}_{k|k} = /textrm{cov}(/textbf{x}_{k} - (/hat{/textbf{x}}_{k|k-1} + /textbf{K}_k/tilde{/textbf{y}}_{k}))

再代入 /tilde{/textbf{y}}_k

/textbf{P}_{k|k} = /textrm{cov}(/textbf{x}_{k} - (/hat{/textbf{x}}_{k|k-1} + /textbf{K}_k(/textbf{z}_k - /textbf{H}_k/hat{/textbf{x}}_{k|k-1})))

/textbf{z}_{k}

/textbf{P}_{k|k} = /textrm{cov}(/textbf{x}_{k} - (/hat{/textbf{x}}_{k|k-1} + /textbf{K}_k(/textbf{H}_k/textbf{x}_k + /textbf{v}_k - /textbf{H}_k/hat{/textbf{x}}_{k|k-1})))

整理误差向量,得

/textbf{P}_{k|k} = /textrm{cov}((I - /textbf{K}_k /textbf{H}_{k})(/textbf{x}_k - /hat{/textbf{x}}_{k|k-1}) - /textbf{K}_k /textbf{v}_k )

因为测量误差vk 与其他项是非相关的,因此有

/textbf{P}_{k|k} = /textrm{cov}((I - /textbf{K}_k /textbf{H}_{k})(/textbf{x}_k - /hat{/textbf{x}}_{k|k-1}))  + /textrm{cov}(/textbf{K}_k /textbf{v}_k )

利用协方差矩阵的性质,此式可以写作

/textbf{P}_{k|k} = (I - /textbf{K}_k /textbf{H}_{k})/textrm{cov}(/textbf{x}_k - /hat{/textbf{x}}_{k|k-1})(I - /textbf{K}_k /textbf{H}_{k})^{T}  + /textbf{K}_k/textrm{cov}(/textbf{v}_k )/textbf{K}_k^{T}

使用不变量Pk|k-1以及Rk的定义 这一项可以写作 :/textbf{P}_{k|k} =  (I - /textbf{K}_k /textbf{H}_{k}) /textbf{P}_{k|k-1} (I - /textbf{K}_k /textbf{H}_{k})^T + /textbf{K}_k /textbf{R}_k /textbf{K}_k^T 这一公式对于任何卡尔曼增益Kk都成立。如果Kk是最优卡尔曼增益,则可以进一步简化,请见下文。


[编辑] 最优卡尔曼增益的推导

卡尔曼滤波器是一个最小均方误差估计器,后验状态误差估计(英文:posteriori state estimate)是

/textbf{x}_{k} - /hat{/textbf{x}}_{k|k}

我们最小化这个矢量幅度平方的期望值,/textrm{E}[|/textbf{x}_{k} - /hat{/textbf{x}}_{k|k}|^2],这等同于最小化后验估计协方差矩阵 Pk|k迹(trace)。将上面方程中的项展开、抵消,得到:

/textbf{P}_{k|k}= /textbf{P}_{k|k-1} - /textbf{K}_k /textbf{H}_k /textbf{P}_{k|k-1} - /textbf{P}_{k|k-1} /textbf{H}_k^T /textbf{K}_k^T + /textbf{K}_k (/textbf{H}_k /textbf{P}_{k|k-1} /textbf{H}_k^T + /textbf{R}_k) /textbf{K}_k^T

= /textbf{P}_{k|k-1} - /textbf{K}_k /textbf{H}_k /textbf{P}_{k|k-1} - /textbf{P}_{k|k-1} /textbf{H}_k^T /textbf{K}_k^T + /textbf{K}_k /textbf{S}_k/textbf{K}_k^T

矩阵导数是 0 的时候得到迹(trace)的最小值:

/frac{d /; /textrm{tr}(/textbf{P}_{k|k})}{d /;/textbf{K}_k} = -2 (/textbf{H}_k /textbf{P}_{k|k-1})^T + 2 /textbf{K}_k /textbf{S}_k  = 0

从这个方程解出卡尔曼增益Kk

/textbf{K}_k /textbf{S}_k = (/textbf{H}_k /textbf{P}_{k|k-1})^T = /textbf{P}_{k|k-1} /textbf{H}_k^T
/textbf{K}_{k} = /textbf{P}_{k|k-1} /textbf{H}_k^T /textbf{S}_k^{-1}

这个增益称为最优卡尔曼增益,在使用时得到最小均方误差

[编辑] 后验误差协方差公式的化简

在卡尔曼增益等于上面导出的最优值时,计算后验协方差的公式可以进行简化。在卡尔曼增益公式两侧的右边都乘以 SkKkT 得到

/textbf{K}_k /textbf{S}_k /textbf{K}_k^T = /textbf{P}_{k|k-1} /textbf{H}_k^T /textbf{K}_k^T

根据上面后验误差协方差展开公式,

/textbf{P}_{k|k} = /textbf{P}_{k|k-1} - /textbf{K}_k /textbf{H}_k /textbf{P}_{k|k-1}  - /textbf{P}_{k|k-1} /textbf{H}_k^T /textbf{K}_k^T + /textbf{K}_k /textbf{S}_k /textbf{K}_k^T

最后两项可以抵消,得到

/textbf{P}_{k|k} = /textbf{P}_{k|k-1} - /textbf{K}_k /textbf{H}_k /textbf{P}_{k|k-1} = (I - /textbf{K}_{k} /textbf{H}_{k}) /textbf{P}_{k|k-1}.

这个公式的计算比较简单,所以实际中总是使用这个公式,但是需注意这公式仅在使用最优卡尔曼增益的时候它才成立。如果算术精度总是很低而导致numerical stability出现问题,或者特意使用非最优卡尔曼增益,那么就不能使用这个简化;必须使用上面导出的后验误差协方差公式。

[编辑] 与递归Bayesian估计之间的关系

假设真正的状态是无法观察的马尔科夫过程,测量结果是从隐性马尔科夫模型观察到的状态。

Image:HMMKalmanFilterDerivation.png

根据马尔科夫假设,真正的状态仅受最近一个状态影响而与其它以前状态无关。

p(/textbf{x}_k|/textbf{x}_0,/dots,/textbf{x}_{k-1}) = p(/textbf{x}_k|/textbf{x}_{k-1})

与此类似,在时刻 k 测量只与当前状态有关而与其它状态无关。

p(/textbf{z}_k|/textbf{x}_0,/dots,/textbf{x}_{k}) = p(/textbf{z}_k|/textbf{x}_{k} )

根据这些假设,隐性马尔科夫模型所有状态的概率分布可以简化为:

p(/textbf{x}_0,/dots,/textbf{x}_k,/textbf{z}_1,/dots,/textbf{z}_k) = p(/textbf{x}_0)/prod_{i=1}^k p(/textbf{z}_i|/textbf{x}_i)p(/textbf{x}_i|/textbf{x}_{i-1})

However, when the Kalman filter is used to estimate the state x, the probability distribution of interest is that associated with the current states conditioned on the measurements up to the current timestep. (This is achieved by marginalizing out the previous states and dividing by the probability of the measurement set.) 但是,当卡尔曼滤波器用来估计状态x的时候,

This leads to the predict and update steps of the Kalman filter written probabilistically. The probability distribution associated with the predicted state is product of the probability distribution associated with the transition from the (k − 1)th timestep to the kth and the probability distribution associated with the previous state, with the true state at (k − 1) integrated out.

p(/textbf{x}_k|/textbf{Z}_{k-1}) = /int p(/textbf{x}_k | /textbf{x}_{k-1}) p(/textbf{x}_{k-1} | /textbf{Z}_{k-1} )  /, d/textbf{x}_{k-1}

The measurement set up to time t is

/textbf{Z}_{t} = /left /{ /textbf{z}_{1},/dots,/textbf{z}_{t} /right /}

The probability distribution of updated is proportional to the product of the measurement likelihood and the predicted state.

p(/textbf{x}_k|/textbf{Z}_{k}) = /frac{p(/textbf{z}_k|/textbf{x}_k) p(/textbf{x}_k|/textbf{Z}_{k-1})}{p(/textbf{z}_k|/textbf{Z}_{k-1})}

The denominator

p(/textbf{z}_k|/textbf{Z}_{k-1}) = /int p(/textbf{z}_k|/textbf{x}_k) p(/textbf{x}_k|/textbf{Z}_{k-1}) d/textbf{x}_k

is an unimportant normalization term.

The remaining probability density functions are

p(/textbf{x}_k | /textbf{x}_{k-1}) = N(/textbf{x}_k, /textbf{F}_k/textbf{x}_{k-1}, /textbf{Q}_k)
p(/textbf{z}_k|/textbf{x}_k) = N(/textbf{z}_k,/textbf{H}_{k}/textbf{x}_k, /textbf{R}_k)
p(/textbf{x}_{k-1}|/textbf{Z}_{k-1}) = N(/textbf{x}_{k-1},/hat{/textbf{x}}_{k-1},/textbf{P}_{k-1} )

Note that the PDF at the previous timestep is inductively assumed to be the estimated state and covariance. This is justified because, as an optimal estimator, the Kalman filter makes best use of the measurements, therefore the PDF for /mathbf{x}_k given the measurements /mathbf{Z}_k is the Kalman filter estimate.

[编辑] 信息滤波器

In the information filter, or inverse covariance filter, the estimated covariance and estimated state are replaced by the information matrix and information vector respectively.

/textbf{Y}_{k|k} /equiv  /textbf{P}_{k|k}^{-1}
/hat{/textbf{y}}_{k|k} /equiv  /textbf{P}_{k|k}^{-1}/hat{/textbf{x}}_{k|k}

Similarly the predicted covariance and state have equivalent information forms,

/textbf{Y}_{k|k-1} /equiv  /textbf{P}_{k|k-1}^{-1}
/hat{/textbf{y}}_{k|k-1} /equiv  /textbf{P}_{k|k-1}^{-1}/hat{/textbf{x}}_{k|k-1}

as have the measurement covariance and measurement vector.

/textbf{I}_{k} /equiv /textbf{H}_{k}^{T} /textbf{R}_{k}^{-1} /textbf{H}_{k}
/textbf{i}_{k} /equiv /textbf{H}_{k}^{T} /textbf{R}_{k}^{-1} /textbf{z}_{k}

The information update now becomes a trivial sum.

/textbf{Y}_{k|k} = /textbf{Y}_{k|k-1} + /textbf{I}_{k}
/hat{/textbf{y}}_{k|k} = /hat{/textbf{y}}_{k|k-1} + /textbf{i}_{k}

The main advantage of the information filter is that N measurements can be filtered at each timestep simply by summing their information matrices and vectors.

/textbf{Y}_{k|k} = /textbf{Y}_{k|k-1} + /sum_{j=1}^N /textbf{I}_{k,j}
/hat{/textbf{y}}_{k|k} = /hat{/textbf{y}}_{k|k-1} + /sum_{j=1}^N /textbf{i}_{k,j}

To predict the information filter the information matrix and vector can be converted back to their state space equivalents, or alternatively the information space prediction can be used.

/textbf{M}_{k} = [/textbf{F}_{k}^{-1}]^{T} /textbf{Y}_{k|k} /textbf{F}_{k}^{-1}
/textbf{C}_{k} = /textbf{M}_{k} [/textbf{M}_{k}+/textbf{Q}_{k}^{-1}]^{-1}
/textbf{L}_{k} = I - /textbf{C}_{k}
/textbf{Y}_{k|k-1} = /textbf{L}_{k} /textbf{M}_{k} /textbf{L}_{k}^{T} +                                    /textbf{C}_{k} /textbf{Q}_{k}^{-1} /textbf{C}_{k}^{T}
/hat{/textbf{y}}_{k|k-1} = /textbf{L}_{k} [/textbf{F}_{k}^{-1}]^{T}/hat{/textbf{y}}_{k|k}

Note that if F and Q are time invariant these values can be cached. Note also that F and Q need to be invertible.

[编辑] 非线性滤波器

基本卡尔曼滤波器(The basic Kalman filter)是限制在线性的假设之下。然而,大部份非平凡的(non-trial)的系统都是非线性系统。其中的“非线性性质”(non- linearity )可能是伴随存在过程模型(process model)中或观测模型(observation model)中,或者两者兼有之。

[编辑] 扩展卡尔曼滤波器

在扩展卡尔曼滤波器(EKF)中状态转换和观测模型不需要是状态的线性函数,可替换为(可微的)函数。

/textbf{x}_{k} = f(/textbf{x}_{k-1}, /textbf{u}_{k}, /textbf{w}_{k})
/textbf{z}_{k} = h(/textbf{x}_{k}, /textbf{v}_{k})

函数 f 可以用来从过去的估计值中计算预测的状态,相似的,函数 h可以用来以预测的状态计算预测的测量值。然而 fh 不能直接的应用在协方差中,取而代之的是计算偏导矩阵(Jacobian)。

在每一步中使用当前的估计状态计算Jacobian矩阵,这几个矩阵可以用在卡尔曼滤波器的方程中。这个过程,实质上将非线性的函数在当前估计值处线性化了。

这样一来,卡尔曼滤波器的等式为:

预测

/hat{/textbf{x}}_{k|k-1} = f(/textbf{x}_{k-1}, /textbf{u}_{k}, 0)
/textbf{P}_{k|k-1} =  /textbf{F}_{k} /textbf{P}_{k-1|k-1} /textbf{F}_{k}^{T} + /textbf{Q}_{k}

使用Jacobians矩阵更新模型

/textbf{F}_{k} = /left . /frac{/partial f}{/partial /textbf{x} } /right /vert _{/hat{/textbf{x}}_{k-1|k-1},/textbf{u}_{k}}
/textbf{H}_{k} = /left . /frac{/partial h}{/partial /textbf{x} } /right /vert _{/hat{/textbf{x}}_{k|k-1}}

更新

/tilde{/textbf{y}}_{k} = /textbf{z}_{k} - h(/hat{/textbf{x}}_{k|k-1}, 0)
/textbf{S}_{k} = /textbf{H}_{k}/textbf{P}_{k|k-1}/textbf{H}_{k}^{T} + /textbf{R}_{k}
/textbf{K}_{k} = /textbf{P}_{k|k-1}/textbf{H}_{k}^{T}/textbf{S}_{k}^{-1}
/hat{/textbf{x}}_{k|k} = /hat{/textbf{x}}_{k|k-1} + /textbf{K}_{k}/tilde{/textbf{y}}_{k}
/textbf{P}_{k|k} = (I - /textbf{K}_{k} /textbf{H}_{k}) /textbf{P}_{k|k-1}

[编辑] Unscented Kalman filter

The extended Kalman filter gives particularly poor performance on highly non-linear functions because only the mean is propagated through the non-linearity. The unscented Kalman filter (UKF) [JU97] uses a deterministic sampling technique to pick a minimal set of sample points (called sigma points) around the mean. These sigma points are then propagated through the non-linear functions and the covariance of the estimate is then recovered. The result is a filter which more accurately captures the true mean and covariance. (This can be verified using Monte Carlo sampling or through a Taylor series expansion of the posterior statistics.) In addition, this technique removes the requirement to analytically calculate Jacobians, which for complex functions can be a difficult task in itself.

预测

如同扩展卡尔曼滤波器(EKF)一样, UKF的预测过程可以独立于UKF的更新过程之外,与一个线性的(或者确实是扩展卡尔曼滤波器的)更新过程合并来使用;或者,UKF的预测过程与更新过程在上述中地位互换亦可。

The estimated state and covariance are augmented with the mean and covariance of the process noise.

/textbf{x}_{k-1|k-1}^{a} = [ /hat{/textbf{x}}_{k-1|k-1}^{T} /quad E[/textbf{w}_{k}^{T}] / ]^{T}
/textbf{P}_{k-1|k-1}^{a} = /begin{bmatrix} & /textbf{P}_{k-1|k-1} & & 0 & // & 0 & &/textbf{Q}_{k} & /end{bmatrix}

A set of 2L+1 sigma points is derived from the augmented state and covariance where L is the dimension of the augmented state.

/chi_{k-1|k-1}^{0}= /textbf{x}_{k-1|k-1}^{a}
/chi_{k-1|k-1}^{i}=/textbf{x}_{k-1|k-1}^{a} + /left ( /sqrt{ (L + /lambda) /textbf{P}_{k-1|k-1}^{a} } /right )_{i}i = 1..L /,/!
/chi_{k-1|k-1}^{i}= /textbf{x}_{k-1|k-1}^{a} - /left ( /sqrt{ (L + /lambda) /textbf{P}_{k-1|k-1}^{a} } /right )_{i-L}i = L+1,/dots{}2L /,/!

The sigma points are propagated through the transition function f.

/chi_{k|k-1}^{i} = f(/chi_{k-1|k-1}^{i}) /quad i = 0..2L

The weighted sigma points are recombined to produce the predicted state and covariance.

/hat{/textbf{x}}_{k|k-1} = /sum_{i=1}^N W_{s}^{i} /chi_{k|k-1}^{i}
/textbf{P}_{k|k-1} = /sum_{i=1}^N W_{c}^{i}/ [/chi_{k|k-1}^{i} - /hat{/textbf{x}}_{k|k-1}] [/chi_{k|k-1}^{i} - /hat{/textbf{x}}_{k|k-1}]^{T}

Where the weights for the state and covariance are given are:

W_{s}^{0} = /frac{/lambda}{L+/lambda}
W_{c}^{0} = /frac{/lambda}{L+/lambda} + (1 - /alpha^2 + /beta)
W_{s}^{i} = W_{c}^{i} = /frac{1}{2(L+/lambda)}
/lambda = /alpha^2 (L+/kappa) - L /,/!

Typical values for α, β, and κ are 10 − 3, 2 and 0 respectively. (These values should suffice for most purposes.)

更新

The predicted state and covariance are augmented as before, except now with the mean and covariance of the measurement noise.

/textbf{x}_{k|k-1}^{a} = [ /hat{/textbf{x}}_{k|k-1}^{T} /quad E[/textbf{v}_{k}^{T}] / ]^{T}
/textbf{P}_{k|k-1}^{a} = /begin{bmatrix} & /textbf{P}_{k|k-1} & & 0 & // & 0 & &/textbf{R}_{k} & /end{bmatrix}

As before, a set of 2L + 1 sigma points is derived from the augmented state and covariance where L is the dimension of the augmented state.

/chi_{k|k-1}^{0}= /textbf{x}_{k|k-1}^{a}
/chi_{k|k-1}^{i}=/textbf{x}_{k|k-1}^{a} + /left ( /sqrt{ (L + /lambda) /textbf{P}_{k|k-1}^{a} } /right )_{i}i = 1..L /,/!
/chi_{k|k-1}^{i}= /textbf{x}_{k|k-1}^{a} - /left ( /sqrt{ (L + /lambda) /textbf{P}_{k|k-1}^{a} } /right )_{i-L}i = L+1,/dots{}2L /,/!

Alternatively if the UKF prediction has been used the sigma points themselves can be augmented along the following lines

/chi_{k|k-1} := [ /chi_{k|k-1} /quad E[/textbf{v}_{k}^{T}] / ]^{T} /pm /sqrt{ (L + /lambda) /textbf{R}_{k}^{a} }

where

/textbf{R}_{k}^{a} = /begin{bmatrix} & 0 & & 0 & // & 0 & &/textbf{R}_{k} & /end{bmatrix}

The sigma points are projected through the observation function h.

/gamma_{k}^{i} = h(/chi_{k|k-1}^{i}) /quad i = 0..2L

The weighted sigma points are recombined to produce the predicted measurement and predicted measurement covariance.

/hat{/textbf{z}}_{k} = /sum_{i=1}^N W_{s}^{i} /gamma_{k}^{i}
/textbf{P}_{z_{k}z_{k}} = /sum_{i=1}^N W_{c}^{i}/ [/gamma_{k}^{i} - /hat{/textbf{z}}_{k}] [/gamma_{k}^{i} - /hat{/textbf{z}}_{k}]^{T}

The state-measurement cross-correlation matrix,

/textbf{P}_{x_{k}z_{k}} = /sum_{i=1}^N W_{c}^{i}/ [/chi_{k|k-1}^{i} - /hat{/textbf{x}}_{k|k-1}] [/gamma_{k}^{i} - /hat{/textbf{z}}_{k}]^{T}

is used to compute the UKF Kalman gain.

K_{k} = /textbf{P}_{x_{k}z_{k}} /textbf{P}_{z_{k}z_{k}}^{-1}

As with the Kalman filter, the updated state is the predicted state plus the innovation weighted by the Kalman gain,

/hat{/textbf{x}}_{k|k} = /hat{/textbf{x}}_{k|k-1} + K_{k}( /textbf{z}_{k} - /hat{/textbf{z}}_{k} )

And the updated covariance is the predicted covariance, minus the predicted measurement covariance, weighted by the Kalman gain.

/textbf{P}_{k|k} = /textbf{P}_{k|k} - K_{k} /textbf{P}_{z_{k}z_{k}} K_{k}^{T}

[编辑] 应用

[编辑] 参见

[编辑] 外部连接

[编辑] 参考文献

  • Gelb A., editor. Applied optimal estimation. MIT Press, 1974.
  • Kalman, R. E. A New Approach to Linear Filtering and Prediction Problems, Transactions of the ASME - Journal of Basic Engineering Vol. 82: pp. 35-45 (1960)
  • Kalman, R. E., Bucy R. S., New Results in Linear Filtering and Prediction Theory, Transactions of the ASME - Journal of Basic Engineering Vol. 83: pp. 95-107 (1961)
  • [JU97] Julier, Simon J. and Jeffery K. Uhlmann. A New Extension of the Kalman Filter to nonlinear Systems. In The Proceedings of AeroSense: The 11th International Symposium on Aerospace/Defense Sensing,Simulation and Controls, Multi Sensor Fusion, Tracking and Resource Management II, SPIE, 1997.
  • Harvey, A.C. Forecasting, Structural Time Series Models and the Kalman Filter. Cambridge University Press, Cambridge, 1989 
  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值