线特征的提出,是在这样一个大背景下,基于点特征的视觉slam系统,平时没问题,但遇到了缺乏纹理的甚至是完全没有纹理的low-texured场景。可能会失效。 线特征的出现就是更加充分的利用了空间中领的这些几何信息,那么自然视觉slam系统也就会更加的鲁棒。
点特征我们很熟悉,前端提取,后面把它的空间三维坐标(也恰好是三个自由度)输入到后端优化器中尽心优化。因为恰好是三自由度,三个坐标,所以没有多余的约束,可以使用无约束条件的非线性优化。利用的库就是ceres,g2o和GTSAM那些。
现在,线特征如果要引入基于优化的视觉slam系统,一定也需要面对这样的问题。点特征在后端使用了“重投影误差”,也即时3D的点反投影回到像素平面和像素平面直接提取出的观测值2D点坐标进行一个做差处理。需要思考,对于线特征,我们要弄一个怎样的差,也就是常说的residual出来,并且求出residual对于待优化变量,比如相机的位姿和线特征的坐标,的雅可比矩阵,有了这些要素,直接使用开源优化库框框一顿计算就好了。
下面我们就来详细介绍一下空间直线的两种参数化方法:Plücker参数化方法,直线正交表示方法。为什么需要两种参数化方法呢?因为空间中的直线有4个自由度,而Plücker参数化方法需要使用6个参数表示直线,这样就会导致过参数化,过参数化在优化的时候就需要采用带约束的优化,不太方便。于是引入了可以用4个参数更新直线的正交表示来方便优化。这两种参数化方法可以很方便的相互转换,所以我们可以在SLAM系统中同时使用这两种参数化形式,在初始化和进行空间变换的时候使用Plücker坐标,在优化的时候使用正交表示。下面我们就来详细了解这两种参数化方法和优化的雅克比求导。
在3D空间中,直线 L \mathcal{L} L 的Plücker坐标表示为 L = ( n ⊤ , d ⊤ ) ⊤ ∈ R 6 \mathcal{L}=\left(\mathbf{n}^{\top}, \mathbf{d}^{\top}\right)^{\top} \in R^6 L=(n⊤,d⊤)⊤∈R6 ,其中 d ∈ R 3 \mathbf{d} \in \mathbf{R}^3 d∈R3是直线的方向向量, n ∈ R 3 \mathbf{n} \in \mathbf{R}^3 n∈R3 是由直线和光心构成的平面 的法向量。Plücker坐标是过参数化的,overparameterized(6个坐标值,却只有4个自由度DoF),比如 和 之间存在约束关系 ( n ⊤ d = 0 ) \left(\mathbf{n}^{\top} \mathbf{d}=\mathbf{0}\right) (n⊤d=0)。于是Plücker坐标不能直接使用无约束的优化。不过这种使用法向量和方向向量的表现形式在初始化直线和进行空间变换的时候很方便。所以在SLAM系统中我们可以使用Plücker坐标来初始化和变换,具体的初始化和变换方法如下:
当给定从世界坐标系 w w w 到相机 c c c 的变换矩阵 T c w = [ R c w p c w 0 1 ] T_{c w}=\left[\begin{array}{cc}R_{c w} & p_{c w} \\ 0 & 1\end{array}\right] Tcw=[Rcw0pcw1],可以通过下面的形式将世界坐标系和相机坐标系下的Plücker线坐标进行变换:
L c = [ n c d c ] = T c w L w = [ R c w [ p c w ] × R c w 0 R c w ] L w \mathcal{L}^c=\left[\begin{array}{l}\mathbf{n}^c \\ \mathbf{d}^c\end{array}\right]=\mathcal{T}_{c w} \mathcal{L}_w=\left[\begin{array}{cc}\mathbf{R}_{c w} & {\left[\mathbf{p}_{c w}\right]_{\times} \mathbf{R}_{c w}} \\ \mathbf{0} & \mathbf{R}_{c w}\end{array}\right] \mathcal{L}^w Lc=[ncdc]=TcwLw=[Rcw0[pcw]×RcwRcw]Lw
上式中 [ ⋅ ] x [\cdot]_x [⋅]x 表示的是三维向量的反对称矩阵, T c w \mathcal{T}_{c w} Tcw 表示的是从世界坐标 w w w到相机坐标 c c c 的Plücker线坐标的变换矩阵, 跟三维点的坐标变换矩阵比较像但是略有不同。
[ a ] × = [ a 1 a 2 a 3 ] = [ 0 − a 3 a 2 a 3 0 − a 1 − a 2 a 1 0 ] [a]_{\times}=\left[\begin{array}{l}a_1 \\ a_2 \\ a_3\end{array}\right]=\left[\begin{array}{ccc}0 & -a_3 & a_2 \\ a_3 & 0 & -a_1 \\ -a_2 & a_1 & 0\end{array}\right] [a]×= a1a2a3 = 0a3−a2−a30a1a2−a10
当我们从不同的两帧相机观测到一个新的线路标的时候,Plücker坐标初始化方式也很简单。如图1b中所示,直线 L \mathcal{L} L 在两帧图像 c 1 c_1 c1 和 c 2 c_2 c2 中表示为两个线段 z L c 1 \mathbf{z}_{\mathcal{L}}^{c_1} zLc1 和 z L c 2 \mathbf{z}_{\mathcal{L}}^{c_2} zLc2 。线段 在归一化平面可以被两个端点表示, s c 1 = [ u s v s 1 ] T \mathbf{s}^{c_1}=\left[\begin{array}{lll}u_{\mathrm{s}} & v_{\mathrm{s}} & 1\end{array}\right]^T sc1=[usvs1]T 和 e c 1 = [ u e v e 1 ] T \mathbf{e}^{c_1}=\left[\begin{array}{lll}u_{\mathrm{e}} & v_{\mathrm{e}} & 1\end{array}\right]^T ec1=[ueve1]T 。再加上坐标原点 C = [ x 0 y 0 z 0 ] \mathbf{C}=\left[\begin{array}{lll}x_0 & y_0 & z_0\end{array}\right] C=[x0y0z0] ,这三个点可以确定一个平面: π = [ π x π y π z π w ] \pi=\left[\begin{array}{llll}\pi_x & \pi_y & \pi_z & \pi_w\end{array}\right] π=[πxπyπzπw].
π X ( x − x 0 ) + π y ( y − y 0 ) + π z ( z − z 0 ) = 0 \pi_X\left(x-x_0\right)+\pi_y\left(y-y_0\right)+\pi_z\left(z-z_0\right)=0 πX(x−x0)+πy(y−y0)+πz(z−z0)=0
其中: [ π x π y π z ] = [ s c 1 ] × e c 1 , π w = π x x 0 + π y y 0 + π z z 0 \left[\begin{array}{l}\pi_x \\ \pi_y \\ \pi_z\end{array}\right]=\left[\mathbf{s}^{c 1}\right]_{\times} \mathbf{e}^{c_1}, \quad \pi_w=\pi_x x_0+\pi_y y_0+\pi_z z_0 πxπyπz =[sc1]×ec1,πw=πxx0+πyy0+πzz0
然后从对偶矩阵中可以提取出Plücker坐标, L = ( n T , d T ) T \mathcal{L}=\left(\mathbf{n}^T, \mathbf{d}^T\right)^T L=(nT,dT)T ,法向量和方向向量都不要求一定要是单位向量。
3D空间下的直线只有4个自由度,使用Plücker坐标的话,是过参数化的表示形式,在优化过程是有约束的不方便,所以引入一种四个参数的表达方式这样就没有多余的约束了,此处就是一种正交表示: ( U , W ) ∈ S O ( 3 ) × S O ( 2 ) (\mathbf{U}, \mathbf{W}) \in S O(3) \times S O(2) (U,W)∈SO(3)×SO(2) 。 这两种形式之间的转换是很方便的。
首先我们需要知道了直线的Plücker坐 L = ( n ⊤ , d ⊤ ) ⊤ \mathcal{L}=\left(\mathbf{n}^{\top}, \mathbf{d}^{\top}\right)^{\top} L=(n⊤,d⊤)⊤ ,然后对 进行QR分解,得到:
[ n d ] = [ n ∥ n ∥ d ∥ d ∥ n × d ∥ n × d ∥ ] [ ∥ n ∥ 0 0 ∥ d ∥ 0 0 ] \left[\begin{array}{ll}\mathbf{n} & \mathbf{d}\end{array}\right]=\left[\begin{array}{lll}\frac{\mathbf{n}}{\|\mathbf{n}\|} & \frac{\mathbf{d}}{\|\mathbf{d}\|} & \frac{\mathbf{n} \times \mathbf{d}}{\|\mathbf{n} \times \mathbf{d}\|}\end{array}\right]\left[\begin{array}{cc}\|\mathbf{n}\| & 0 \\ 0 & \|\mathbf{d}\| \\ 0 & 0\end{array}\right] [nd]=[∥n∥n∥d∥d∥n×d∥n×d] ∥n∥000∥d∥0
分解得到的第一项是正交矩阵 U \mathbf{U} U,是一个旋转矩阵。所表示的是相机坐标系到直线坐标系的旋转。其中直线坐标系的定义如下:用直线的方向向量以及直线和光心组成平面的法向量作为坐标的两个轴,再用他们叉乘得到的向量作为第三个轴,所以
U = R x ( θ 1 ) R y ( θ 2 ) R z ( θ 3 ) = [ u 1 u 2 u 3 ] = [ n ∥ n ∥ d ∥ d ∥ n × d ∥ n × d ∥ ] \begin{aligned} \mathbf{U} & =\mathbf{R}_x\left(\theta_1\right) \mathbf{R}_y\left(\theta_2\right) \mathbf{R}_z\left(\theta_3\right)=\left[\begin{array}{lll}\mathbf{u}_1 & \mathbf{u}_2 & \mathbf{u}_3\end{array}\right] \\ & =\left[\begin{array}{lll}\frac{\mathbf{n}}{\|\mathbf{n}\|} & \frac{\mathbf{d}}{\|\mathbf{d}\|} & \frac{\mathbf{n} \times \mathbf{d}}{\|\mathbf{n} \times \mathbf{d}\|}\end{array}\right]\end{aligned} U=Rx(θ1)Ry(θ2)Rz(θ3)=[u1u2u3]=[∥n∥n∥d∥d∥n×d∥n×d]
对于后面矩阵的两个元素 ∥ n ∥ , ∥ d ∥ \|\mathbf{n}\|,\|\mathbf{d}\| ∥n∥,∥d∥ 实际上只有一个自由度,把它们归一化以后,就能用一个 S O 2 {S O} 2 SO2来更新它
W = [ cos ( ϕ ) − sin ( ϕ ) sin ( ϕ ) cos ( ϕ ) ] = [ w 1 − w 2 w 2 w 1 ] = 1 ( ∥ n ∥ 2 + ∥ d ∥ 2 ) [ ∥ n ∥ − ∥ d ∥ ∥ d ∥ ∥ n ∥ ] \begin{aligned} \mathbf{W} & =\left[\begin{array}{cc}\cos (\phi) & -\sin (\phi) \\ \sin (\phi) & \cos (\phi)\end{array}\right]=\left[\begin{array}{cc}w_1 & -w_2 \\ w_2 & w_1\end{array}\right] \\ & =\frac{1}{\sqrt{\left(\|\mathbf{n}\|^2+\|\mathbf{d}\|^2\right)}}\left[\begin{array}{cc}\|\mathbf{n}\| & -\|\mathbf{d}\| \\ \|\mathbf{d}\| & \|\mathbf{n}\|\end{array}\right]\end{aligned} W=[cos(ϕ)sin(ϕ)−sin(ϕ)cos(ϕ)]=[w1w2−w2w1]=(∥n∥2+∥d∥2)1[∥n∥∥d∥−∥d∥∥n∥]
原点到直系的距离: d = w 1 w 2 = ∥ n ∥ ∥ d ∥ d=\frac{w_1}{w_2}=\frac{\|\mathbf{n}\|}{\|\mathbf{d}\|} d=w2w1=∥d∥∥n∥
所以W里编码了距离信息d。由正交表达也很容易得到普吕克坐标:
L ′ ∼ [ w 1 u 1 T , w 2 u 2 T ] T \mathcal{L}^{\prime} \sim\left[w_1 \mathbf{u}_1^T, w_2 \mathbf{u}_2^T\right]^T L′∼[w1u1T,w2u2T]T
注意这里不是等号, 他们之间在数值上差了一个尺度,但是对应同一条三维空间直线。
L ′ = 1 ( ∥ n ∥ 2 + ∥ d ∥ 2 ) L \mathcal{L}^{\prime}=\frac{1}{\sqrt{\left(\|\mathbf{n}\|^2+\|\mathbf{d}\|^2\right)}} \mathcal{L} L′=(∥n∥2+∥d∥2)1L
该部分主要对直线的重投影误差和相关的雅克比进行推导。
在介绍直线的重投影误差前,需要知道三维直线的普吕克坐标在各个坐标系之间的转换矩阵,假设世界坐标系到相机坐标系之间的旋转和平移对应为 R c w , t c w \mathbf{R}_{c w}, \mathbf{t}_{c w} Rcw,tcw,对于世界坐标系下的三维直线 L w \mathcal{L}_w Lw可以利用如下方程转换到相机坐标系下:
L c = [ n c d c ] = T c w L w = [ R c w [ t c w ] × R c w 0 R c w ] L w \mathcal{L}_c=\left[\begin{array}{c}\mathbf{n}_c \\ \mathbf{d}_c\end{array}\right]=\mathcal{T}_{c w} \mathcal{L}_w=\left[\begin{array}{cc}\mathbf{R}_{c w} & {\left[\mathbf{t}_{c w}\right]_{\times} \mathbf{R}_{c w}} \\ 0 & \mathbf{R}_{c w}\end{array}\right] \mathcal{L}_w Lc=[ncdc]=TcwLw=[Rcw0[tcw]×RcwRcw]Lw
同理,可以定义该变换的逆过程,逆变换矩阵为将直线的普吕克坐标从相机坐标系下转到世界坐标下:
T c w − 1 = [ R c w T [ − R c w T t c w ] × R c w T 0 R c w T ] = [ R c w T − R c w T [ t c w ] × 0 R c w T ] \mathcal{T}_{c w}^{-1}=\left[\begin{array}{cc}\mathbf{R}_{c w}^T & {\left[-\mathbf{R}_{c w}^T \mathbf{t}_{c w}\right]_{\times} \mathbf{R}_{c w}^T} \\ 0 & \mathbf{R}_{c w}^T\end{array}\right]=\left[\begin{array}{cc}\mathbf{R}_{c w}^T & -\mathbf{R}_{c w}^T\left[\mathbf{t}_{c w}\right]_{\times} \\ 0 & \mathbf{R}_{c w}^T\end{array}\right] Tcw−1=[RcwT0[−RcwTtcw]×RcwTRcwT]=[RcwT0−RcwT[tcw]×RcwT]
进一步,从相机系下投影到图像平面的投影矩阵(跟相机性质,内参有关系):
l = [ l 1 l 2 l 3 ] = K n c = [ f y 0 0 0 f x 0 − f y c x − f x c y f x f y ] n c \mathbf{l}=\left[\begin{array}{l}l_1 \\ l_2 \\ l_3\end{array}\right]=\mathcal{K} \mathbf{n}_c=\left[\begin{array}{ccc}f_y & 0 & 0 \\ 0 & f_x & 0 \\ -f_y c_x & -f_x c_y & f_x f_y\end{array}\right] \mathbf{n}_c l= l1l2l3 =Knc= fy0−fycx0fx−fxcy00fxfy nc
其中 K K K为相机内参数组成的矩阵。
定义重投影误差为检测的直线线段的两个端点到重投影直线上的距离:
e l = [ d ( x s , l ) d ( x e , l ) ] \mathbf{e}_l=\left[\begin{array}{l}d\left(\mathbf{x}_s, \mathbf{l}\right) \\ d\left(\mathbf{x}_e, \mathbf{l}\right)\end{array}\right] el=[d(xs,l)d(xe,l)]
其中 d ( x , l ) d(\mathrm{x}, \mathbf{l}) d(x,l)表示点到直线的距离: d ( x , l ) = x T l l 1 2 + l 2 2 d(\mathrm{x}, \mathrm{l})=\frac{\mathrm{x}^T \mathrm{l}}{\sqrt{l_1^2+l_2^2}} d(x,l)=l12+l22xTl
x s , x e \mathbf{x}_s, \mathbf{x}_e xs,xe表示嫌多在图像平面的两个端点。
∂ e l ∂ l ∂ l ∂ L c ∂ L c ∂ L w ∂ L w ∂ O ∂ O ∂ [ δ θ δ ϕ ] \frac{\partial \mathbf{e}_l}{\partial \mathbf{l}} \frac{\partial \mathbf{l}}{\partial \mathcal{L}_c} \frac{\partial \mathcal{L}_c}{\partial \mathcal{L}_w} \frac{\partial \mathcal{L}_w}{\partial \mathcal{O}} \frac{\partial \mathcal{O}}{\partial\left[\begin{array}{l}\delta \boldsymbol{\theta} \\ \delta \phi\end{array}\right]} ∂l∂el∂Lc∂l∂Lw∂Lc∂O∂Lw∂[δθδϕ]∂O
O = [ u 1 , u 2 , w 1 , w 2 ] T \mathcal{O}=\left[\mathbf{u}_1, \mathbf{u}_2, w_1, w_2\right]^T O=[u1,u2,w1,w2]T
首先计算重投影误差 e l \mathrm{e}_l el对重投影直线 l l l的导数
∂ e l ∂ l = [ ∂ e 1 ∂ 1 ∂ e 2 ∂ 1 ] = [ ∂ e 1 ∂ l 1 ∂ e 1 ∂ l 2 ∂ e 1 ∂ l 3 ∂ e 2 ∂ l 1 ∂ e 2 ∂ l 2 ∂ e 2 ∂ l 3 ] = [ − l 1 x s T 1 ( l 1 2 + l 2 2 ) ( 3 2 ) + u s ( l 1 2 + l 2 2 ) ( 1 2 ) − l 2 x s T 1 ( l 1 2 + l 2 2 ) ( 3 2 ) + v s ( l 1 2 + l 2 2 ) ( 1 2 ) 1 ( l 1 2 + l 2 2 ) ( 1 2 ) − l 1 x e T 1 ( l 1 2 + l 2 2 ) ( 3 2 ) + u e ( l 1 2 + l 2 2 ) 2 ) 1 2 ) − l 2 x e T 1 ( l 1 2 + l 2 2 ) ( 3 2 ) + v e ( l 1 2 + l 2 2 ) ( 1 2 ) 1 ( l 1 2 + l 2 2 ) 2 1 2 ) ] 2 × 3 \begin{aligned} \frac{\partial \mathbf{e}_l}{\partial \mathbf{l}} & =\left[\begin{array}{l}\frac{\partial e_1}{\partial \mathbf{1}} \\ \frac{\partial e_2}{\partial \mathbf{1}}\end{array}\right]=\left[\begin{array}{lll}\frac{\partial e_1}{\partial l_1} & \frac{\partial e_1}{\partial l_2} & \frac{\partial e_1}{\partial l_3} \\ \frac{\partial e_2}{\partial l_1} & \frac{\partial e_2}{\partial l_2} & \frac{\partial e_2}{\partial l_3}\end{array}\right] \\ & =\left[\begin{array}{lll}\frac{-l_1 \mathbf{x}_s^T 1}{\left(l_1^2+l_2^2\right)^{\left(\frac{3}{2}\right)}}+\frac{u_s}{\left(l_1^2+l_2^2\right)^{\left(\frac{1}{2}\right)}} & \frac{-l_2 \mathbf{x}_s^T 1}{\left.\left(l_1^2+l_2^2\right)^{\left(\frac{3}{2}\right.}\right)}+\frac{v_s}{\left(l_1^2+l_2^2\right)^{\left(\frac{1}{2}\right)}} & \frac{1}{\left(l_1^2+l_2^2\right)^{\left(\frac{1}{2}\right)}} \\ \frac{-l_1 \mathbf{x}_e^T 1}{\left.\left(l_1^2+l_2^2\right)^{\left(\frac{3}{2}\right.}\right)}+\frac{u_e}{\left.\left.\left(l_1^2+l_2^2\right)^2\right)^{\frac{1}{2}}\right)} & \frac{-l_2 \mathbf{x}_e^T 1}{\left(l_1^2+l_2^2\right)^{\left(\frac{3}{2}\right)}}+\frac{v_e}{\left(l_1^2+l_2^2\right)^{\left(\frac{1}{2}\right)}} & \frac{1}{\left.\left(l_1^2+l_2^2\right)^2 \frac{1}{2}\right)}\end{array}\right]_{2 \times 3}\end{aligned} ∂l∂el=[∂1∂e1∂1∂e2]=[∂l1∂e1∂l1∂e2∂l2∂e1∂l2∂e2∂l3∂e1∂l3∂e2]= (l12+l22)(23)−l1xsT1+(l12+l22)(21)us(l12+l22)(23)−l1xeT1+(l12+l22)2)21)ue(l12+l22)(23)−l2xsT1+(l12+l22)(21)vs(l12+l22)(23)−l2xeT1+(l12+l22)(21)ve(l12+l22)(21)1(l12+l22)221)1 2×3
∂ l ∂ L c = [ K 0 ] 3 × 6 \frac{\partial \mathbf{l}}{\partial \mathcal{L}_c}=\left[\begin{array}{ll}\mathcal{K} & 0\end{array}\right]_{3 \times 6} ∂Lc∂l=[K0]3×6
∂ L c ∂ L w = T w c − 1 \frac{\partial \mathcal{L}_c}{\partial \mathcal{L}_w}=\mathcal{T}_{w c}^{-1} ∂Lw∂Lc=Twc−1
世界坐标系下的三位置线普吕克坐标对正交表达 O = [ u 1 , u 2 , w 1 , w 2 ] T \mathcal{O}=\left[\mathbf{u}_1, \mathbf{u}_2, w_1, w_2\right]^T O=[u1,u2,w1,w2]T的求导为:
∂ L w ∂ O = ∂ [ w 1 u 1 w 2 u 2 ] ∂ O = [ ∂ L w ∂ u 1 ∂ L w ∂ u 2 ∂ L w ∂ w 1 ∂ L w ∂ w 2 ] 6 × ( 3 + 3 + 1 + 1 ) = [ w 1 I 3 × 3 0 3 × 3 u 1 0 3 × 1 0 3 × 3 w 2 I 3 × 3 0 3 × 1 u 2 ] 6 × 8 \begin{aligned} \frac{\partial \mathcal{L}_w}{\partial \mathcal{O}} & =\frac{\partial\left[\begin{array}{c}w_1 \mathbf{u}_1 \\ w_2 \mathbf{u}_2\end{array}\right]}{\partial \mathcal{O}}=\left[\begin{array}{llll}\frac{\partial \mathcal{L}_w}{\partial \mathbf{u}_1} & \frac{\partial \mathcal{L}_w}{\partial \mathbf{u}_2} & \frac{\partial \mathcal{L}_w}{\partial w_1} & \frac{\partial \mathcal{L}_w}{\partial w_2}\end{array}\right]_{6 \times(3+3+1+1)} \\ & =\left[\begin{array}{cccc}w_1 \mathbf{I}_{3 \times 3} & 0_{3 \times 3} & \mathbf{u}_1 & 0_{3 \times 1} \\ 0_{3 \times 3} & w_2 \mathbf{I}_{3 \times 3} & \mathbf{0}_{3 \times 1} & \mathbf{u}_2\end{array}\right]_{6 \times 8}\end{aligned} ∂O∂Lw=∂O∂[w1u1w2u2]=[∂u1∂Lw∂u2∂Lw∂w1∂Lw∂w2∂Lw]6×(3+3+1+1)=[w1I3×303×303×3w2I3×3u103×103×1u2]6×8
接下来计算正交表达对于自身微小变化量的雅克比矩阵:
∂ O ∂ [ δ θ δ ϕ ] = [ ∂ u 1 ∂ δ θ ∂ u 1 ∂ δ ϕ ∂ u 2 ∂ δ θ ∂ u 2 ∂ δ ϕ ∂ w 1 ∂ δ θ ∂ w 1 ∂ δ ϕ ∂ w 2 ∂ δ θ ∂ w 2 ∂ δ ϕ ] 8 × 4 \frac{\partial \mathcal{O}}{\partial\left[\begin{array}{c}\delta \boldsymbol{\theta} \\ \delta \phi\end{array}\right]}=\left[\begin{array}{ll}\frac{\partial \mathbf{u}_1}{\partial \delta \boldsymbol{\theta}} & \frac{\partial \mathbf{u}_1}{\partial \delta \phi} \\ \frac{\partial \mathbf{u}_2}{\partial \delta \boldsymbol{\theta}} & \frac{\partial \mathbf{u}_2}{\partial \delta \phi} \\ \frac{\partial w_1}{\partial \delta \boldsymbol{\theta}} & \frac{\partial w_1}{\partial \delta \phi} \\ \frac{\partial w_2}{\partial \delta \boldsymbol{\theta}} & \frac{\partial w_2}{\partial \delta \phi}\end{array}\right]_{8 \times 4} ∂[δθδϕ]∂O= ∂δθ∂u1∂δθ∂u2∂δθ∂w1∂δθ∂w2∂δϕ∂u1∂δϕ∂u2∂δϕ∂w1∂δϕ∂w2 8×4
在求解之前,需要定义好变量的增量更新形式。
U ∈ S O ( 3 ) , W ∈ S O ( 2 ) \mathbf{U} \in S O(3), \mathbf{W} \in S O(2) U∈SO(3),W∈SO(2)
可以利用李代数的性质来更新他们,分别定义它们的微小增量为: δ θ , δ ϕ \delta \theta, \delta \phi δθ,δϕ
U ′ = U exp ( [ δ θ ] × ) ≈ U ( I + [ δ θ ] × ) W ′ = W exp ( [ δ ϕ ] × ) = W exp ( [ 0 − δ ϕ δ ϕ 0 ] ) ≈ W ( I + [ 0 − δ ϕ δ ϕ 0 ] ) \begin{aligned} \mathbf{U}^{\prime} & =\mathbf{U} \exp \left([\delta \boldsymbol{\theta}]_{\times}\right) \approx \mathbf{U}\left(\mathbf{I}+[\delta \boldsymbol{\theta}]_{\times}\right) \\ \mathbf{W}^{\prime} & =\mathbf{W} \exp \left([\delta \phi]_{\times}\right)=\mathbf{W} \exp \left(\left[\begin{array}{cc}0 & -\delta \phi \\ \delta \phi & 0\end{array}\right]\right) \approx \mathbf{W}\left(\mathbf{I}+\left[\begin{array}{cc}0 & -\delta \phi \\ \delta \phi & 0\end{array}\right]\right)\end{aligned} U′W′=Uexp([δθ]×)≈U(I+[δθ]×)=Wexp([δϕ]×)=Wexp([0δϕ−δϕ0])≈W(I+[0δϕ−δϕ0])
雅克比相应的是:
∂ U ′ ∂ δ θ = ∂ U [ δ θ ] × ∂ δ θ = ∂ U ( δ θ 1 [ 0 0 0 0 0 − 1 0 1 0 ] + δ θ 2 [ 0 0 1 0 0 0 − 1 0 0 ] + δ θ 3 [ 0 − 1 0 1 0 0 0 0 0 ] ) ∂ δ θ \frac{\partial \mathbf{U}^{\prime}}{\partial \delta \boldsymbol{\theta}}=\frac{\partial \mathbf{U}[\delta \boldsymbol{\theta}]_{\times}}{\partial \delta \boldsymbol{\theta}}=\frac{\partial \mathbf{U}\left(\delta \theta_1\left[\begin{array}{ccc}0 & 0 & 0 \\ 0 & 0 & -1 \\ 0 & 1 & 0\end{array}\right]+\delta \theta_2\left[\begin{array}{ccc}0 & 0 & 1 \\ 0 & 0 & 0 \\ -1 & 0 & 0\end{array}\right]+\delta \theta_3\left[\begin{array}{ccc}0 & -1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 0\end{array}\right]\right)}{\partial \delta \boldsymbol{\theta}} ∂δθ∂U′=∂δθ∂U[δθ]×=∂δθ∂U(δθ1[0000010−10]+δθ2[00−1000100]+δθ3[010−100000])
列出对每个增量分量的雅克比:
∂ U ′ ∂ δ θ 1 = U [ 0 0 0 0 0 − 1 0 1 0 ] = [ 0 u 3 − u 2 ] 3 × 3 \frac{\partial \mathbf{U}^{\prime}}{\partial \delta \theta_1}=\mathbf{U}\left[\begin{array}{ccc}0 & 0 & 0 \\ 0 & 0 & -1 \\ 0 & 1 & 0\end{array}\right]=\left[\begin{array}{lll}\mathbf{0} & \mathbf{u}_3 & -\mathbf{u}_2\end{array}\right]_{3 \times 3} ∂δθ1∂U′=U 0000010−10 =[0u3−u2]3×3
∂ U ′ ∂ δ θ 2 = U [ 0 0 1 0 0 0 − 1 0 0 ] = [ − u 3 0 u 1 ] 3 × 3 \frac{\partial \mathbf{U}^{\prime}}{\partial \delta \theta_2}=\mathbf{U}\left[\begin{array}{ccc}0 & 0 & 1 \\ 0 & 0 & 0 \\ -1 & 0 & 0\end{array}\right]=\left[\begin{array}{lll}-\mathbf{u}_3 & \mathbf{0} & \mathbf{u}_1\end{array}\right]_{3 \times 3} ∂δθ2∂U′=U 00−1000100 =[−u30u1]3×3
∂ U ′ ∂ δ θ 3 = U [ 0 − 1 0 1 0 0 0 0 0 ] = [ u 2 − u 1 0 ] 3 × 3 \frac{\partial \mathbf{U}^{\prime}}{\partial \delta \theta_3}=\mathbf{U}\left[\begin{array}{lll}0 & -1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 0\end{array}\right]=\left[\begin{array}{lll}\mathbf{u}_2 & -\mathbf{u}_1 & 0\end{array}\right]_{3 \times 3} ∂δθ3∂U′=U 010−100000 =[u2−u10]3×3
们把上面公式求得的各分量雅克比取对应的列,就能得到:
∂ u 1 ∂ δ θ = [ ∂ u 1 ∂ δ θ 1 ∂ u 1 ∂ δ θ 2 ∂ u 1 ∂ δ θ 3 ] = [ 0 − u 3 u 2 ] 3 × 3 \frac{\partial \mathbf{u}_1}{\partial \delta \boldsymbol{\theta}}=\left[\begin{array}{lll}\frac{\partial \mathbf{u}_1}{\partial \delta \theta_1} & \frac{\partial \mathbf{u}_1}{\partial \delta \theta_2} & \frac{\partial \mathbf{u}_1}{\partial \delta \theta_3}\end{array}\right]=\left[\begin{array}{lll}0 & -\mathbf{u}_3 & \mathbf{u}_2\end{array}\right]_{3 \times 3} ∂δθ∂u1=[∂δθ1∂u1∂δθ2∂u1∂δθ3∂u1]=[0−u3u2]3×3
∂ u 2 ∂ δ θ = [ ∂ u 2 ∂ δ θ 1 ∂ u 2 ∂ δ θ 2 ∂ u 2 ∂ δ θ 3 ] = [ u 3 0 − u 1 ] 3 × 3 \frac{\partial \mathbf{u}_2}{\partial \delta \boldsymbol{\theta}}=\left[\begin{array}{lll}\frac{\partial \mathbf{u}_2}{\partial \delta \theta_1} & \frac{\partial \mathbf{u}_2}{\partial \delta \theta_2} & \frac{\partial \mathbf{u}_2}{\partial \delta \theta_3}\end{array}\right]=\left[\begin{array}{lll}\mathbf{u}_3 & \mathbf{0} & -\mathbf{u}_1\end{array}\right]_{3 \times 3} ∂δθ∂u2=[∂δθ1∂u2∂δθ2∂u2∂δθ3∂u2]=[u30−u1]3×3
∂ W ′ ∂ δ ϕ = ∂ W [ 0 − δ ϕ δ ϕ 0 ] ∂ δ ϕ = W [ 0 − 1 1 0 ] = [ − w 2 − w 1 w 1 − w 2 ] \frac{\partial \mathbf{W}^{\prime}}{\partial \delta \phi}=\frac{\partial \mathbf{W}\left[\begin{array}{cc}0 & -\delta \phi \\ \delta \phi & 0\end{array}\right]}{\partial \delta \phi}=\mathbf{W}\left[\begin{array}{cc}0 & -1 \\ 1 & 0\end{array}\right]=\left[\begin{array}{cc}-w_2 & -w_1 \\ w_1 & -w_2\end{array}\right] ∂δϕ∂W′=∂δϕ∂W[0δϕ−δϕ0]=W[01−10]=[−w2w1−w1−w2]
∂ w 1 ∂ δ ϕ = − w 2 \frac{\partial w_1}{\partial \delta \phi}=-w_2 ∂δϕ∂w1=−w2
∂ w 2 ∂ δ ϕ = w 1 \frac{\partial w_2}{\partial \delta \phi}=w_1 ∂δϕ∂w2=w1
。利用上面计算的结果,就很容易得到:
∂ O ∂ [ δ θ δ ϕ ] = [ ∂ u 1 ∂ δ θ ∂ u 1 ∂ δ ϕ ∂ u 2 ∂ δ θ ∂ u 2 ∂ δ ϕ ∂ w 1 ∂ δ θ ∂ w 1 ∂ δ ϕ ∂ w 2 ∂ δ θ ∂ w 2 ∂ δ ϕ ] 8 × 4 = [ 0 − u 3 u 2 0 u 3 0 − u 1 0 0 0 0 − w 2 0 0 0 w 1 ] 8 × 4 \frac{\partial \mathcal{O}}{\partial\left[\begin{array}{ll}\delta \theta \\ \delta \phi\end{array}\right]}=\left[\begin{array}{ll}\frac{\partial \mathbf{u}_1}{\partial \delta \boldsymbol{\theta}} & \frac{\partial \mathbf{u}_1}{\partial \delta \phi} \\ \frac{\partial \mathbf{u}_2}{\partial \delta \boldsymbol{\theta}} & \frac{\partial \mathbf{u}_2}{\partial \delta \phi} \\ \frac{\partial w_1}{\partial \delta \boldsymbol{\theta}} & \frac{\partial w_1}{\partial \delta \phi} \\ \frac{\partial w_2}{\partial \delta \boldsymbol{\theta}} & \frac{\partial w_2}{\partial \delta \phi}\end{array}\right]_{8 \times 4}=\left[\begin{array}{cccc}\mathbf{0} & -\mathbf{u}_3 & \mathbf{u}_2 & \mathbf{0} \\ \mathbf{u}_3 & \mathbf{0} & -\mathbf{u}_1 & \mathbf{0} \\ 0 & 0 & 0 & -w_2 \\ 0 & 0 & 0 & w_1\end{array}\right]_{8 \times 4} ∂[δθδϕ]∂O= ∂δθ∂u1∂δθ∂u2∂δθ∂w1∂δθ∂w2∂δϕ∂u1∂δϕ∂u2∂δϕ∂w1∂δϕ∂w2 8×4= 0u300−u3000u2−u10000−w2w1 8×4
∂ L w ∂ O ∂ O ∂ [ δ θ δ ϕ ] = [ w 1 I 3 × 3 0 3 × 3 u 1 0 3 × 1 0 3 × 3 w 2 I 3 × 3 0 3 × 1 u 2 ] 6 × 8 [ 0 − u 3 u 2 0 u 3 0 − u 1 0 0 0 0 − w 2 0 0 0 w 1 ] 8 × 4 = [ 0 − w 1 u 3 w 1 u 2 − w 2 u 1 w 2 u 3 0 − w 2 u 1 w 1 u 2 ] 6 × 4 \begin{aligned} \frac{\partial \mathcal{L}_w}{\partial \mathcal{O}} \frac{\partial \mathcal{O}}{\partial}\left[\begin{array}{c}\delta \boldsymbol{\theta} \\ \delta \phi\end{array}\right] & =\left[\begin{array}{cccc}w_1 \mathbf{I}_{3 \times 3} & 0_{3 \times 3} & \mathbf{u}_1 & 0_{3 \times 1} \\ 0_{3 \times 3} & w_2 \mathbf{I}_{3 \times 3} & \mathbf{0}_{3 \times 1} & \mathbf{u}_2\end{array}\right]_{6 \times 8}\left[\begin{array}{cccc}0 & -\mathbf{u}_3 & \mathbf{u}_2 & 0 \\ \mathbf{u}_3 & 0 & -\mathbf{u}_1 & 0 \\ 0 & 0 & 0 & -w_2 \\ 0 & 0 & 0 & w_1\end{array}\right]_{8 \times 4} \\ & =\left[\begin{array}{cccc}0 & -w_1 \mathbf{u}_3 & w_1 \mathbf{u}_2 & -w_2 \mathbf{u}_1 \\ w_2 \mathbf{u}_3 & 0 & -w_2 \mathbf{u}_1 & w_1 \mathbf{u}_2\end{array}\right]_{6 \times 4}\end{aligned} ∂O∂Lw∂∂O[δθδϕ]=[w1I3×303×303×3w2I3×3u103×103×1u2]6×8 0u300−u3000u2−u10000−w2w1 8×4=[0w2u3−w1u30w1u2−w2u1−w2u1w1u2]6×4