Ubuntu16.04 编译和运行ORBSLAM3
代码链接:https://github.com/UZ-SLAMLab/ORB_SLAM3
(很建议先翻墙下载好,因为这个代码有足足313M)
论文链接:ORB-SLAM3: An Accurate Open-Source Library
for Visual, Visual-Inertial and Multi-Map SLAM
如果之前有编译过ORBSLAM1和ORBSLAM2,编译这个应该不会有太大的问题,不过我编译的过程遇到几个小小的坑
本文结构:
- 依赖库安装
- 编译
- 运行
1.依赖库安装
1.Pangolin:
https://github.com/stevenlovegrove/Pangolin
2.opencv:
http://opencv.org
这里网上有很多安装教程,不加以累赘。GitHub里作者要求必须是3.0以上的版本。在我的系统里面Cmake是直接找到了我ROS里面的opencv
-- Found OpenCV: /opt/ros/kinetic (found suitable version "3.3.1", minimum required is "3")
OPENCV VERSION:
3.3.1
3.Eigen3:
http://eigen.tuxfamily.org
这里要求最低版本是3.1.0。我用的是3.2.92。
这里有一些坑,后面再说。如果想查看自己的Eigen版本可以进/usr/include/eigen3/Eigen/src/Core/util/Macros.h(我自己的路径),以下代表版本是:3.2.92
#define EIGEN_WORLD_VERSION 3
#define EIGEN_MAJOR_VERSION 2
#define EIGEN_MINOR_VERSION 92
4.DBoW2 and g2o
5.python:
要求是2.7,用到里面的numpy模型
可以直接:sudo apt install libpython2.7-dev
2.编译
找一个文件夹
git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git ORB_SLAM3
(最好先翻墙下载)
cd ORB_SLAM3
chmod +x build.sh
./build.sh
如果可以直接成功那是最好,不过一般不会吧。。。
一般会报错提示找不到Eigen:
CMake Error at CMakeLists.txt:72 (FIND_PACKAGE):
Could not find a configuration file for package "Eigen3" that is compatible
with requested version "3.1.0".
The following configuration files were considered but not accepted:
/usr/lib/cmake/eigen3/Eigen3Config.cmake, version: unknown
如果编译过ORBSLAM2的朋友会发现3的根目录里少了cmake_modules文件夹,但在ORBSLAM3的cmake文件里面也确实保留着这句话:
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
这是帮助代码找到Eigen位置的配置文件,所以我就到了ORBSLAM2里面把它下到根目录里面:
https://github.com/raulmur/ORB_SLAM2/tree/master/cmake_modules
再一次编译:
chmod +x build.sh
./build.sh
我还是会报这两个错误:
CMake Error at CMakeLists.txt:72 (FIND_PACKAGE):
Could not find a configuration file for package "Eigen3" that is compatible
with requested version "3.1.0".
The following configuration files were considered but not accepted:
/usr/lib/cmake/eigen3/Eigen3Config.cmake, version: unknown
make[2]: *** No rule to make target '../Thirdparty/g2o/lib/libg2o.so', needed by '../lib/libORB_SLAM3.so'。 停止。
然后编译奔溃:
CMakeFiles/Makefile2:400: recipe for target 'CMakeFiles/ORB_SLAM3.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM3.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
但是,这时候再编译一次,就可以成功了
./build.sh
3.运行
这里我尝试的是EuRoC MAV 数据集。(注意,下载的是压缩文件ASL Dataset Format而不是rosbag),我下的MH_05数据包。
然后在根目录终端下:
单目+imu:
./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml ../dataset/MH_05 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/MH05.txt
双目+imu:
./Examples/Stereo-Inertial/stereo_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo-Inertial/EuRoC.yaml ../dataset/MH_05 ./Examples/Stereo-Inertial/EuRoC_TimeStamps/MH05.txt
注意,这里我dataset的位置是和ORBSLAM3文件夹在同一个目录下的,然后MH_05里面还有一个mav0文件夹。
运行效果如下:
说真的,界面效果感觉比vins-mono更加流畅和标准,效果目前不清楚,准备进一步读论文了。接下来要好好深入了解啦!!
第一次写博客,比较粗糙,请大家多多包涵!