进入工程目录,我们发现有两个sh文件,一个是build.sh另一个是build_ros.sh。
这两个都可以进行ORB_SLAM2的安装,我们先来看一下build.sh
1 echo "Configuring and building Thirdparty/DBoW2 ..." 2 3 cd Thirdparty/DBoW2 4 mkdir build 5 cd build 6 cmake .. -DCMAKE_BUILD_TYPE=Release 7 make -j 8 9 cd ../../g2o 10 11 echo "Configuring and building Thirdparty/g2o ..." 12 13 mkdir build 14 cd build 15 cmake .. -DCMAKE_BUILD_TYPE=Release 16 make -j 17 18 cd ../../../ 19 20 echo "Uncompress vocabulary ..." 21 22 cd Vocabulary 23 tar -xf ORBvoc.txt.tar.gz 24 cd .. 25 26 echo "Configuring and building ORB_SLAM2 ..." 27 28 mkdir build 29 cd build 30 cmake .. -DCMAKE_BUILD_TYPE=Release 31 make -j
我们通过查看orb_slam的代码框架可以知道,有2个lib库需要我们编译。一个是DBoW2,另一个是g2o,按照上面的指示可以分别将lib库编译完成。
解压ORBvoc.txt.tar.gz,然后在工程目录下建立build,然后编译,便可以成功。
但是第一次编译,由于没有安装一些依赖,可能会出现以下问题:
1 //若第一次编译,可能得到以下错误 2 CMake Error at CMakeLists.txt:40 (find_package): 3 By not providing "FindPangolin.cmake" in CMAKE_MODULE_PATH this project has 4 asked CMake to find a package configuration file provided by "Pangolin", 5 but CMake did not find one. 6 7 Could not find a package configuration file provided by "Pangolin" with any 8 of the following names: 9 10 PangolinConfig.cmake 11 pangolin-config.cmake 12 13 Add the installation prefix of "Pangolin" to CMAKE_PREFIX_PATH or set 14 "Pangolin_DIR" to a directory containing one of the above files. If 15 "Pangolin" provides a separate development package or SDK, be sure it has 16 been installed. 19 -- Configuring incomplete, errors occurred! 20 See also "/home/leonsun/backup/orb_slam2/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log". 21 //没有安装Pangolin
解决方法如下:
1 //到home目录 2 mkdir Software 3 cd Software 4 //下载Pangolin并且编译 5 git https://github.com/stevenlovegrove/Pangolin.git 6 //右键提取到此处解压Pangolin文件 7 cd Pangolin 8 mkdir build 9 cd build 10 cmake ..
但是得到以下错误
1 -- The C compiler identification is GNU 5.4.0 2 -- The CXX compiler identification is GNU 5.4.0 3 -- Check for working C compiler: /usr/bin/cc 4 -- Check for working C compiler: /usr/bin/cc -- works 5 -- Detecting C compiler ABI info 6 -- Detecting C compiler ABI info - done 7 -- Detecting C compile features 8 -- Detecting C compile features - done 9 -- Check for working CXX compiler: /usr/bin/c++ 10 -- Check for working CXX compiler: /usr/bin/c++ -- works 11 -- Detecting CXX compiler ABI info 12 -- Detecting CXX compiler ABI info - done 13 -- Detecting CXX compile features 14 -- Detecting CXX compile features - done 15 Build type not set (defaults to release) 16 -DCMAKE_BUILD_TYPE=Debug for debug 17 CMake Error at CMakeModules/FindGLEW.cmake:51 (MESSAGE): 18 Could not find GLEW 19 Call Stack (most recent call first): 20 src/CMakeLists.txt:122 (find_package)
没有安装GLEW,利用apt-get进行安装
1 sudo apt-get install libglew-dev
重新编译Pangolin,成功。然后按照上部分提供的官网教程进行编译
接着我们来看一下build_ros.sh
1 echo "Building ROS nodes" 2 3 cd Examples/ROS/ORB_SLAM2 4 mkdir build 5 cd build 6 cmake .. -DROS_BUILD_TYPE=Release 7 make -j
官方给的教程就是运行这个文件进行编译。也可以进行成功编译。