ORB_SLAM2在ubuntu16.04上的安装测试
一、下载ORB_SLAM2源码
git clone https://github.com/raulmur/ORB_SLAM2.git
参考功能包的说明,在编译之前需要安装相应依赖包:
sudo apt-get install libboost-all-dev libblas-dev liblapack-dev
二、安装Pangolin库
1、安装依赖
sudo apt-get install libpython2.7-dev
2、下载Pangolin库
git clone https://github.com/stevenlovegrove/Pangolin.git
3、源码编译
mkdir build
cd build
cmake ..
make
sudo make install
如果执行cmake ..指令出现错误:Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE),执行如下指令后重新编译:
sudo apt-get install doxygen
三、安装OpenCV3.2.0以及eigen3
安装方法:进入文件根目录,执行:
mkdir build
cd build
cmake ..
make
sudo make install
四、ORB_SLAM2安装
1、编译ORB_SLAM2包,进入ORB_SLAM2根目录,执行:
chmod +x build.sh
./build.sh
编译过程可能会报错:ORB_SLAM2/src/System.cc: error: ‘usleep’ was not declared in this scope usleep(5000),这是因为system.h文件中缺少一个头文件,打开ORB_SLAM2/include/system.h文件,然后在头文件处添加:#include <unistd.h>
再次进行编译,应该可以顺利通过。
2、编译ORB_SLAM2的ROS功能包
在编译ROS功能包之前,在终端设置ORB_SLAM2功能包的路径,最好将配置文件放入终端配置文件中:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:ORB_SLAM_PATH/ORB_SLAM2/Examples/ROS
其中ORB_SLAM_PATH是ORB_SLAM2功能包的所在路径
根据个人文件位置,本文所用指令为:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/oay/application/ORB_SLAM2/Examples/ROS
执行如下编译命令:
chmod +x build_ros.sh
./build_ros.sh
可能出现的错误:
CMakeFiles/Stereo.dir/build.make:227:recipe for target '../Stereo' failed
,CMakeFiles/RGBD.dir/build.make:197: recipe for target ‘…/RGBD’ failed
,CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/RGBD.dir/all' failed
,CMakeFiles/Makefile2:104:recipe for target 'CMakeFiles/Stereo.dir/all' failed
解决方法:修改ORB_SLAM2/Examples/ROS/ORB_SLAM2/路径下的CMakeLists.txt文件,在set(LIBS......最后部分加入-lboost_system),如下图所示:
再次编译,一般可以通过
3、设置环境变量
source /home/oay/application/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/devel/setup.bash
最好可以将其加入到~/.bashrc中,以便在所有终端都可以使用该环境变量
echo "source /home/oay/application/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/devel/setup.bash" >> ~/.bashrc
安装完成,接下来运用自己搭建的仿真环境进行测试。
五、仿真环境下测试
仿真环境下所用为RGB-D深度相机,因此执行:
rosrun ORB_SLAM2 RGBD Vocabulary/ORBvoc.txt Examples/ROS/ORB_SLAM2/Asus.yaml
可能会出现错误(段错误,核心已转储):
Depth Threshold (Close/Far Points): 2.98842
terminate called after throwing an instance of 'std::runtime_error'
what(): Pangolin X11: Unable to retrieve framebuffer options
Aborted (core dumped)
解决方法:
对Pangolin包里面的Pangolin/src/display/device/display_x11.cpp文件如下两行进行注释:
然后重新对Pangolin包进行编译和安装,再次运行ORB_SLAM2即可。
运行效果如下图所示:
参考自: https://blog.csdn.net/weixin_45168199/article/details/107106811