進入工程目錄,我們發現有兩個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
官方給的教程就是運行這個文件進行編譯。也可以進行成功編譯。