视觉SLAM第2讲|初识SLAM:经典框架、传感器选型与工程环境全梳理
第1讲我们过完了预备知识的自测题,从这一讲开始正式进入SLAM的世界。如果说SLAM是一座技术大厦,第2讲就是先给你画一张总平面图:告诉你SLAM到底是干什么的,有哪些主流传感器方案,一个完整的SLAM系统由哪几个模块组成,以及做SLAM开发需要搭建什么样的编程环境。
一、SLAM到底是什么?
SLAM是 Simultaneous Localization and Mapping 的缩写,中文叫同时定位与地图构建 。
说人话就是:一个搭载传感器的机器人,在完全陌生的环境里,一边移动一边摸清周围环境的结构,同时搞清楚自己此刻在什么位置。
这件事听着很自然------人走进陌生房间,走两圈也就知道房间布局和自己在哪了。但对计算机来说,这是个非常经典的难题:你没有地图就没法定位,你定位不准又建不准地图,两个问题互相耦合,和我们之前讲的"鸡生蛋还是蛋生鸡"是一个逻辑。
传感器的两大路线
要完成SLAM,首先得有传感器。按照是不是依赖环境布置,我们可以分成两类:
- 环境布置式 :比如地面导轨、二维码地标、GPS定位。
优点是直接读位置,简单稳定;缺点是必须先改造环境,未知场景用不了,不具备通用性。 - 本体携带式 :相机、激光雷达、IMU惯性单元、轮式编码器。
传感器装在机器人身上,不要求环境做任何改造,未知场景也能工作。这才是SLAM研究的核心,也是视觉SLAM的主战场。
💡通俗解释:前者就像商场里贴了地贴的指引机器人,沿着地带走就行;后者就像探险者,全靠自己的眼睛和感知探路,适用面广得多,但技术难度也大得多。
三类视觉传感器对比
视觉SLAM,核心传感器就是相机。常见的有三类,各有优劣:
| 类型 | 核心原理 | 优点 | 核心短板 |
|---|---|---|---|
| 单目相机 | 单个摄像头成像 | 结构简单、成本极低、场景不限 | 单张图无深度,必须运动才能估计深度;存在尺度不确定性 |
| 双目相机 | 左右双摄,靠视差算深度 | 直接输出真实尺度,被动成像,室内外都能用 | 基线短,远距离精度差;视差计算量大 |
| RGB-D相机 | 主动发射红外光,飞行时间/结构光测深度 | 直接出像素级深度,不用算法算视差 | 测量距离近、易受日光干扰,大多仅限室内 |
这里重点说下单目最经典的尺度不确定性 :
单目相机只能通过像素的相对大小判断远近,没法知道真实尺寸。你把整个场景和相机运动同时放大2倍,单目相机看到的图像是完全一样的。所以单目SLAM的轨迹和地图,天然就差一个未知的尺度因子,必须靠其他方式(比如IMU、已知尺寸的物体)来标定真实尺度。
💡通俗解释:就像你看一张风景照,你没法知道照片里的山是真的千米高山,还是桌上的模型山。单目SLAM就是这个感觉,只能算出相对形状,真实大小是飘的。
二、经典视觉SLAM框架:五大模块
一个完整的视觉SLAM系统,拆解开就是标准的五层结构,从前往后依次是:传感器读取、视觉里程计、后端优化、回环检测、建图。
1. 传感器信息读取
最前端的输入层,负责读取相机图像、IMU数据、轮速里程计数据,做时间戳对齐和预处理。
别小看这一步,实际工程里多传感器时间同步没做好,后面的算法再强也白搭。
2. 视觉里程计(VO,前端)
视觉里程计的任务是:估算相邻两帧图像之间相机的运动,恢复局部的三维结构 。
比如第k帧和第k+1帧,通过特征匹配或者直接法,算出这两帧之间相机转了多少、平移了多少。
💡通俗解释:就像你蒙眼走路,一步一步数自己迈了多远、转了多少度。优点是快,能实时输出;缺点是每一步都有一点点误差,走的步数多了,误差累积起来,轨迹就会慢慢飘走,这就是漂移。
3. 后端优化
后端接收前端传过来的所有时刻的相机位姿,再加上回环检测的约束,做全局的优化,得到一条全局一致的轨迹和地图。
如果说前端是"走一步算一步",后端就是"把所有步放在一起,算一个全局最优解"。
💡通俗解释:相当于你走完一段路之后,把所有步数的误差重新匀一匀,让整体的偏差最小。早期SLAM的研究几乎全在后端,从卡尔曼滤波到后来的图优化,都是后端的核心技术。
4. 回环检测
回环检测专门解决漂移问题:判断机器人是不是回到了之前曾经来过的地方。
如果检测到"哦这个地方我来过",就往后端里加一条约束:这两个时刻其实是同一个位置。后端根据这个约束,把整条轨迹"拉"回来,就能消除累积的漂移。
💡通俗解释:就像你逛街的时候,突然看到了之前来过的便利店,立刻就反应过来"我到这了",之前走歪的路线一下就纠正了。回环检测是消除累积误差最关键的手段。
5. 建图
最后一步,根据估计出来的相机轨迹,构建任务需要的地图。
地图不是只有一种,按需构建:
- 稀疏地图:只要路标特征点,用来定位就行,量小速度快;
- 稠密地图:重建所有看到的表面,用来导航避障、可视化;
- 拓扑地图:只记录地点和连通关系,不关心精确坐标,用来路径规划。
三、SLAM问题的数学表述
讲完直观框架,我们用数学语言把SLAM问题抽象一下,后面所有算法都是在解这个问题。
两个核心方程
我们把离散时刻k的机器人位姿记为xkx_kxk,地图里的路标点记为yjy_jyj。整个SLAM过程就由两个方程描述:
- 运动方程 :k时刻的位姿,等于上一时刻位姿经过运动输入之后的结果,再加上噪声。
描述机器人是怎么运动的。 - 观测方程 :k时刻相机看到了第j个路标点,得到的观测值,等于路标点投影到相机的结果,再加上观测噪声。
描述相机是怎么看到环境的。
状态估计问题
SLAM本质上就是个状态估计问题 :已知运动输入和观测数据,反过来估计机器人的位姿和地图坐标。
求解思路主要分两派:
- 增量式(滤波器) :来一帧数据就更新一次当前状态,只保留当前时刻的估计。代表是扩展卡尔曼滤波EKF。
优点是快、内存小;缺点是累积误差,适合早期算力弱的场景。 - 批量式(图优化) :把一段时间所有数据攒起来,一起优化出全局最优的结果。代表是基于图的非线性优化。
优点是精度高、效果好;缺点是计算量更大。现在视觉SLAM的主流方案就是图优化。
💡通俗解释:增量式像边走路边算账,走一步记一笔,快但容易算错;批量式像月底统一对账,算得准但要攒数据。实际工程里大多用滑动窗口折中:保留最近N帧优化,老的固定住,兼顾精度和速度。
四、实践:SLAM开发环境怎么搭?
理论最终要落地到代码。第2讲的实践部分,就是把SLAM开发的基础工程环境搭起来。
1. 为什么选Linux
SLAM领域的核心库(Eigen、OpenCV、Ceres、g2o、Sophus),对Linux的支持都是最好的,安装配置简单,编译运行顺畅。
主流发行版选Ubuntu就行,对新手友好,软件源全。
2. 编译基础:g++编译器
C++源码是文本文件,需要编译器编译成可执行文件才能运行。Linux下最常用的就是g++。
最简单的编译命令:
bash
g++ helloSLAM.cpp
编译完生成a.out可执行文件,直接运行即可。
3. CMake:工程管理工具
小工程一两文件可以手动敲g++,文件多了、有第三方库依赖了,就必须用工程管理工具。CMake就是SLAM领域最通用的工程管理工具。
标准的CMake编译流程:
bash
mkdir build # 建一个编译中间目录
cd build
cmake .. # 对上一层源码做配置,生成Makefile
make # 编译整个工程
💡通俗解释:g++是单个文件的编译器,CMake是整个工程的大管家。它帮你管哪些文件要编译、依赖哪些库、链接顺序是什么,不用你自己手动敲几十条编译命令。
库的概念
代码除了直接编译成可执行文件,还可以打包成库:
- 静态库.a:调用的时候直接复制进程序里,程序体积大,不用依赖外部库文件;
- 共享库.so:程序运行的时候再加载,多个程序可以共用,省内存。
调用一个库,需要两样东西:头文件 (声明函数长什么样)和库文件(编译好的二进制实现)。链接的时候把两者对应上,程序就能调用库函数了。
4. IDE选择
纯文本写代码效率太低,工程开发推荐用IDE。Linux下常用两个:
- KDevelop:免费开源,原生支持CMake工程,基础的代码跳转、断点调试都有,新手入门够用。
- Clion:JetBrains出品,功能全面体验好,收费,学生可以用教育邮箱免费申请。
IDE最有用的功能就是断点调试:打个断点,程序跑到这就停下,能看每个变量的值,单步运行看逻辑怎么走,排错效率比打印日志高太多。
五、知识体系全景
#mermaid-svg-txJNr2CdahVTAgBb{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-txJNr2CdahVTAgBb .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-txJNr2CdahVTAgBb .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-txJNr2CdahVTAgBb .error-icon{fill:#552222;}#mermaid-svg-txJNr2CdahVTAgBb .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-txJNr2CdahVTAgBb .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-txJNr2CdahVTAgBb .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-txJNr2CdahVTAgBb .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-txJNr2CdahVTAgBb .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-txJNr2CdahVTAgBb .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-txJNr2CdahVTAgBb .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-txJNr2CdahVTAgBb .marker{fill:#333333;stroke:#333333;}#mermaid-svg-txJNr2CdahVTAgBb .marker.cross{stroke:#333333;}#mermaid-svg-txJNr2CdahVTAgBb svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-txJNr2CdahVTAgBb p{margin:0;}#mermaid-svg-txJNr2CdahVTAgBb .edge{stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .section--1 rect,#mermaid-svg-txJNr2CdahVTAgBb .section--1 path,#mermaid-svg-txJNr2CdahVTAgBb .section--1 circle,#mermaid-svg-txJNr2CdahVTAgBb .section--1 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section--1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section--1 text{fill:#ffffff;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon--1{font-size:40px;color:#ffffff;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge--1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth--1{stroke-width:17;}#mermaid-svg-txJNr2CdahVTAgBb .section--1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-0 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-0 path,#mermaid-svg-txJNr2CdahVTAgBb .section-0 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-0 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-txJNr2CdahVTAgBb .section-0 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-0{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-0{stroke-width:14;}#mermaid-svg-txJNr2CdahVTAgBb .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-1 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-1 path,#mermaid-svg-txJNr2CdahVTAgBb .section-1 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-1 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-1 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-1{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-1{stroke-width:11;}#mermaid-svg-txJNr2CdahVTAgBb .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-2 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-2 path,#mermaid-svg-txJNr2CdahVTAgBb .section-2 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-2 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-2 text{fill:#ffffff;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-2{stroke-width:8;}#mermaid-svg-txJNr2CdahVTAgBb .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-3 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-3 path,#mermaid-svg-txJNr2CdahVTAgBb .section-3 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-3 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-3 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-3{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-3{stroke-width:5;}#mermaid-svg-txJNr2CdahVTAgBb .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-4 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-4 path,#mermaid-svg-txJNr2CdahVTAgBb .section-4 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-4 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-4 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-4{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-4{stroke-width:2;}#mermaid-svg-txJNr2CdahVTAgBb .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-5 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-5 path,#mermaid-svg-txJNr2CdahVTAgBb .section-5 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-5 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-5 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-5{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-5{stroke-width:-1;}#mermaid-svg-txJNr2CdahVTAgBb .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-6 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-6 path,#mermaid-svg-txJNr2CdahVTAgBb .section-6 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-6 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-6 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-6{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-6{stroke-width:-4;}#mermaid-svg-txJNr2CdahVTAgBb .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-7 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-7 path,#mermaid-svg-txJNr2CdahVTAgBb .section-7 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-7 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-7 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-7{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-7{stroke-width:-7;}#mermaid-svg-txJNr2CdahVTAgBb .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-8 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-8 path,#mermaid-svg-txJNr2CdahVTAgBb .section-8 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-8 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-8 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-8{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-8{stroke-width:-10;}#mermaid-svg-txJNr2CdahVTAgBb .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-9 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-9 path,#mermaid-svg-txJNr2CdahVTAgBb .section-9 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-9 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-9 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-9{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-9{stroke-width:-13;}#mermaid-svg-txJNr2CdahVTAgBb .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-10 rect,#mermaid-svg-txJNr2CdahVTAgBb .section-10 path,#mermaid-svg-txJNr2CdahVTAgBb .section-10 circle,#mermaid-svg-txJNr2CdahVTAgBb .section-10 polygon,#mermaid-svg-txJNr2CdahVTAgBb .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-10 text{fill:black;}#mermaid-svg-txJNr2CdahVTAgBb .node-icon-10{font-size:40px;color:black;}#mermaid-svg-txJNr2CdahVTAgBb .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .edge-depth-10{stroke-width:-16;}#mermaid-svg-txJNr2CdahVTAgBb .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-txJNr2CdahVTAgBb .disabled,#mermaid-svg-txJNr2CdahVTAgBb .disabled circle,#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:lightgray;}#mermaid-svg-txJNr2CdahVTAgBb .disabled text{fill:#efefef;}#mermaid-svg-txJNr2CdahVTAgBb .section-root rect,#mermaid-svg-txJNr2CdahVTAgBb .section-root path,#mermaid-svg-txJNr2CdahVTAgBb .section-root circle,#mermaid-svg-txJNr2CdahVTAgBb .section-root polygon{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-txJNr2CdahVTAgBb .section-root text{fill:#ffffff;}#mermaid-svg-txJNr2CdahVTAgBb .section-root span{color:#ffffff;}#mermaid-svg-txJNr2CdahVTAgBb .section-2 span{color:#ffffff;}#mermaid-svg-txJNr2CdahVTAgBb .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-txJNr2CdahVTAgBb .edge{fill:none;}#mermaid-svg-txJNr2CdahVTAgBb .mindmap-node-label{dy:1em;alignment-baseline:middle;text-anchor:middle;dominant-baseline:middle;text-align:center;}#mermaid-svg-txJNr2CdahVTAgBb :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 初识SLAM
核心概念
定义 同时定位与地图构建
本质 位姿与地图耦合估计
核心难点 累积漂移
传感器体系
环境布置式 GPS 二维码 导轨
本体携带式 相机 激光雷达 IMU
视觉传感器
单目相机 尺度不确定性
双目相机 基线视差测深度
RGB-D相机 主动光测深度
经典框架
传感器数据读取 时间同步
视觉里程计 前端
相邻帧运动估计
局部地图恢复
存在累积漂移
后端优化
全局状态优化
最小化整体误差
回环检测
场景重识别
消除累积漂移
建图模块
稀疏点云地图
稠密重建地图
拓扑连通地图
数学表述
运动方程 位姿传递
观测方程 投影模型
状态估计
增量式 卡尔曼滤波
批量式 图优化
工程实践
系统 Ubuntu Linux
编译器 g++
工程管理 CMake
build外编译
静态库 共享库
开发IDE
KDevelop 免费开源
Clion 专业级
小结
第2讲是整个视觉SLAM的总纲,先把骨架搭起来:从传感器到前端、后端、回环、建图,再到数学抽象和工程环境。
后面的第3讲到第6讲,都是在打基础:三维刚体运动、李群李代数、相机模型、非线性优化。把这些数学工具掌握了,再去学后面的视觉里程计、后端优化,就会顺理成章,知道自己在学哪一块、解决的是什么问题。