当前位置:网站首页>扩展卡尔曼滤波EKF
扩展卡尔曼滤波EKF
2022-08-03 23:58:00 【威士忌燕麦拿铁】
扩展卡尔曼滤波EKF
如果将置信度和噪声限制为高斯分布,并且对运动模型和观测进行线性化,计算贝叶斯滤波中的积分(以及归一化积),即可得到扩展卡尔曼滤波(EKF)。
为了推导EKF,首先假设 x k \boldsymbol{x}_{k} xk 的置信度函数限制为高斯分布:
p ( x k ∣ x ˇ 0 , v 1 : k , y 0 : k ) = N ( x ^ k , P ^ k ) p\left(\boldsymbol{x}_{k} \mid \check{\boldsymbol{x}}_{0}, \boldsymbol{v}_{1: k}, \boldsymbol{y}_{0: k}\right)=\mathcal{N}\left(\hat{\boldsymbol{x}}_{k}, \hat{\boldsymbol{P}}_{k}\right) p(xk∣xˇ0,v1:k,y0:k)=N(x^k,P^k)
其中, x ^ k \hat{\boldsymbol{x}}_{k} x^k 为均值, P ^ k \hat{\boldsymbol{P}}_{k} P^k 为协方差。
并且假设噪声变量 w k \boldsymbol{w}_{k} wk 和 n k \boldsymbol{n}_{k} nk 也是高斯分布的:
w k ∼ N ( 0 , Q k ) n k ∼ N ( 0 , R k ) \begin{array}{l}\boldsymbol{w}_{k} \sim \mathcal{N}\left(\mathbf{0}, \boldsymbol{Q}_{k}\right) \\\boldsymbol{n}_{k} \sim \mathcal{N}\left(\mathbf{0}, \boldsymbol{R}_{k}\right)\end{array} wk∼N(0,Qk)nk∼N(0,Rk)
对于以下运动和观测模型:
x k = f ( x k − 1 , v k , w k ) y k = g ( x k , n k ) \begin{aligned}&\boldsymbol{x}_{k}=f\left(\boldsymbol{x}_{k-1}, \boldsymbol{v}_{k},\boldsymbol{w}_{k}\right) \\&\boldsymbol{y}_{k}=g\left(\boldsymbol{x}_{k}, \boldsymbol{n}_{k}\right)\end{aligned} xk=f(xk−1,vk,wk)yk=g(xk,nk)
由于 f ( ⋅ ) \boldsymbol{f}(\cdot) f(⋅) 和 g ( ⋅ ) \boldsymbol{g}(\cdot) g(⋅) 是非线性函数,所以我们需要对其进行线性化。在当前状态的均值处展开,对运动和观测模型进行线性化:
f ( x k − 1 , v k , w k ) ≈ x ˇ k + F k − 1 ( x k − 1 − x ^ k − 1 ) + w k ′ \boldsymbol{f}\left(\boldsymbol{x}_{k-1}, \boldsymbol{v}_{k}, \boldsymbol{w}_{k}\right) \approx \check{\boldsymbol{x}}_{k}+\boldsymbol{F}_{k-1}\left(\boldsymbol{x}_{k-1}-\hat{\boldsymbol{x}}_{k-1}\right)+\boldsymbol{w}_{k}^{\prime} f(xk−1,vk,wk)≈xˇk+Fk−1(xk−1−x^k−1)+wk′
g ( x k , n k ) ≈ y ˇ k + G k ( x k − x ˇ k ) + n k ′ \boldsymbol{g}\left(\boldsymbol{x}_{k}, \boldsymbol{n}_{k}\right) \approx \check{\boldsymbol{y}}_{k}+\boldsymbol{G}_{k}\left(\boldsymbol{x}_{k}-\check{\boldsymbol{x}}_{k}\right)+\boldsymbol{n}_{k}^{\prime} g(xk,nk)≈yˇk+Gk(xk−xˇk)+nk′
其中:
- x ˇ k = f ( x ^ k − 1 , v k , 0 ) \check{\boldsymbol{x}}_{k}=\boldsymbol{f}\left(\hat{\boldsymbol{x}}_{k-1}, \boldsymbol{v}_{k}, \mathbf{0}\right) xˇk=f(x^k−1,vk,0)
- F k − 1 = ∂ f ( x k − 1 , v k , w k ) ∂ x k − 1 ∣ x ^ k − 1 , v k , 0 \boldsymbol{F}_{k-1}=\left.\frac{\partial \boldsymbol{f}\left(\boldsymbol{x}_{k-1}, \boldsymbol{v}_{k}, \boldsymbol{w}_{k}\right)}{\partial \boldsymbol{x}_{k-1}}\right|_{\hat{\boldsymbol{x}}_{k-1}, \boldsymbol{v}_{k}, \mathbf{0}} Fk−1=∂xk−1∂f(xk−1,vk,wk)∣∣x^k−1,vk,0
- w k ′ = ∂ f ( x k − 1 , v k , w k ) ∂ w k ∣ x ^ k − 1 , v k , 0 w k \boldsymbol{w}_{k}^{\prime}=\left.\frac{\partial \boldsymbol{f}\left(\boldsymbol{x}_{k-1}, \boldsymbol{v}_{k}, \boldsymbol{w}_{k}\right)}{\partial \boldsymbol{w}_{k}}\right|_{\hat{\boldsymbol{x}}_{k-1}, \boldsymbol{v}_{k}, \mathbf{0}} \boldsymbol{w}_{k} wk′=∂wk∂f(xk−1,vk,wk)∣∣x^k−1,vk,0wk
- y ˇ k = g ( x ˇ k , 0 ) \check{\boldsymbol{y}}_{k}=\boldsymbol{g}\left(\check{\boldsymbol{x}}_{k}, \mathbf{0}\right) yˇk=g(xˇk,0)
- G k = ∂ g ( x k , n k ) ∂ x k ∣ x ˇ k , 0 \boldsymbol{G}_{k}=\left.\frac{\partial \boldsymbol{g}\left(\boldsymbol{x}_{k}, \boldsymbol{n}_{k}\right)}{\partial \boldsymbol{x}_{k}}\right|_{\check{\boldsymbol{x}}_{k}, \mathbf{0}} Gk=∂xk∂g(xk,nk)∣∣xˇk,0
- n k ′ = ∂ g ( x k , n k ) ∂ n k ∣ x ˇ k , 0 n k \boldsymbol{n}_{k}^{\prime}=\left.\frac{\partial \boldsymbol{g}\left(\boldsymbol{x}_{k}, \boldsymbol{n}_{k}\right)}{\partial \boldsymbol{n}_{k}}\right|_{\check{\boldsymbol{x}}_{k}, \mathbf{0}} \boldsymbol{n}_{k} nk′=∂nk∂g(xk,nk)∣∣xˇk,0nk
给定过去的状态和最新输入,则当前状态 x k \boldsymbol{x}_{k} xk 的统计学特性为:
x k ≈ x ˇ k + F k − 1 ( x k − 1 − x ^ k − 1 ) + w k ′ \boldsymbol{x}_{k} \approx \check{\boldsymbol{x}}_{k}+\boldsymbol{F}_{k-1}\left(\boldsymbol{x}_{k-1}-\hat{\boldsymbol{x}}_{k-1}\right)+\boldsymbol{w}_{k}^{\prime} xk≈xˇk+Fk−1(xk−1−x^k−1)+wk′
E [ x k ] ≈ x ˇ k + F k − 1 ( x k − 1 − x ^ k − 1 ) + E [ w k ′ ] ⏟ 0 E\left[\boldsymbol{x}_{k}\right] \approx \check{\boldsymbol{x}}_{k}+\boldsymbol{F}_{k-1}\left(\boldsymbol{x}_{k-1}-\hat{\boldsymbol{x}}_{k-1}\right)+\underbrace{E\left[\boldsymbol{w}_{k}^{\prime}\right]}_{0} E[xk]≈xˇk+Fk−1(xk−1−x^k−1)+0E[wk′]
E [ ( x k − E [ x k ] ) ( x k − E [ x k ] ) T ] ≈ E [ w k ′ w k ′ T ] ⏟ Q k ′ E\left[\left(\boldsymbol{x}_{k}-E\left[\boldsymbol{x}_{k}\right]\right)\left(\boldsymbol{x}_{k}-E\left[\boldsymbol{x}_{k}\right]\right)^{\mathrm{T}}\right] \approx \underbrace{E\left[\boldsymbol{w}_{k}^{\prime} \boldsymbol{w}_{k}^{\left.\prime^{\mathrm{T}}\right]}\right.}_{\boldsymbol{Q}_{k}^{\prime}} E[(xk−E[xk])(xk−E[xk])T]≈Qk′E[wk′wk′T]
p ( x k ∣ x k − 1 , v k ) ≈ N ( x ˇ k + F k − 1 ( x k − 1 − x ^ k − 1 ) , Q k ′ ) p\left(\boldsymbol{x}_{k} \mid \boldsymbol{x}_{k-1}, \boldsymbol{v}_{k}\right) \approx \mathcal{N}\left(\check{\boldsymbol{x}}_{k}+\boldsymbol{F}_{k-1}\left(\boldsymbol{x}_{k-1}-\hat{\boldsymbol{x}}_{k-1}\right), \boldsymbol{Q}_{k}^{\prime}\right) p(xk∣xk−1,vk)≈N(xˇk+Fk−1(xk−1−x^k−1),Qk′)
给定当前状态,则当前观测 y ˇ k \check{\boldsymbol{y}}_{k} yˇk 的统计学特性为:
y k ≈ y ˇ k + G k ( x k − x ˇ k ) + n k ′ \boldsymbol{y}_{k} \approx \check{\boldsymbol{y}}_{k}+\boldsymbol{G}_{k}\left(\boldsymbol{x}_{k}-\check{\boldsymbol{x}}_{k}\right)+\boldsymbol{n}_{k}^{\prime} yk≈yˇk+Gk(xk−xˇk)+nk′
E [ y k ] ≈ y ˇ k + G k ( x k − x ˇ k ) + E [ n k ′ ] ⏟ 0 E\left[\boldsymbol{y}_{k}\right] \approx \check{\boldsymbol{y}}_{k}+\boldsymbol{G}_{k}\left(\boldsymbol{x}_{k}-\check{\boldsymbol{x}}_{k}\right)+\underbrace{E\left[\boldsymbol{n}_{k}^{\prime}\right]}_{0} E[yk]≈yˇk+Gk(xk−xˇk)+0E[nk′]
E [ ( y k − E [ y k ] ) ( y k − E [ y k ] ) T ] ≈ E [ n k ′ n k ′ T ] ⏟ R k ′ E\left[\left(\boldsymbol{y}_{k}-E\left[\boldsymbol{y}_{k}\right]\right)\left(\boldsymbol{y}_{k}-E\left[\boldsymbol{y}_{k}\right]\right)^{\mathrm{T}}\right] \approx \underbrace{E\left[\boldsymbol{n}_{k}^{\prime} \boldsymbol{n}_{k}^{\prime \mathrm{T}}\right]}_{\boldsymbol{R}_{k}^{\prime}} E[(yk−E[yk])(yk−E[yk])T]≈Rk′E[nk′nk′T]
p ( y k ∣ x k ) ≈ N ( y ˇ k + G k ( x k − x ˇ k ) , R k ′ ) p\left(\boldsymbol{y}_{k} \mid \boldsymbol{x}_{k}\right) \approx \mathcal{N}\left(\check{\boldsymbol{y}}_{k}+\boldsymbol{G}_{k}\left(\boldsymbol{x}_{k}-\check{\boldsymbol{x}}_{k}\right), \boldsymbol{R}_{k}^{\prime}\right) p(yk∣xk)≈N(yˇk+Gk(xk−xˇk),Rk′)
由贝叶斯滤波器有:
p ( x k ∣ x ˇ 0 , v 1 : k , y 0 : k ) ⏟ 后验置信度 = η p ( y k ∣ x k ) ⏟ 利用 g ( ⋅ ) 进行更新 ∫ p ( x k ∣ x k − 1 , v k ) ⏟ 利用 f ( ⋅ ) 进行预测 p ( x k − 1 ∣ x ˇ 0 , v 1 : k − 1 , y 0 : k − 1 ) ⏟ 先验置信度 d x k − 1 \begin{aligned}& \underbrace{p\left(\boldsymbol{x}_{k} \mid \check{\boldsymbol{x}}_{0}, \boldsymbol{v}_{1: k}, \boldsymbol{y}_{0: k}\right)}_{\text {后验置信度 }} \\=& \eta \underbrace{p\left(\boldsymbol{y}_{k} \mid \boldsymbol{x}_{k}\right)}_{\text {利用 } \boldsymbol{g}(\cdot) \text { 进行更新 }} \int \underbrace{p\left(\boldsymbol{x}_{k} \mid \boldsymbol{x}_{k-1}, \boldsymbol{v}_{k}\right)}_{\text {利用 } \boldsymbol{f}(\cdot) \text { 进行预测 }} \underbrace{p\left(\boldsymbol{x}_{k-1} \mid \check{\boldsymbol{x}}_{0}, \boldsymbol{v}_{1: k-1}, \boldsymbol{y}_{0: k-1}\right)}_{\text {先验置信度 }} \mathrm{d} \boldsymbol{x}_{k-1}\end{aligned} =后验置信度 p(xk∣xˇ0,v1:k,y0:k)η利用 g(⋅) 进行更新 p(yk∣xk)∫利用 f(⋅) 进行预测 p(xk∣xk−1,vk)先验置信度 p(xk−1∣xˇ0,v1:k−1,y0:k−1)dxk−1
将线性化之后的运动和观测模型代入到贝叶斯滤波器中,有:
p ( x k ∣ x ˇ 0 , v 1 : k , y 0 : k ) ⏟ N ( x ^ k , P ^ k ) = η p ( y k ∣ x k ) ⏟ N ( y ˇ k + G k ( x k − x ˇ k ) , R k ′ ) × ∫ p ( x k ∣ x k − 1 , v k ) ⏟ N ( x ˇ k + F k − 1 ( x k − 1 − x ^ k − 1 ) , Q k ′ ) p ( x k − 1 ∣ x ˇ 0 , v 1 : k − 1 , y 0 : k − 1 ) ⏟ N ( x ^ k − 1 , P ^ k − 1 ) d x k − 1 \begin{array}{l}\underbrace{p\left(\boldsymbol{x}_{k} \mid \check{\boldsymbol{x}}_{0}, \boldsymbol{v}_{1: k}, \boldsymbol{y}_{0: k}\right)}_{\mathcal{N}\left(\hat{\boldsymbol{x}}_{k}, \hat{\boldsymbol{P}}_{k}\right)}=\eta \underbrace{p\left(\boldsymbol{y}_{k} \mid \boldsymbol{x}_{k}\right)}_{\mathcal{N}\left(\check{\boldsymbol{y}}_{k}+\boldsymbol{G}_{k}\left(\boldsymbol{x}_{k}-\check{\boldsymbol{x}}_{k}\right), \boldsymbol{R}_{k}^{\prime}\right)}\\\times \int \underbrace{p\left(\boldsymbol{x}_{k} \mid \boldsymbol{x}_{k-1}, \boldsymbol{v}_{k}\right)}_{\mathcal{N}\left(\check{\boldsymbol{x}}_{k}+\boldsymbol{F}_{k-1}\left(\boldsymbol{x}_{k-1}-\hat{\boldsymbol{x}}_{k-1}\right), \boldsymbol{Q}_{k}^{\prime}\right)} \underbrace{p\left(\boldsymbol{x}_{k-1} \mid \check{\boldsymbol{x}}_{0}, \boldsymbol{v}_{1: k-1}, \boldsymbol{y}_{0: k-1}\right)}_{\mathcal{N}\left(\hat{\boldsymbol{x}}_{k-1}, \hat{\boldsymbol{P}}_{k-1}\right)} \mathrm{d} \boldsymbol{x}_{k-1}\end{array} N(x^k,P^k)p(xk∣xˇ0,v1:k,y0:k)=ηN(yˇk+Gk(xk−xˇk),Rk′)p(yk∣xk)×∫N(xˇk+Fk−1(xk−1−x^k−1),Qk′)p(xk∣xk−1,vk)N(x^k−1,P^k−1)p(xk−1∣xˇ0,v1:k−1,y0:k−1)dxk−1
将服从高斯分布的变量传入到非线性函数中,积分之后仍然服从高斯分布:
p ( x k ∣ x ˇ 0 , v 1 : k , y 0 : k ) ⏟ N ( x ^ k , P ^ k ) = η p ( y k ∣ x k ) ⏟ N ( y ˇ k + G k ( x k − x ˇ k ) , R k ′ ) × ∫ p ( x k ∣ x k − 1 , v k ) p ( x k − 1 ∣ x ˇ 0 , v 1 : k − 1 , y 0 : k − 1 ) d x k − 1 ⏟ N ( x ˇ k , F k − 1 P ^ k − 1 F k − 1 T + Q k ′ ) \begin{array}{l}\underbrace{p\left(\boldsymbol{x}_{k} \mid \check{\boldsymbol{x}}_{0}, \boldsymbol{v}_{1: k}, \boldsymbol{y}_{0: k}\right)}_{\mathcal{N}\left(\hat{\boldsymbol{x}}_{k}, \hat{\boldsymbol{P}}_{k}\right)}=\eta \underbrace{p\left(\boldsymbol{y}_{k} \mid \boldsymbol{x}_{k}\right)}_{\mathcal{N}\left(\check{\boldsymbol{y}}_{k}+\boldsymbol{G}_{k}\left(\boldsymbol{x}_{k}-\check{\boldsymbol{x}}_{k}\right), \boldsymbol{R}_{k}^{\prime}\right)} \\\times \underbrace{\int p\left(\boldsymbol{x}_{k} \mid \boldsymbol{x}_{k-1}, \boldsymbol{v}_{k}\right) p\left(\boldsymbol{x}_{k-1} \mid \check{\boldsymbol{x}}_{0}, \boldsymbol{v}_{1: k-1}, \boldsymbol{y}_{0: k-1}\right) \mathrm{d} \boldsymbol{x}_{k-1}}_{\mathcal{N}\left(\check{\boldsymbol{x}}_{k}, \boldsymbol{F}_{k-1} \hat{\boldsymbol{P}}_{k-1} \boldsymbol{F}_{k-1}^{\mathrm{T}}+\boldsymbol{Q}_{k}^{\prime}\right)}\end{array} N(x^k,P^k)p(xk∣xˇ0,v1:k,y0:k)=ηN(yˇk+Gk(xk−xˇk),Rk′)p(yk∣xk)×N(xˇk,Fk−1P^k−1Fk−1T+Qk′)∫p(xk∣xk−1,vk)p(xk−1∣xˇ0,v1:k−1,y0:k−1)dxk−1
再利用高斯概率密度函数的归一化积的性质,有:
p ( x k ∣ x ˇ 0 , v 1 : k , y 0 : k ) ⏟ N ( x ^ k , P ^ k ) = η p ( y k ∣ x k ) ∫ p ( x k ∣ x k − 1 , v k ) p ( x k − 1 ∣ x ˇ 0 , v 1 : k − 1 , y 0 : k − 1 ) d x k − 1 ⏟ N ( x ˇ k + K k ( y k − y ˇ k ) , ( 1 − K k G k ) ( F k − 1 P ^ k − 1 F k − 1 T + Q k ′ ) ) \begin{aligned}\underbrace{p\left(\boldsymbol{x}_{k} \mid \check{\boldsymbol{x}}_{0}, \boldsymbol{v}_{1: k}, \boldsymbol{y}_{0: k}\right)}_{\mathcal{N}\left(\hat{\boldsymbol{x}}_{k}, \hat{\boldsymbol{P}}_{k}\right)} =& \underbrace{\eta p\left(\boldsymbol{y}_{k} \mid \boldsymbol{x}_{k}\right) \int p\left(\boldsymbol{x}_{k} \mid \boldsymbol{x}_{k-1}, \boldsymbol{v}_{k}\right) p\left(\boldsymbol{x}_{k-1} \mid \check{\boldsymbol{x}}_{0}, \boldsymbol{v}_{1: k-1}, \boldsymbol{y}_{0: k-1}\right) \mathrm{d} \boldsymbol{x}_{k-1}}_{\mathcal{N}\left(\check{\boldsymbol{x}}_{k}+\boldsymbol{K}_{k}\left(\boldsymbol{y}_{k}-\check{\boldsymbol{y}}_{k}\right),\left(\mathbf{1}-\boldsymbol{K}_{k} \boldsymbol{G}_{k}\right)\left(\boldsymbol{F}_{k-1} \hat{\boldsymbol{P}}_{k-1} \boldsymbol{F}_{k-1}^{\mathrm{T}}+\boldsymbol{Q}_{k}^{\prime}\right)\right)}\end{aligned} N(x^k,P^k)p(xk∣xˇ0,v1:k,y0:k)=N(xˇk+Kk(yk−yˇk),(1−KkGk)(Fk−1P^k−1Fk−1T+Qk′))ηp(yk∣xk)∫p(xk∣xk−1,vk)p(xk−1∣xˇ0,v1:k−1,y0:k−1)dxk−1
其中, K k \boldsymbol{K}_{k} Kk 为卡尔曼增益。比较上面式子的左右两侧,有:
预测
x ˇ k = f ( x ^ k − 1 , v k , 0 ) \check{\boldsymbol{x}}_{k} =\boldsymbol{f}\left(\hat{\boldsymbol{x}}_{k-1}, \boldsymbol{v}_{k}, \mathbf{0}\right) xˇk=f(x^k−1,vk,0)
P ˇ k = F k − 1 P ^ k − 1 F k − 1 T + Q k ′ \check{\boldsymbol{P}}_{k} =\boldsymbol{F}_{k-1} \hat{\boldsymbol{P}}_{k-1} \boldsymbol{F}_{k-1}^{\mathrm{T}}+\boldsymbol{Q}_{k}^{\prime} Pˇk=Fk−1P^k−1Fk−1T+Qk′
卡尔曼增益
K k = P ˇ k G k T ( G k P ˇ k G k T + R k ′ ) − 1 \boldsymbol{K}_{k} =\check{\boldsymbol{P}}_{k} \boldsymbol{G}_{k}^{\mathrm{T}}\left(\boldsymbol{G}_{k} \check{\boldsymbol{P}}_{k} \boldsymbol{G}_{k}^{\mathrm{T}}+\boldsymbol{R}_{k}^{\prime}\right)^{-1} Kk=PˇkGkT(GkPˇkGkT+Rk′)−1
更新
x ^ k = x ˇ k + K k ( y k − g ( x ˇ k , 0 ) ) ⏟ 更新量 \hat{\boldsymbol{x}}_{k} =\check{\boldsymbol{x}}_{k}+\boldsymbol{K}_{k} \underbrace{\left(\boldsymbol{y}_{k}-\boldsymbol{g}\left(\check{\boldsymbol{x}}_{k}, \mathbf{0}\right)\right)}_{\text {更新量 }} x^k=xˇk+Kk更新量 (yk−g(xˇk,0))
P ^ k = ( 1 − K k G k ) P ˇ k \hat{\boldsymbol{P}}_{k} =\left(\mathbf{1}-\boldsymbol{K}_{k} \boldsymbol{G}_{k}\right) \check{\boldsymbol{P}}_{k} P^k=(1−KkGk)Pˇk
边栏推荐
猜你喜欢
随机推荐
Scala basics [regular expressions, framework development principles]
corn表达式 具体详解与案例
绕任意轴旋转矩阵推导
Unity intercepts 3D images and the implementation of picture-in-picture PIP
Super perfect version of the layout have shortcut, background replacement (solve the problem of opencv Chinese path)
2022-08-03:以下go语言代码输出什么?A:2;B:3;C:1;D:0。 package main import “fmt“ func main() { slice := []i
It will invest about 200 billion US dollars in the United States in 20 years, and Samsung Electronics looks so handsome
用栈实现队列
小身材有大作用——光模块寿命分析(二)
libnet
XSLT – 编辑 XML概述
【MySQL —— 索引】
2022/8/3 Exam Summary
SolidEdge ST8安装教程
【LeetCode】最长公共子序列(动态规划)
现货白银需要注意八大事项
响应式织梦模板塑身瑜伽类网站
使用unbound在RHEL7上搭建DNS服务
[Miscellaneous] How to install the specified font into the computer and then use the font in the Office software?
【并发编程】ReentrantLock的lockInterruptibly()方法源码分析