参考:《Quaternion kinematics for error-state kalman filter》
1. 三种状态
- true-state
真实状态值,包含高斯噪声,用于EKF作为状态变量使用 - nominal-state
- 无(不考虑)噪声的状态值,可以是估计值(不考虑噪声)、预测值(不考虑噪声)
- 在预测阶段,由高频的IMU测量值预测得到当前的nominal-state x \mathbf x x,nominal state没有考虑噪声项,因此会存在累计误差,这些误差被堆积到error-state δ x \mathbf{\delta x} δx中,
- error-state
- 误差状态,符合零均值高斯分布,用于ESKF
true-state = nominal-state + error-state - ESKF中dynamic, control, measurement matrices由nominal-state计算得到
- 误差状态,符合零均值高斯分布,用于ESKF
2. 连续时间的系统运动学(System kinematics in continuous time)
- The true-state kinematics
p ˙ t = v t v ˙ t = R t ( a m − a b t − a n ) + g t q ˙ t = 1 2 q t ⊗ ( ω m − ω b t − ω n ) a ˙ b t = a w ω ˙ b t = ω w g ˙ t = 0 \begin{aligned} \dot{\mathbf{p}}_{t} &=\mathbf{v}_{t} \\ \dot{\mathbf{v}}_{t} &=\mathbf{R}_{t}\left(\mathbf{a}_{m}-\mathbf{a}_{b t}-\mathbf{a}_{n}\right)+\mathbf{g}_{t} \\ \dot{\mathbf{q}}_{t} &=\frac{1}{2} \mathbf{q}_{t} \otimes\left(\boldsymbol{\omega}_{m}-\boldsymbol{\omega}_{b t}-\boldsymbol{\omega}_{n}\right) \\ \dot{\mathbf{a}}_{b t} &=\mathbf{a}_{w} \\ \dot{\boldsymbol{\omega}}_{b t} &=\boldsymbol{\omega}_{w} \\ \dot{\mathbf{g}}_{t} &=0 \end{aligned} p˙tv˙tq˙ta˙btω˙btg˙t=vt=Rt(am−abt−an)+gt=21qt⊗(ωm−ωbt−ωn)=aw=ωw=0 - The nominal-state kinematics
p ˙ = v v ˙ = R ( a m − a b ) + g q ˙ = 1 2 q ⊗ ( ω m − ω b ) a ˙ b = 0 ω ˙ b = 0 g ˙ = 0 \begin{aligned} \dot{\mathbf{p}} &=\mathbf{v} \\ \dot{\mathbf{v}} &=\mathbf{R}\left(\mathbf{a}_{m}-\mathbf{a}_{b}\right)+\mathbf{g} \\ \dot{\mathbf{q}} &=\frac{1}{2} \mathbf{q} \otimes\left(\boldsymbol{\omega}_{m}-\boldsymbol{\omega}_{b}\right) \\ \dot{\mathbf{a}}_{b} &=0 \\ \dot{\boldsymbol{\omega}}_{b} &=0 \\ \dot{\mathrm{g}} &=0 \end{aligned} p˙v˙q˙a˙bω˙bg˙=v=R(am−ab)+g=21q⊗(ωm−ωb)=0=0=0 - The error-state kinematics
δ p ˙ = δ v δ v ˙ = − R [ a m − a b ] × δ θ − R δ a b + δ g − R a n δ θ ˙ = − [ ω m − ω b ] × δ θ − δ ω b − ω n δ a ˙ b = a w δ ω ˙ b = ω w δ g ˙ = 0 \begin{aligned} \dot{\delta \mathbf{p}} &=\delta \mathbf{v} \\ \dot{\delta \mathbf{v}} &=-\mathbf{R}\left[\mathbf{a}_{m}-\mathbf{a}_{b}\right]_{\times} \delta \boldsymbol{\theta}-\mathbf{R} \delta \mathbf{a}_{b}+\delta \mathbf{g}-\mathbf{R a}_{n} \\ \dot{\delta \boldsymbol{\theta}} &=-\left[\boldsymbol{\omega}_{m}-\boldsymbol{\omega}_{b}\right]_{\times} \delta \boldsymbol{\theta}-\delta \boldsymbol{\omega}_{b}-\boldsymbol{\omega}_{n} \\ \dot{\delta \mathbf{a}}_{b} &=\mathbf{a}_{w} \\ \delta \dot{\boldsymbol{\omega}}_{b} &=\boldsymbol{\omega}_{w} \\ \dot{\delta \mathbf{g}} &=0 \end{aligned} δp˙δv˙δθ˙δa˙bδω˙bδg˙=δv=−R[am−ab]×δθ−Rδab+δg−Ran=−[ωm−ωb]×δθ−δωb−ωn=aw=ωw=0
3. 离散时间的系统运动学(System kinematics in discrete time)
连续时间的系统运动学方程是微分方程,离散化后转换成差分方程,所谓离散化,其实本质就是积分
- The nominal state kinematics
此差分方程用于预测系统状态
p ← p + v Δ t + 1 2 ( R ( a m − a b ) + g ) Δ t 2 v ← v + ( R ( a m − a b ) + g ) Δ t q ← q ⊗ q { ( ω m − ω b ) Δ t } a b ← a b ω b ← ω b g ← g \begin{aligned} \mathbf{p} & \leftarrow \mathbf{p}+\mathbf{v} \Delta t+\frac{1}{2}\left(\mathbf{R}\left(\mathbf{a}_{m}-\mathbf{a}_{b}\right)+\mathbf{g}\right) \Delta t^{2} \\ \mathbf{v} & \leftarrow \mathbf{v}+\left(\mathbf{R}\left(\mathbf{a}_{m}-\mathbf{a}_{b}\right)+\mathbf{g}\right) \Delta t \\ \mathbf{q} & \leftarrow \mathbf{q} \otimes \mathbf{q}\left\{\left(\boldsymbol{\omega}_{m}-\boldsymbol{\omega}_{b}\right) \Delta t\right\} \\ \mathbf{a}_{b} & \leftarrow \mathbf{a}_{b} \\ \boldsymbol{\omega}_{b} & \leftarrow \boldsymbol{\omega}_{b} \\ \mathbf{g} & \leftarrow \mathbf{g} \end{aligned} pvqabωbg←p+vΔt+21(R(am−ab)+g)Δt2←v+(R(am−ab)+g)Δt←q⊗q{(ωm−ωb)Δt}←ab←ωb←g - The error-state kinematics
此差分方程用于协方差传递
δ p ← δ p + δ v Δ t δ v ← δ v + ( − R [ a m − a b ] × δ θ − R δ a b + δ g ) Δ t + v i δ θ ← R ⊤ { ( ω m − ω b ) Δ t } δ θ − δ ω b Δ t + θ i δ a b ← δ a b + a i δ ω b ← δ ω b + ω i δ g ← δ g \begin{aligned} \delta \mathbf{p} & \leftarrow \delta \mathbf{p}+\delta \mathbf{v} \Delta t \\ \delta \mathbf{v} & \leftarrow \delta \mathbf{v}+\left(-\mathbf{R}\left[\mathbf{a}_{m}-\mathbf{a}_{b}\right]_{\times} \delta \boldsymbol{\theta}-\mathbf{R} \delta \mathbf{a}_{b}+\delta \mathbf{g}\right) \Delta t+\mathbf{v}_{\mathbf{i}} \\ \delta \boldsymbol{\theta} & \leftarrow \mathbf{R}^{\top}\left\{\left(\boldsymbol{\omega}_{m}-\boldsymbol{\omega}_{b}\right) \Delta t\right\} \delta \boldsymbol{\theta}-\delta \boldsymbol{\omega}_{b} \Delta t+\boldsymbol{\theta}_{\mathbf{i}} \\ \delta \mathbf{a}_{b} & \leftarrow \delta \mathbf{a}_{b}+\mathbf{a}_{\mathbf{i}} \\ \delta \boldsymbol{\omega}_{b} & \leftarrow \delta \boldsymbol{\omega}_{b}+\boldsymbol{\omega}_{\mathbf{i}} \\ \delta \mathbf{g} & \leftarrow \delta \mathbf{g} \end{aligned} δpδvδθδabδωbδg←δp+δvΔt←δv+(−R[am−ab]×δθ−Rδab+δg)Δt+vi←R⊤{(ωm−ωb)Δt}δθ−δωbΔt+θi←δab+ai←δωb+ωi←δg
4. 离散时间的error-state kinematics方程推导
-
第一步:写出连续时间的true-state kinematics
x ˙ = f ( x , u , w ) u ~ ∼ N { 0 , U c } , w c ∼ N { 0 , W c } \dot{\mathbf{x}}=f(\mathbf{x}, \mathbf{u}, \mathbf{w}) \\ \tilde{\mathbf{u}} \sim \mathcal{N}\left\{0, \mathbf{U}^{c}\right\} \quad, \quad \mathbf{w}^{c} \sim \mathcal{N}\left\{0, \mathbf{W}^{c}\right\} x˙=f(x,u,w)u~∼N{0,Uc},wc∼N{0,Wc}注意,区分两种噪声模型:
- 控制信号噪声
u
~
\tilde{\mathbf{u}}
u~
此噪声在采样时间段内认为是常量 - 随机扰动噪声
w
c
\mathbf{w}^{c}
wc
跟采样无关,时刻以高斯分布的形态改变(时变量),布朗运动
- 控制信号噪声
u
~
\tilde{\mathbf{u}}
u~
-
第二步:写出连续时间的error-state kinematics(一阶泰勒展开)
δ ˙ x = A δ x + B u ~ + C w A ≜ ∂ f ∂ δ x ∣ x , u m , B ≜ ∂ f ∂ u ~ ∣ x , u m , C ≜ ∂ f ∂ w ∣ x , u m \dot{\delta} \mathbf{x}=\mathbf{A} \delta \mathbf{x}+\mathbf{B} \tilde{\mathbf{u}}+\mathbf{C} \mathbf{w} \\ \left.\mathbf{A} \triangleq \frac{\partial f}{\partial \delta \mathbf{x}}\right|_{\mathbf{x}, \mathbf{u}_{m}} \quad,\left.\quad \mathbf{B} \triangleq \frac{\partial f}{\partial \tilde{\mathbf{u}}}\right|_{\mathbf{x}, \mathbf{u}_{m}} \quad,\left.\quad \mathbf{C} \triangleq \frac{\partial f}{\partial \mathbf{w}}\right|_{\mathbf{x}, \mathbf{u}_{m}} δ˙x=Aδx+Bu~+CwA≜∂δx∂f x,um,B≜∂u~∂f x,um,C≜∂w∂f x,um -
第三步:积分得到离散时间的error-state kinematics
δ x n + 1 = δ x n + ∫ n Δ t ( n + 1 ) Δ t ( A δ x ( τ ) + B u ~ ( τ ) + C w c ( τ ) ) d τ = δ x n + ∫ n Δ t ( n + 1 ) Δ t A δ x ( τ ) d τ + ∫ n Δ t ( n + 1 ) Δ t B u ~ ( τ ) d τ + ∫ n Δ t ( n + 1 ) Δ t C w c ( τ ) d τ \begin{aligned} \delta \mathbf{x}_{n+1} &=\delta \mathbf{x}_{n}+\int_{n \Delta t}^{(n+1) \Delta t}\left(\mathbf{A} \delta \mathbf{x}(\tau)+\mathbf{B} \tilde{\mathbf{u}}(\tau)+\mathbf{C} \mathbf{w}^{c}(\tau)\right) d \tau \\ &=\delta \mathbf{x}_{n}+\int_{n \Delta t}^{(n+1) \Delta t} \mathbf{A} \delta \mathbf{x}(\tau) d \tau+\int_{n \Delta t}^{(n+1) \Delta t} \mathbf{B} \tilde{\mathbf{u}}(\tau) d \tau+\int_{n \Delta t}^{(n+1) \Delta t} \mathbf{C} \mathbf{w}^{c}(\tau) d \tau \end{aligned} δxn+1=δxn+∫nΔt(n+1)Δt(Aδx(τ)+Bu~(τ)+Cwc(τ))dτ=δxn+∫nΔt(n+1)ΔtAδx(τ)dτ+∫nΔt(n+1)ΔtBu~(τ)dτ+∫nΔt(n+1)ΔtCwc(τ)dτ分三部分进行积分:
-
dynamic部分
δ x n + ∫ n Δ t ( n + 1 ) Δ t A δ x ( τ ) d τ = Φ ⋅ δ x n \delta \mathbf{x}_{n}+\int_{n \Delta t}^{(n+1) \Delta t} \mathbf{A} \delta \mathbf{x}(\tau) d \tau=\Phi \cdot \delta \mathbf{x}_{n} δxn+∫nΔt(n+1)ΔtAδx(τ)dτ=Φ⋅δxn其中, Φ = e A Δ t \Phi=e^{\mathbf{A} \Delta t} Φ=eAΔt可以通过闭式积分或者近似积分的方式得到
-
一旦被采样,在积分阶段采样噪声不再改变(该噪声已经在采样时成为确定),相当于常量进行积分
∫ n Δ t ( n + 1 ) Δ t B u ~ ( τ ) d τ = B Δ t u ~ n \int_{n \Delta t}^{(n+1) \Delta t} \mathbf{B} \tilde{\mathbf{u}}(\tau) d \tau=\mathbf{B} \Delta t \tilde{\mathbf{u}}_{n} ∫nΔt(n+1)ΔtBu~(τ)dτ=BΔtu~n -
bias随机游走噪声属于布朗运动,在积分阶段也是时变的,所以需要对高斯分布进行积分:
w n ≜ ∫ n Δ t ( n + 1 ) Δ t w ( τ ) d τ , w n ∼ N { 0 , W } , with W = W c Δ t \mathbf{w}_{n} \triangleq \int_{n \Delta t}^{(n+1) \Delta t} \mathbf{w}(\tau) d \tau \quad, \quad \mathbf{w}_{n} \sim \mathcal{N}\{0, \mathbf{W}\} \quad, \quad \text { with } \mathbf{W}=\mathbf{W}^{c} \Delta t wn≜∫nΔt(n+1)Δtw(τ)dτ,wn∼N{0,W}, with W=WcΔt
-
-
最终结果:
Description Continuous time t Discrete time n Δ t state x ˙ = f c ( x , u , w ) x n + 1 = f ( x n , u n , w n ) error-state δ x ˙ = A δ x + B u ~ + C w δ x n + 1 = F x δ x n + F u u ~ n + F w w n system/ transition matrix A F x = Φ = e A Δ t control matrix B F u = B Δ t perturbation matrix C F w = C control covariance U c U = U c perturbation covariance W c W = W c Δ t \begin{array}{|c|c|c|} \hline \text { Description } & \text { Continuous time } t & \text { Discrete time } n \Delta t \\ \hline \hline \text { state } & \dot{\mathbf{x}}=f^{c}(\mathbf{x}, \mathbf{u}, \mathbf{w}) & \mathbf{x}_{n+1}=f\left(\mathbf{x}_{n}, \mathbf{u}_{n}, \mathbf{w}_{n}\right) \\ \text { error-state } & \dot{\delta \mathbf{x}}=\mathbf{A} \delta \mathbf{x}+\mathbf{B \tilde{u}}+\mathbf{C} \mathbf{w} & \delta \mathbf{x}_{n+1}=\mathbf{F}_{\mathbf{x}} \delta \mathbf{x}_{n}+\mathbf{F}_{\mathbf{u}} \tilde{\mathbf{u}}_{n}+\mathbf{F}_{\mathbf{w}} \mathbf{w}_{n} \\ \hline \text { system/ transition matrix } & \mathbf{A} & \mathbf{F}_{\mathbf{x}}=\Phi=e^{\mathbf{A} \Delta t} \\ \text { control matrix } & \mathbf{B} & \mathbf{F}_{\mathbf{u}}=\mathbf{B} \Delta t \\ \text { perturbation matrix } & \mathbf{C} & \mathbf{F}_{\mathbf{w}}=\mathbf{C} \\ \hline \text { control covariance } & \mathbf{U}^{c} & \mathbf{U}=\mathbf{U}^{c} \\ \text { perturbation covariance } & \mathbf{W}^{c} & \mathbf{W}=\mathbf{W}^{c} \Delta t \\ \hline \end{array} Description state error-state system/ transition matrix control matrix perturbation matrix control covariance perturbation covariance Continuous time tx˙=fc(x,u,w)δx˙=Aδx+Bu~+CwABCUcWc Discrete time nΔtxn+1=f(xn,un,wn)δxn+1=Fxδxn+Fuu~n+FwwnFx=Φ=eAΔtFu=BΔtFw=CU=UcW=WcΔtδ x n + 1 = F x δ x n + F u u ~ n + F w w n u ~ n ∼ N { 0 , U } , w n ∼ N { 0 , W } \delta \mathbf{x}_{n+1}=\mathbf{F}_{\mathbf{x}} \delta \mathbf{x}_{n}+\mathbf{F}_{\mathbf{u}} \tilde{\mathbf{u}}_{n}+\mathbf{F}_{\mathbf{w}} \mathbf{w}_{n} \\ \tilde{\mathbf{u}}_{n} \sim \mathcal{N}\{0, \mathbf{U}\} \quad, \quad \mathbf{w}_{n} \sim \mathcal{N}\{0, \mathbf{W}\} δxn+1=Fxδxn+Fuu~n+Fwwnu~n∼N{0,U},wn∼N{0,W}
EKF预测阶段的两个方程:
δ x ^ n + 1 = F x δ ^ x n P n + 1 = F x P n F x ⊤ + F u U F u ⊤ + F w W F w ⊤ = e A Δ t P n ( e A Δ t ) ⊤ + Δ t 2 B U c B ⊤ + Δ t C W c C ⊤ \begin{aligned} \hat{\delta \mathbf{x}}_{n+1} &=\mathbf{F}_{\mathbf{x}} \hat{\delta} \mathbf{x}_{n} \\ \mathbf{P}_{n+1} &=\mathbf{F}_{\mathbf{x}} \mathbf{P}_{n} \mathbf{F}_{\mathbf{x}}^{\top}+\mathbf{F}_{\mathbf{u}} \mathbf{U} \mathbf{F}_{\mathbf{u}}^{\top}+\mathbf{F}_{\mathbf{w}} \mathbf{W} \mathbf{F}_{\mathbf{w}}^{\top} \\ &=e^{\mathbf{A} \Delta t} \mathbf{P}_{n}\left(e^{\mathbf{A} \Delta t}\right)^{\top}+\Delta t^{2} \mathbf{B} \mathbf{U}^{c} \mathbf{B}^{\top}+\Delta t \mathbf{C} \mathbf{W}^{c} \mathbf{C}^{\top} \end{aligned} δx^n+1Pn+1=Fxδ^xn=FxPnFx⊤+FuUFu⊤+FwWFw⊤=eAΔtPn(eAΔt)⊤+Δt2BUcB⊤+ΔtCWcC⊤注意观察:
- the dynamic error term is exponential
- the measurement error term is quadratic
- and the perturbation error term is linear
5. ESKF中需要进行两次积分
Integration needs to be done for the following sub-systems
- The nominal state
- The error-state
- The deterministic part: state dynamics and control
- The stochastic part: noise and perturbations