本文内容均默认使用右手定则,且旋转向量在局部坐标系中表达(即右乘)

  • 代码实现

1. 旋转表示

1.1 旋转向量

  • \(\boldsymbol{\phi} = \phi \boldsymbol{n}\)表示绕着单位轴\(\boldsymbol{n}\)旋转\(\phi\)弧度,用\(\boldsymbol{\omega}\)表示旋转角速率

1.2 旋转矩阵

  • 旋转行为: \[ \boldsymbol{x}^{'} = \boldsymbol{R}\boldsymbol{x} \tag{1} \]

  • 约束: \[ \boldsymbol{R}\boldsymbol{R}^\mathrm{T} = \boldsymbol{R}^\mathrm{T}\boldsymbol{R} = \boldsymbol{I}, \quad det(\boldsymbol{R}) = 1 \tag{2} \]

  • 微分: \[ \dot{\boldsymbol{R}}=\boldsymbol{R}\boldsymbol{\omega}^{\wedge} \tag{3} \]

1.3 四元数

  • 表示: \[ \boldsymbol{q}=[s, \boldsymbol{v}]^{\mathrm{T}}, \quad s=q_w \in \mathbb{R}, \quad \boldsymbol{v}=\left[q_x, q_y, q_z\right]^{\mathrm{T}} \in \mathbb{R}^3 \tag{4} \]

    只有单位四元数才能表示旋转

  • 四元数乘法: \[ \mathbf{q}_a \otimes \mathbf{q}_b =\left[\begin{array}{c} s_a s_b-\mathbf{v}_a^{\top} \mathbf{v}_b \\ s_a \mathbf{v}_b+s_b \mathbf{v}_a+\mathbf{v}_a \times \mathbf{v}_b \end{array}\right] \tag{5} \]

    !!!四元数乘法不满足乘法结合律

  • 旋转行为: \[ \boldsymbol{x}^{'} = \boldsymbol{q} \otimes \boldsymbol{x} \otimes \boldsymbol{q}^* \tag{6} \]

  • 约束: \[ \mathbf{q} \otimes \mathbf{q}^* = \mathbf{q}^* \otimes \mathbf{q} =1 \tag{7} \]

  • 微分: \[ \dot{\mathbf{q}}=\frac{1}{2} \mathbf{q} \otimes \boldsymbol{\omega} \tag{8} \]

2. 旋转转换

2.1 旋转向量与旋转矩阵

2.1.1 从旋转向量转换到旋转矩阵的转换

\[ \begin{aligned} \boldsymbol{R} &=\exp \left(\boldsymbol{\phi}^{\wedge}\right) = \sum_{n=0}^{\infty} \frac{1}{n!}\left(\boldsymbol{\phi}^{\wedge}\right)^n \approx \boldsymbol{I}+\boldsymbol{\phi}^{\wedge} \\ &= \exp \left(\phi \boldsymbol{n}^{\wedge}\right) = \cos \phi \boldsymbol{I}+(1-\cos \phi)\boldsymbol{n}\boldsymbol{n}^{\mathrm{T}}+\sin \phi \boldsymbol{n}^{\wedge} \end{aligned} \tag{9} \]

式(9)的第二行即罗德里格斯公式

2.1.2 从旋转矩阵转换到旋转向量的转换

\[ \begin{aligned} \phi & =\arccos \frac{\operatorname{tr}(\boldsymbol{R})-1}{2} \\ \boldsymbol{n} & =\frac{\left(\boldsymbol{R}-\boldsymbol{R}^{\top}\right)^{\vee}}{2 \sin \phi} \end{aligned} \tag{10} \]

2.2 旋转向量与四元数

2.2.1 从旋转向量到四元数的转换

\(\boldsymbol{\phi}\)转换为纯四元数(pure quaternion),则有 \[ \boldsymbol{q} = exp(\frac{\boldsymbol{\phi}}{2}) = \left[\begin{array}{c} \cos \frac{\phi}{2} \\ \boldsymbol{n} \sin \frac{\phi}{2} \end{array}\right] \approx \left[\begin{array}{c} 1 \\ \frac{1}{2}\boldsymbol{\phi} \end{array}\right] \tag{11} \]

上式中存在\(\boldsymbol{\phi}\)到纯四元数(pure quaternion)的隐含转换

2.2.2 从四元数到旋转向量的转换

\[ \begin{aligned} \phi & =2 \arctan \left(||\boldsymbol{v}||, s \right) \\ \boldsymbol{n} & =\frac{\boldsymbol{v}}{ ||\boldsymbol{v}||} \end{aligned} \tag{12} \]

2.3 旋转矩阵与四元数

2.3.1 从旋转矩阵到四元数的转换

\[ \left\{ \begin{aligned} q_w = sign(q_w) \frac{1}{2} \sqrt{1+r_{11}+r_{22} + r_{33}} \\ q_x = sign(q_x) \frac{1}{2} \sqrt{1+r_{11}-r_{22} - r_{33}} \\ q_y = sign(q_y) \frac{1}{2} \sqrt{1-r_{11}+r_{22} - r_{33}} \\ q_z = sign(q_z) \frac{1}{2} \sqrt{1-r_{11}-r_{22} + r_{33}} \\ \end{aligned} \right. \tag{13} \]

2.3.2 从四元数到旋转矩阵的转换

\[ \boldsymbol{R}=\left(s^2-\boldsymbol{v}^{\mathrm{T}} \boldsymbol{v}\right) \boldsymbol{I}+2 \boldsymbol{v} \boldsymbol{v}^{\mathrm{T}}+2 s \boldsymbol{v}^{\wedge} \tag{14} \]

3. 旋转更新

  • 在优化姿态时,通常计算一个旋转向量增量\(\delta \boldsymbol{\phi}\),再用它更新当前的估计值\(\mathbf{R} \leftarrow \mathbf{R} \exp \left(\boldsymbol{\delta \boldsymbol{\phi}}^{\wedge}\right)\)\(\mathbf{q} \leftarrow \mathbf{q} \otimes exp(\frac{\boldsymbol{\delta\phi}}{2})\)

参考文献

  1. 《视觉SLAM十四讲》
  2. Sola J. Quaternion kinematics for the error-state Kalman filter[J]. arXiv preprint arXiv:1711.02508, 2017.
  3. 《机器人学中的状态估计》
  4. 《多旋翼飞行器设计与控制》
  5. 深蓝学院《从零手写VIO》课程

奇异值分解求解线性方程组

奇异值分解(SVD)

\(\boldsymbol{A} \in \mathbb{C}^{m \times n}_r\),则存在正交矩阵\(\boldsymbol{U} \in \mathbb{C}^{m \times m}\)与正交矩阵\(\boldsymbol{V} \in \mathbb{C}^{n \times n}\)使得\(\boldsymbol{A} = \boldsymbol{U} \left[ \begin{matrix} \boldsymbol{\Sigma}_r & \boldsymbol{0} \\ \boldsymbol{0} & \boldsymbol{0} \end{matrix}\right] \boldsymbol{V}^T = \boldsymbol{U} \boldsymbol{D} \boldsymbol{V}^T\),其中\(\boldsymbol{\Sigma_r}= diag(\sigma_1,...,\sigma_r)\)是矩阵\(\boldsymbol{A}\)的正奇异值

  • 通过奇异值分解将原问题转换为最小二乘问题,可以求解超定线性方程组

1 求解齐次线性方程组(\(\boldsymbol{A}\boldsymbol{x}= \boldsymbol{0}\)

问题等价于\(\min _{\boldsymbol{x}}|| \boldsymbol{A}\boldsymbol{x}||^2\),则 $$ \[\begin{aligned} & \min _{\boldsymbol{x}}|| \boldsymbol{A}\boldsymbol{x}||^2 \\ = & \min _{\boldsymbol{x}} || \boldsymbol{U} \boldsymbol{D} \boldsymbol{V}^T \boldsymbol{x}||^2 \\ = & \min _{\boldsymbol{x}} || \boldsymbol{D} \boldsymbol{V}^T \boldsymbol{x}||^2 \\ \end{aligned} \tag{1}\]

$$ 令\(\boldsymbol{y} = \boldsymbol{V}^T \boldsymbol{x}\),则\((1)\)式变为\(\min _{\boldsymbol{y}} || \boldsymbol{D} \boldsymbol{y} ||^2 = \min _{\boldsymbol{y}}\left(\sigma_1^2y_1^2 + \sigma_2^2y_2^2 + ... + \sigma_r^2y_r^2\right)\),其中\(r <= n\)

因为\(\sigma_1 > \sigma_2 > ... > \sigma_r > 0\),所有不管\(r\)是否等于\(n\),在\(|| \boldsymbol{x} ||= 1\)的前提下的最优解均在\(\boldsymbol{y}= [0,0,...,1]^T\)时取得(\(r=n\)时存在最小二乘解,\(r<n\)时存在数值解),此时\(\boldsymbol{x} = \boldsymbol{V}\boldsymbol{y}\) ,即\(\boldsymbol{V}\)的最后一列

2 求解非齐次线性方程组(\(\boldsymbol{A}\boldsymbol{x}= \boldsymbol{b}\)

问题等价于\(\min _{\boldsymbol{x}} || \boldsymbol{A}\boldsymbol{x}-\boldsymbol{b}||^2\),则 \[ \begin{aligned} & \min _{\boldsymbol{x}}|| \boldsymbol{A}\boldsymbol{x}-\boldsymbol{b}||^2 \\ = & \min _{\boldsymbol{x}} || \boldsymbol{U} \boldsymbol{D} \boldsymbol{V}^T \boldsymbol{x} -\boldsymbol{b} ||^2 \\ = & \min _{\boldsymbol{x}} || \boldsymbol{D} \boldsymbol{V}^T \boldsymbol{x} -\boldsymbol{U}^T\boldsymbol{b} ||^2 \\ \end{aligned} \tag{2} \]\(\boldsymbol{y} = \boldsymbol{V}^T \boldsymbol{x}\)\(\boldsymbol{c} = \boldsymbol{U}^T \boldsymbol{b}\),则\((2)\)式变为\(\min _{\boldsymbol{y}} || \boldsymbol{D} \boldsymbol{y} - \boldsymbol{c}||^2 = \min _{\boldsymbol{y}}\left( \sum_{i=1}^r(\sigma_i y_i - c_i)^2+\sum_{i=r+1}^m c_i^2 \right)\)

\(y_i = \frac{c_i}{\sigma_i}(i = 1,...,r)\)\(y_i(i=r+1,...,n)\)为任意值时求得最优解

参考文献

  1. 王磊.矩阵基本理论与应用[M]
  2. https://blog.csdn.net/Ansel_Lee/article/details/107643789
  3. https://blog.csdn.net/MyArrow/article/details/53780972


本质矩阵\(\boldsymbol{E} = \boldsymbol{t}^{\land} \boldsymbol{R}\)的奇异值必定是\([\sigma, \ \sigma, \ 0]^{T}\)的形式,这称为本质矩阵的内在性质

证明过程

\(\because \boldsymbol{E}=\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T\)

$ ^T = ^T ( T)T = TT =^T $

\(\because\boldsymbol{E}\boldsymbol{E}^T = \boldsymbol{t}^{\land} \boldsymbol{R}(\boldsymbol{t}^{\land} \boldsymbol{R})^T = \boldsymbol{t}^{\land} \boldsymbol{R} \boldsymbol{R}^T \boldsymbol{t}^{\land T} = \boldsymbol{t}^{\land} \boldsymbol{t}^{\land T} =\left[\begin{matrix}0 & -t_z & t_y \\t_z & 0 & -t_x \\ -t_y & t_x & 0 \end{matrix} \right] \left[\begin{matrix}0 & t_z & -t_y \\ -t_z & 0 & t_x \\ t_y & -t_x & 0 \end{matrix} \right]\)

考虑到\(\boldsymbol{E}\)的尺度等价性(\(\boldsymbol{E}\)只有5个自由度),将\(\boldsymbol{t}= [t_x \ t_y \ t_z]^T\)归一化为单位矢量,即\(t_x^2 + t_y^2 + t_z^2 = 1\)

那么可由\(\left|\lambda \boldsymbol{I} - \boldsymbol{E}\boldsymbol{E}^T \right| = 0\)求取\(\boldsymbol{E}\boldsymbol{E}^T\)的特征值

行列式展开得\(\lambda(\lambda-1)^2= 0\),即\(\boldsymbol{M} = diag(\lambda_1, \lambda_2, \lambda_3) = diag(1, 1, 0)\)

\(\because \boldsymbol{M} = \boldsymbol{\Sigma} \boldsymbol{\Sigma}^T\)

\(\therefore \boldsymbol{\Sigma} = diag(1, 1, 0)\)

得证

  • PS:《计算机视觉中的多视图几何》第九章也给出了证明,但需要更强的数学基础

参考文献

  1. https://blog.csdn.net/zengxyuyu/article/details/106676509
  2. 《视觉SLAM十四讲》第二版
  3. 《计算机视觉中的多视图几何》第二版


Abstract

  • 作者提出了一种半直接单目视觉里程计算法,该算法精确、鲁棒,并且比当前最先进的方法更快
    • 该算法无需代价昂贵的特征提取和鲁棒匹配技术
    • 该算法直接对像素强度进行操作,在高帧率下可以达到亚像素精度
    • 使用显式建模异常测量的概率建图方法来估计3D点,从而得到更少的异常点和更可靠的点
    • 精确的高帧率运动估计在纹理较少、重复和高频的场景中具有更高的鲁棒性
  • 该算法应用于GPS拒止环境下的微型飞行器状态估计,在机载嵌入式计算机上以55帧/秒的速度运行,在消费级笔记本电脑上以超过300帧/秒的速度运行
  • 该算法称为SVO (Semi-direct Visual Odometry),并将软件实现开源
阅读全文 »

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

0%