本文为gtsam imu预积分文档学习笔记,为gtsam基于切向量实现的imu预积分的理论基础。
定义导航状态为 X b n = { R b n , P b n , V b n } X^n_b=\{R^n_b,P^n_b,V^n_b\} Xbn={Rbn,Pbn,Vbn}
下文均省略上下标
对于导航问题我们用如下微分方程描述 X ˙ ( t ) = F ( t , X ) \dot X(t)=F(t,X) X˙(t)=F(t,X)
X ˙ ( t ) = [ R ˙ ( X , t ) , V ( t ) , V ˙ ( X , t ) ] = [ R ( t ) [ ω b ( t ) ] × , V ( t ) , g + R ( t ) a b ( t ) ] \dot{X}(t)=[\dot{R}(X, t), V(t), \dot{V}(X, t)]=\left[R(t)\left[\omega^{b}(t)\right]_{\times}, V(t), g+R(t) a^{b}(t)\right] X˙(t)=[R˙(X,t),V(t),V˙(X,t)]=[R(t)[ωb(t)]×,V(t),g+R(t)ab(t)]
基于流形空间的优化基于局部坐标的概念。当初始位姿为 R 0 R_0 R0,定义一个局部映射 Φ R 0 ( θ ) \Phi _{R_0}(\theta) ΦR0(θ)从局部坐标 θ ∈ R 3 \theta\in \mathbb{R}^3 θ∈R3 映射到 R 0 R_0 R0 的邻域:
Φ R 0 ( θ ) = R 0 exp ( [ θ ] × ) \Phi_{R_{0}}(\theta)=R_{0} \exp \left([\theta]_{\times}\right) ΦR0(θ)=R0exp([θ]×)
局部坐标系 θ \theta θ 和切向量是同构的,定义 θ = ω t \theta=\omega t θ=ωt,有
d Φ R 0 ( ω t ) d t ∣ t = 0 = d R 0 exp ( [ ω t ] × ) d t ∣ t = 0 = R 0 [ ω ] × \left.\frac{d \Phi_{R_{0}}(\omega t)}{d t}\right|_{t=0}=\left.\frac{d R_{0} \exp \left([\omega t]_{\times}\right)}{d t}\right|_{t=0}=R_{0}[\omega]_{\times} dtdΦR0(ωt)∣∣∣∣t=0=dtdR0exp([ωt]×)∣∣∣∣t=0=R0[ω]×
因此,三维向量 ω \omega ω表示了在 S O ( 3 ) SO(3) SO(3)流形上的前进方向,但是仅在 R 0 R_0 R0附近的局部坐标系上有效。
类似的,可以定义在 S E ( 3 ) SE(3) SE(3)上的局部坐标 ξ = [ ω t , v t ] ∈ R 6 \xi=[\omega t, v t] \in \mathbb{R}^{6} ξ=[ωt,vt]∈R6与其对应的映射函数
Φ T 0 ( ξ ) = T 0 exp ξ ^ \Phi_{T_{0}}(\xi)=T_{0} \exp \hat{\xi} ΦT0(ξ)=T0expξ^
定义一个 3 × 3 3\times3 3×3的雅克比矩阵模拟增量 δ \delta δ 对局部坐标系的影响。
Φ R 0 ( θ + δ ) ≈ Φ R 0 ( θ ) exp ( [ H ( θ ) δ ] × ) = Φ Φ R 0 ( θ ) ( H ( θ ) δ ) \Phi_{R_{0}}(\theta+\delta) \approx \Phi_{R_{0}}(\theta) \exp \left([H(\theta) \delta]_{\times}\right)=\Phi_{\Phi_{R_{0}}(\theta)}(H(\theta) \delta) ΦR0(θ+δ)≈ΦR0(θ)exp([H(θ)δ]×)=ΦΦR0(θ)(H(θ)δ)
这个雅克比的计算仅仅依赖 θ \theta θ
H ( θ ) = ∑ k = 0 ∞ ( − 1 ) k ( k + 1 ) ! [ θ ] × k H(\theta)=\sum_{k=0}^{\infty} \frac{(-1)^{k}}{(k+1) !}[\theta]_{\times}^{k} H(θ)=k=0∑∞(k+1)!(−1)k[θ]×k
对于问题 R ˙ ( t ) = F ( R , t ) \dot R(t)=F(R,t) R˙(t)=F(R,t),我们将其解建模为 R ( t ) = Φ R 0 ( θ ( t ) ) R(t)=\Phi_{R_{0}}(\theta(t)) R(t)=ΦR0(θ(t))
定义
γ ( δ ) = R ( t + δ ) = Φ R 0 ( θ ( t ) + θ ˙ ( t ) δ ) ≈ Φ R ( t ) ( H ( θ ) θ ˙ ( t ) δ ) \gamma(\delta)=R(t+\delta)=\Phi_{R_{0}}(\theta(t)+\dot{\theta}(t) \delta) \approx \Phi_{R(t)}(H(\theta) \dot{\theta}(t) \delta) γ(δ)=R(t+δ)=ΦR0(θ(t)+θ˙(t)δ)≈ΦR(t)(H(θ)θ˙(t)δ)
有
R ˙ ( t ) = d γ ( δ ) d δ ∣ δ = 0 = d Φ R ( t ) ( H ( θ ) θ ˙ ( t ) δ ) d δ ∣ δ = 0 = R [ t ] [ H ( θ ) θ ˙ ( t ) ] × \dot{R}(t)=\left.\frac{d \gamma(\delta)}{d \delta}\right|_{\delta=0}=\left.\frac{d \Phi_{R(t)}(H(\theta) \dot{\theta}(t) \delta)}{d \delta}\right|_{\delta=0}=R[t][H(\theta) \dot{\theta}(t)]_{\times} R˙(t)=dδdγ(δ)∣∣∣∣δ=0=dδdΦR(t)(H(θ)θ˙(t)δ)∣∣∣∣∣δ=0=R[t][H(θ)θ˙(t)]×
R X 0 ( ζ ) = { Φ R 0 ( ω t ) , P 0 + R 0 v t , V 0 + R 0 a t } \mathcal{R}_{X_{0}}(\zeta)=\left\{\Phi_{R_{0}}(\omega t), P_{0}+R_{0} v t, V_{0}+R_{0} a t\right\} RX0(ζ)={ΦR0(ωt),P0+R0vt,V0+R0at}
将状态表示为时间的函数
X ( t ) = R X 0 ( ζ ( t ) ) = { Φ R 0 ( θ ( t ) ) , P 0 + R 0 p ( t ) , V 0 + R 0 v ( t ) } X(t)=\mathcal{R}_{X_{0}}(\zeta(t))=\left\{\Phi_{R_{0}}(\theta(t)), P_{0}+R_{0} p(t), V_{0}+R_{0} v(t)\right\} X(t)=RX0(ζ(t))={ΦR0(θ(t)),P0+R0p(t),V0+R0v(t)}
定义一个轨迹函数 γ ( δ ) \gamma(\delta) γ(δ),自变量为时间的增量 δ \delta δ,每一个 δ \delta δ对应状态空间的条轨迹, γ ( δ ) \gamma(\delta) γ(δ)表示轨迹簇,并在 δ = 0 \delta=0 δ=0时通过X(t):
γ ( δ ) = X ( t + δ ) = { Φ R 0 ( θ ( t ) + θ ˙ ( t ) δ ) , P 0 + R 0 { p ( t ) + p ˙ ( t ) δ } , V 0 + R 0 { v ( t ) + v ˙ ( t ) δ } } \gamma(\delta)=X(t+\delta)=\left\{\Phi_{R_{0}}(\theta(t)+\dot{\theta}(t) \delta), P_{0}+R_{0}\{p(t)+\dot{p}(t) \delta\}, V_{0}+R_{0}\{v(t)+\dot{v}(t) \delta\}\right\} γ(δ)=X(t+δ)={ΦR0(θ(t)+θ˙(t)δ),P0+R0{p(t)+p˙(t)δ},V0+R0{v(t)+v˙(t)δ}}
导航状态的导数可以表示为
X ˙ ( t ) = d γ ( δ ) d δ ∣ δ = 0 = [ R ( t ) [ H ( θ ) θ ˙ ( t ) ] × , R 0 p ˙ ( t ) , R 0 v ˙ ( t ) ] \dot{X}(t)=\left.\frac{d \gamma(\delta)}{d \delta}\right|_{\delta=0}=\left[R(t)\left[H(\theta) \dot{\theta}(t)\right]_{\times}, R_{0} \dot{p}(t), R_{0} \dot{v}(t)\right] X˙(t)=dδdγ(δ)∣∣∣∣δ=0=[R(t)[H(θ)θ˙(t)]×,R0p˙(t),R0v˙(t)]
铺垫了这么多 终于进入核心内容了
在Lupton 的论文(On-Manifold Preintegration for Real-Time Visual–Inertial Odometry)中,当不知道导航状态 X i X_i Xi的状态时,无法对重力加速度进行补偿,因此吧速度拆成重力加速和比力两部分。
v t 2 n = v t 1 n + ∫ t 1 t 2 ( R b t n ( f t b − b i a s f o b s ) + g n ) d t = v t 1 n + ∫ t 1 t 2 g n d t + R b t 1 n ∫ t 1 t 2 ( R b t b t 1 ( f t b − b i a s f o b s ) ) d t v_{t 2}^{n}=v_{t 1}^{n}+\int_{t 1}^{t 2}\left(R_{b t}^{n}\left(f_{t}^{b}-b i a s_{f}^{o b s}\right)+g^{n}\right) d t=v_{t 1}^{n}+\int_{t 1}^{t 2} g^{n} d t+R_{b t 1}^{n} \int_{t 1}^{t 2}\left(R_{b t}^{b t 1}\left(f_{t}^{b}-b i a s_{f}^{o b s}\right)\right) d t vt2n=vt1n+∫t1t2(Rbtn(ftb−biasfobs)+gn)dt=vt1n+∫t1t2gndt+Rbt1n∫t1t2(Rbtbt1(ftb−biasfobs))dt
把原文这个式子左右两边同乘 R n b t 1 R^{bt1}_n Rnbt1有
v t 2 b t 1 = v t 1 b t + R n b t 1 ∫ t 1 t 2 g n d t + ∫ t 1 t 2 ( R b t b t 1 ( f t b − b i a s f o b s ) ) d t (1) v_{t 2}^{bt 1}=v_{t 1}^{bt}+R^{bt1}_n\int_{t 1}^{t 2} g^{n} d t+ \int_{t 1}^{t 2}\left(R_{b t}^{b t 1}\left(f_{t}^{b}-b i a s_{f}^{o b s}\right)\right) d t\tag{1} vt2bt1=vt1bt+Rnbt1∫t1t2gndt+∫t1t2(Rbtbt1(ftb−biasfobs))dt(1)
本文档的表达 v ( t ) = v g ( t ) + v a ( t ) v(t)=v_g(t)+v_a(t) v(t)=vg(t)+va(t)
进一步的
v ˙ g ( t ) = R i T g v ˙ a ( t ) = R b i ( t ) a b ( t ) \begin{aligned} &\dot{v}_{g}(t)=R_{i}^{T} g \\ &\dot{v}_{a}(t)=R_{b}^{i}(t) a^{b}(t) \end{aligned} v˙g(t)=RiTgv˙a(t)=Rbi(t)ab(t)
这里的公式和 ( 1 ) (1) (1)中相同。
p t 2 n = p t 1 n + ( t 2 − t 1 ) v t 1 n + ∬ t 1 t 2 ( R b t n ( f t b − b i a s f o b s ) + g n ) d t 2 = p t 1 n + ( t 2 − t 1 ) v t 1 n + ∬ t 1 t 2 g n d t 2 + R b t 1 n ∬ t 1 t 2 ( R b t b t 1 ( f t b − b i a s f o b s ) ) d t 2 p_{t 2}^{n}=p_{t 1}^{n}+(t 2-t 1) v_{t 1}^{n}+\iint_{t 1}^{t 2}\left(R_{b t}^{n}\left(f_{t}^{b}-b i a s_{f}^{o b s}\right)+g^{n}\right) d t^{2}= p_{t 1}^{n}+(t 2-t 1) v_{t 1}^{n}+\iint_{t 1}^{t 2} g^{n} d t^{2}+R_{b t 1}^{n} \iint_{t 1}^{t 2}\left(R_{b t}^{b t 1}\left(f_{t}^{b}-b i a s_{f}^{o b s}\right)\right) d t^{2} pt2n=pt1n+(t2−t1)vt1n+∬t1t2(Rbtn(ftb−biasfobs)+gn)dt2=pt1n+(t2−t1)vt1n+∬t1t2gndt2+Rbt1n∬t1t2(Rbtbt1(ftb−biasfobs))dt2
把原文这个式子左右两边同乘 R n b t 1 R^{bt1}_n Rnbt1有
p t 2 b t 1 = p t 1 b t 1 + ( t 2 − t 1 ) v t 1 b t 1 + R n b t 1 ∬ t 1 t 2 g n d t 2 + ∬ t 1 t 2 ( R b t b t 1 ( f t b − b i a s f o b s ) ) d t 2 (2) p_{t 2}^{bt1}= p_{t 1}^{bt1}+(t 2-t 1) v_{t 1}^{bt1}+R_{n}^{bt1}\iint_{t 1}^{t 2} g^{n} d t^{2}+ \iint_{t 1}^{t 2}\left(R_{b t}^{b t 1}\left(f_{t}^{b}-b i a s_{f}^{o b s}\right)\right) d t^{2} \tag{2} pt2bt1=pt1bt1+(t2−t1)vt1bt1+Rnbt1∬t1t2gndt2+∬t1t2(Rbtbt1(ftb−biasfobs))dt2(2)
p ( t ) = p i ( t ) + p g ( t ) + p v ( t ) p ˙ i ( t ) = R i T V i p ˙ g ( t ) = v g ( t ) = R i T g t p ˙ v ( t ) = v a ( t ) \begin{aligned} &p(t)=p_{i}(t)+p_{g}(t)+p_{v}(t) \\ &\dot{p}_{i}(t)=R_{i}^{T} V_{i} \\ &\dot{p}_{g}(t)=v_{g}(t)=R_{i}^{T} g t \\ &\dot{p}_{v}(t)=v_{a}(t) \end{aligned} p(t)=pi(t)+pg(t)+pv(t)p˙i(t)=RiTVip˙g(t)=vg(t)=RiTgtp˙v(t)=va(t)
这个式子和 ( 2 ) (2) (2)本质相同。
总的来说,IMU预积分因子由一下三项组成
θ ˙ ( t ) = H ( θ ( t ) ) − 1 ω b ( t ) p ˙ v ( t ) = v a ( t ) v ˙ a ( t ) = R b i ( t ) a b ( t ) \begin{aligned} \dot{\theta}(t) &=H(\theta(t))^{-1} \omega^{b}(t) \\ \dot{p}_{v}(t) &=v_{a}(t) \\ \dot{v}_{a}(t) &=R_{b}^{i}(t) a^{b}(t) \end{aligned} θ˙(t)p˙v(t)v˙a(t)=H(θ(t))−1ωb(t)=va(t)=Rbi(t)ab(t)
从零开始,一直到时间 t i j t_{ij} tij,有 R b i ( t ) = exp ( [ θ ( t ) ] × ) R_{b}^{i}(t)=\text{exp}([\theta(t)]_\times) Rbi(t)=exp([θ(t)]×),用局部坐标向量表示为
ζ ( t i j ) = [ θ ( t i j ) , p ( t i j ) , v ( t i j ) ] = [ θ ( t i j ) , R i T V i t i j + R i T g t i j 2 2 + p v ( t i j ) , R i T g t i j + v a ( t i j ) ] \zeta\left(t_{i j}\right)=\left[\theta\left(t_{i j}\right), p\left(t_{i j}\right), v\left(t_{i j}\right)\right]=\left[\theta\left(t_{i j}\right), R_{i}^{T} V_{i} t_{i j}+R_{i}^{T} \frac{g t_{i j}^{2}}{2}+p_{v}\left(t_{i j}\right), R_{i}^{T} g t_{i j}+v_{a}\left(t_{i j}\right)\right] ζ(tij)=[θ(tij),p(tij),v(tij)]=[θ(tij),RiTVitij+RiT2gtij2+pv(tij),RiTgtij+va(tij)]
X j X_j Xj的导航状态可以表达为
X j = R X i ( ζ ( t i j ) ) = { Φ R 0 ( θ ( t i j ) ) , P i + V i t i j + g t i j 2 2 + R i p v ( t i j ) , V i + g t i j + R i v a ( t i j ) } X_{j}=\mathcal{R}_{X_{i}}\left(\zeta\left(t_{i j}\right)\right)=\left\{\Phi_{R_{0}}\left(\theta\left(t_{i j}\right)\right), P_{i}+V_{i} t_{i j}+\frac{g t_{i j}^{2}}{2}+R_{i} p_{v}\left(t_{i j}\right), V_{i}+g t_{i j}+R_{i} v_{a}\left(t_{i j}\right)\right\} Xj=RXi(ζ(tij))={ΦR0(θ(tij)),Pi+Vitij+2gtij2+Ripv(tij),Vi+gtij+Riva(tij)}
欧拉法求解微分方程的原理就是用一阶导数近似来计算积分,有以下三个式子
θ k + 1 = θ k + θ ˙ ( t k ) Δ t = θ k + H ( θ k ) − 1 ω k b Δ t p k + 1 = p k + p ˙ v ( t k ) Δ t = p k + v k Δ t v k + 1 = v k + v ˙ a ( t k ) Δ t = v k + exp ( [ θ k ] × ) a k b Δ t \begin{aligned} \theta_{k+1}=\theta_{k}+\dot{\theta}\left(t_{k}\right) \Delta_{t} &=\theta_{k}+H\left(\theta_{k}\right)^{-1} \omega_{k}^{b} \Delta_{t} \\ p_{k+1}=p_{k}+\dot{p}_{v}\left(t_{k}\right) \Delta_{t} &=p_{k}+v_{k} \Delta_{t} \\ v_{k+1}=v_{k}+\dot{v}_{a}\left(t_{k}\right) \Delta_{t} &=v_{k}+\exp \left(\left[\theta_{k}\right]_{\times}\right) a_{k}^{b} \Delta_{t} \end{aligned} θk+1=θk+θ˙(tk)Δtpk+1=pk+p˙v(tk)Δtvk+1=vk+v˙a(tk)Δt=θk+H(θk)−1ωkbΔt=pk+vkΔt=vk+exp([θk]×)akbΔt
其中 θ k ≜ θ ( t k ) , p k ≜ p v ( t k ) , v k ≜ v a ( t k ) \theta_{k} \triangleq \theta\left(t_{k}\right), p_{k} \triangleq p_{v}\left(t_{k}\right), v_{k} \triangleq v_{a}\left(t_{k}\right) θk≜θ(tk),pk≜pv(tk),vk≜va(tk)
进一步提高位置的精度,引入二阶导数计算(加速度)
θ k + 1 = θ k + H ( θ k ) − 1 ω k b Δ t p k + 1 = p k + v k Δ t + R k a k b Δ t 2 2 v k + 1 = v k + R k a k b Δ t \begin{aligned} \theta_{k+1} &=\theta_{k}+H\left(\theta_{k}\right)^{-1} \omega_{k}^{b} \Delta_{t} \\ p_{k+1} &=p_{k}+v_{k} \Delta_{t}+R_{k} a_{k}^{b} \frac{\Delta_{t}^{2}}{2} \\ v_{k+1} &=v_{k}+R_{k} a_{k}^{b} \Delta_{t} \end{aligned} θk+1pk+1vk+1=θk+H(θk)−1ωkbΔt=pk+vkΔt+Rkakb2Δt2=vk+RkakbΔt
定义 t k t_k tk时刻的导航状态为 ζ k = [ θ k , p k , v k ] \zeta_k=[\theta_k,p_k,v_k] ζk=[θk,pk,vk],
ζ k + 1 = f ( ζ k , a k b , ω k b ) \zeta_{k+1}=f\left(\zeta_{k}, a_{k}^{b}, \omega_{k}^{b}\right) ζk+1=f(ζk,akb,ωkb)
噪声的传递可以表达为
Σ k + 1 = A k Σ k A k T + B k Σ η a d B k + C k Σ η g d C k \Sigma_{k+1}=A_{k} \Sigma_{k} A_{k}^{T}+B_{k}\Sigma_{\eta}^{a d} B_{k}+C_{k} \Sigma_{\eta}^{g d} C_{k} Σk+1=AkΣkAkT+BkΣηadBk+CkΣηgdCk
Σ k + 1 \Sigma_{k+1} Σk+1: t k + 1 t_{k+1} tk+1时刻的协方差矩阵, 9 × 9 9\times9 9×9大小
Σ k \Sigma_{k} Σk: t k t_{k} tk时刻的协方差矩阵, 9 × 9 9\times9 9×9矩阵
Σ η a d \Sigma_{\eta}^{a d} Σηad测量加速度引入的噪声, 3 × 3 3\times3 3×3矩阵
Σ η g d \Sigma_{\eta}^{g d} Σηgd测量角速度引入的噪声, 3 × 3 3\times3 3×3矩阵
A k ≈ [ I 3 × 3 − Δ t 2 [ ω k b ] × 0 0 R k [ − a k b ] × H ( θ k ) Δ t 2 I 3 × 3 I 3 × 3 Δ t R k [ − a k b ] × H ( θ k ) Δ t 0 I 3 × 3 ] A_{k} \approx\left[\begin{array}{ccc} I_{3 \times 3}-\frac{\Delta_{t}}{2}\left[\omega_{k}^{b}\right]_{\times} &0 & 0\\ R_{k}\left[-a_{k}^{b}\right]_{\times} H\left(\theta_{k}\right) \frac{\Delta_{t}}{2} & I_{3 \times 3} & I_{3 \times 3} \Delta_{t} \\ R_{k}\left[-a_{k}^{b}\right]_{\times} H\left(\theta_{k}\right) \Delta_{t} &0 & I_{3 \times 3} \end{array}\right] Ak≈⎣⎢⎡I3×3−2Δt[ωkb]×Rk[−akb]×H(θk)2ΔtRk[−akb]×H(θk)Δt0I3×300I3×3ΔtI3×3⎦⎥⎤
B k = [ 0 3 × 3 R k Δ t 2 R k Δ t ] , C k = [ H ( θ k ) − 1 Δ t 0 3 × 3 0 3 × 3 ] B_{k}=\left[\begin{array}{c} 0_{3 \times 3} \\ R_{k} \frac{\Delta_{t}}{2} \\ R_{k} \Delta_{t} \end{array}\right], \quad C_{k}=\left[\begin{array}{c} H\left(\theta_{k}\right)^{-1} \Delta_{t} \\ 0_{3 \times 3} \\ 0_{3 \times 3} \end{array}\right] Bk=⎣⎡03×3Rk2ΔtRkΔt⎦⎤,Ck=⎣⎡H(θk)−1Δt03×303×3⎦⎤