[详细教程]ubuntu16.04安装ORB-SLAM与ORB-SLAM2
⼀、ORB-SLAM介绍
ORB-SLAM是⼀种多功能且精确的单⽬SLAM解决⽅案,能够实时计算摄像机轨迹,并在各种环境下稀疏地重建场景,从⼩型⼿持序列到在⼏个城市街区⾏驶的汽车。它能够关闭⼤的循环,并从宽基线实时执⾏全局重新定位。
项⽬主页:
⼆、准备
1.boost库开始多线程
sudo apt-get install libboost-all-dev
2.安装ROS
参考链接:1. 2.
3.安装opencv
4.g2o (included in Thirdparty)
源码链接:
这个源码⾥就有,不⽤额外下载,不过为了顺利安装成功,需要提前运⾏如下程序
sudo apt-get install libeigen3-dev//版本最低3.1.0
5. DBoW2 (included in Thirdparty)
源码链接:,同样不需要额外下载,看⼀下就好。
三、安装
1.确认已经安装好所有的依赖:ROS,boost, eigen3, opencv, blas, lapack
2.克隆ORB-SLAM源码
git clone github/raulmur/ORB_SLAM.git ORB_SLAM
3.将当前ORB-SLAM的路径添加到bashrc中.获取ORB-SLAM⽂件夹的路径
sudo gedit ~/.bashrc //打开bashrc⽂件
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/ning/1.software/ORB_SLAM //加⼊ORB-SLAM⽂件夹的路径,注:这⾥应替换成⾃⼰电脑上的ORB-SLAM⽂件夹的路径
source ~/.bashrc
4.Build g2o。cd Thirdparty/g2o/
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
5.Build DBoW2. Go into Thirdparty/DBoW2/ and execute:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
6.Build ORB_SLAM. In the ORB_SLAM root execute:
mkdir build
cd build
cmake .. -DROS_BUILD_TYPE=Release
make
编译报错1:
ning@ning:~/1.software/ORB_SLAM/build$ cmake .. -DCMAKE_BUILD_TYPE=Release
[rosbuild] Building package ORB_SLAM
Failed to invoke /opt/ros/kinetic/bin/rospack deps-manifests ORB_SLAM
[rospack] Error: package 'ORB_SLAM' depends on non-existent package 'opencv2' and rosdep claims that it is not a system dependency. Check the ROS_ PACKAGE_PATH or try calling 'rosdep update'
CMake Error at /opt/ros/kinetic/share/ros/core/ake:129 (message):
Failed to invoke rospack to get compile flags for package 'ORB_SLAM'. Look
above for errors from rospack itself. Aborting. Please fix the broken
dependency!
Call Stack (most recent call first):
/opt/ros/kinetic/share/ros/core/ake:207 (rosbuild_invoke_rospack)
<:4 (rosbuild_init)
-- Configuring incomplete, errors occurred!
See also "/home/ning/1.software/ORB_SLAM/build/CMakeFiles/CMakeOutput.log".
解决办法1:
打开/l⽂件,注释掉<depend package="opencv2"/>,最终的l⽂件如下:
<package>
<description brief="ORB_SLAM">
ORB_SLAM
</description>
<author>Raul Mur-Artal</author>
<license>GPLv3</license>
<depend package="roscpp"/>
<depend package="tf"/>
<depend package="sensor_msgs"/>
<!--<depend package="opencv2"/>-->
<depend package="image_transport"/>
<depend package="cv_bridge"/>
</package>
编译报错2:
ubuntu安装教程/home/ning/1.software/ORB_SLAM/: In member function ‘void ORB_SLAM::ORBextractor::ComputeKeyPoints(std::vector<std::vector<c v::KeyPoint> >&)’:
/home/ning/1.software/ORB_SLAM/:607:63: error: ‘FAST’ was not declared in this scope
FAST(cellImage,cellKeyPoints[i][j],fastTh,true);
^
/home/ning/1.software/ORB_SLAM/:616:34: error: ‘ORB’ has not been declared
if( scoreType == ORB::HARRIS_SCORE )
^
/home/ning/1.software/ORB_SLAM/:683:17: error: ‘KeyPointsFilter’ has not been declared
KeyPointsFilter::retainBest(keysCell,nToRetain[i][j]);
^
/home/ning/1.software/ORB_SLAM/:699:13: error: ‘KeyPointsFilter’ has not been declared
KeyPointsFilter::retainBest(keypoints,nDesiredFeatures);
^
/home/ning/1.software/ORB_SLAM/: In member function ‘void ORB_SLAM::ORBextractor::operator()(cv::InputArray, cv::InputArray, std ::vector<cv::KeyPoint>&, cv::OutputArray)’:
/home/ning/1.software/ORB_SLAM/:760:82: error: ‘GaussianBlur’ was not declared in this scope
GaussianBlur(workingMat, workingMat, Size(7, 7), 2, 2, BORDER_REFLECT_101);
^
/home/ning/1.software/ORB_SLAM/: In member function ‘void ORB_SLAM::ORBextractor::ComputePyramid(cv::Mat, cv::Mat)’:
/home/ning/1.software/ORB_SLAM/:800:78: error: ‘INTER_LINEAR’ was not declared in this scope
resize(mvImagePyramid[level-1], mvImagePyramid[level], sz, 0, 0, INTER_LINEAR);
^
/home/ning/1.software/ORB_SLAM/:800:90: error: ‘resize’ was not declared in this scope
resize(mvImagePyramid[level-1], mvImagePyramid[level], sz, 0, 0, INTER_LINEAR);
^
/home/ning/1.software/ORB_SLAM/:803:80: error: ‘INTER_NEAREST’ was not declared in this scope
resize(mvMaskPyramid[level-1], mvMaskPyramid[level], sz, 0, 0, INTER_NEAREST);
^
CMakeFiles/ORB_SLAM.dir/build.make:443: recipe for target 'CMakeFiles/ORB_SLAM.dir/' failed
make[2]: *** [CMakeFiles/ORB_SLAM.dir/] Error 1
make[2]: *** Waiting for
CMakeFiles/Makefile2:227: recipe for target 'CMakeFiles/ORB_SLAM.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
解决办法2:
打开/ORB_SLAM/include/ORBextractor.h⽂件,添加以下两个头⽂件
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
编译报错3:
/usr/local/include/eigen3/Eigen/src/Core/util/StaticAssert.h:125:9: error: ‘YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAS T_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY’ is not a member of ‘Eigen::internal::static_assertion<false>’
if (Eigen::internal::static_assertion<static_cast<bool>(CONDITION)>::MSG) {}
解决办法3:
是eigen库版本的问题,更换eigen版本之前需要先清理⼀下电脑上原本的eigen3库(查看eigen版本:打
开/usr/include/eigen3/Eigen/src/Core/util/Macros.h ⽂件即可看到定义)
sudo mv /usr/include/eigen3 /temp/usr_include/eigen3
sudo mv /usr/local/include/eigen3 /temp/usr_local_include/eigen3//后⾯的路径可以⾃⼰随便定义
访问,
下载libeigen3-dev_3.2.0-8_all.deb⽂件,执⾏
sudo dpkg -i libeigen3-dev_3.2.0-8_all.deb
编译报错4:
/usr/bin/ld: CMakeFiles/ORB_SLAM.dir/: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: error addin
g symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/ORB_SLAM.dir/build.make:1609: recipe for target '../bin/ORB_SLAM' failed
make[2]: *** [../bin/ORB_SLAM] Error 1
CMakeFiles/Makefile2:324: recipe for target 'CMakeFiles/ORB_SLAM.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2
解决办法4:
是因为程序在编译时没到boost依赖的库,打开终端定位boost_filesystem与boost_system两个库的位置
ning@ning:~/1.software/ORB_SLAM/build$ locate boost_filesystem
/usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.58.0
ning@ning:~/1.software/ORB_SLAM/build$ locate boost_system
/usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0
打开/ORB_⽂件,在最底部target_link_libraries中加⼊上⾯两个库的路径,变成
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${EIGEN3_LIBS}
${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so
/usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0
/usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.58.0
)
重新编译,成功!
四、测试
1.解压⽂件
cd /ORB_SLAM
tar -ar.gz //解压
…
参考进⾏测试
⼆、
发布评论