文章目录
前言
同时定位与建图
提示:以下是本篇文章正文内容,下面案例可供参考
一、ORB-SLAM2是什么?
ORB-SLAM2 is a real-time SLAM library for Monocular, Stereo and RGB-D cameras that computes the camera trajectory and a sparse 3D reconstruction (in the stereo and RGB-D case with true scale). It is able to detect loops and relocalize the camera in real time. We provide examples to run the SLAM system in the KITTI dataset as stereo or monocular, in the TUM dataset as RGB-D or monocular, and in the EuRoC dataset as stereo or monocular. We also provide a ROS node to process live monocular, stereo or RGB-D streams. The library can be compiled without ROS.
ORB-SLAM2是一个实时SLAM库,用于单目,立体声和RGB-D相机,计算相机轨迹和稀疏3D重建(在立体声和RGB-D情况下的真实规模)。它能够检测循环和重新定位摄像机实时。我们提供了一些例子来运行SLAM系统在KITTI数据集作为立体或单目,在TUM数据集作为RGB-D或单目,在EuRoC数据集作为立体或单目。我们还提供一个ROS节点来处理实时单目、立体声或RGB-D流。这个库可以在没有ROS的情况下编译。
二、安装步骤
1.下载orb-slam2源码
代码如下(示例):
git clone https://github.com/raulmur/ORB_SLAM2.git
2.安装三个库
2.1 安装Pangolin
下载Pangolin源码(示例):
git clone https://github.com/raulmur/ORB_SLAM2.git//我执行这句总是超时,于是把源码放在了我的github上,可以执行下面这句
git clone https://github.com/rickkcir/Pangolin.git
安装Pangolin的依赖包(示例):
- C++11
- OpenGL
sudo apt install libgl1-mesa-dev
- Glew CMake (forbuild environment)
sudo apt install cmake
编译
cd Pangolin
mkdir build
cd build
cmake ..
make
源码github上最后一句用cmake --build .替换掉了make,效果是一样的。
2.2 安装DBOW2、g2o库
这两个库在ORB_SLAM2/Thirdparty/目录下,不需要额外下载,编译时会在./build.sh中自动安装。
3.编译ORB-SLAM2
在orb-slam2目录下:
chmod +x build.sh
./build.sh
4.下载TUM数据集
下载官网:TUM数据集
准备测试单目,下面是源码官网给的数据集解释:
- Execute the following command. Change TUMX.yaml to
TUM1.yaml,TUM2.yaml or TUM3.yaml for freiburg1, freiburg2 and
freiburg3 sequences respectively. Change PATH_TO_SEQUENCE_FOLDERto
the uncompressed sequence folder.
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUMX.yaml PATH_TO_SEQUENCE_FOLDER
意思是:TUM1.yaml对应数据集freiburg1(fr1)、TUM2.yaml对应数据集freiburg2(fr2)、TUM3.yaml对应数据集freiburg3(fr3),本实验下载fr1/360,对应TUM1.yaml文件
点击"more info"后,下载tgz压缩包文件
5.单目测试
在做测试之前,把第4步下载的数据集解压后放在ORB-SLAM2目录下(数据集可以放在任意目录,为方便本文放在了ORB-SLAM2目录下),进入ORB-SLAM2目录后打开终端执行下面这条命令
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml rgbd_dataset_freiburg1_360/
ORB-SLAM2运行成功视频