ORB_SLAM2安装

时间:2023-03-10 00:32:03
ORB_SLAM2安装

进入工程目录,我们发现有两个sh文件,一个是build.sh另一个是build_ros.sh

这两个都可以进行ORB_SLAM2的安装,我们先来看一下build.sh

 echo "Configuring and building Thirdparty/DBoW2 ..."

 cd Thirdparty/DBoW2
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j cd ../../g2o echo "Configuring and building Thirdparty/g2o ..." mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j cd ../../../ echo "Uncompress vocabulary ..." cd Vocabulary
tar -xf ORBvoc.txt.tar.gz
cd .. echo "Configuring and building ORB_SLAM2 ..." mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j

我们通过查看orb_slam的代码框架可以知道,有2个lib库需要我们编译。一个是DBoW2,另一个是g2o,按照上面的指示可以分别将lib库编译完成。

解压ORBvoc.txt.tar.gz,然后在工程目录下建立build,然后编译,便可以成功。

但是第一次编译,由于没有安装一些依赖,可能会出现以下问题:

 //若第一次编译,可能得到以下错误
CMake Error at CMakeLists.txt: (find_package):
By not providing "FindPangolin.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Pangolin",
but CMake did not find one. Could not find a package configuration file provided by "Pangolin" with any
of the following names: PangolinConfig.cmake
pangolin-config.cmake Add the installation prefix of "Pangolin" to CMAKE_PREFIX_PATH or set
"Pangolin_DIR" to a directory containing one of the above files. If
"Pangolin" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/home/leonsun/backup/orb_slam2/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
//没有安装Pangolin

解决方法如下:

 //到home目录
mkdir Software
cd Software
//下载Pangolin并且编译
git https://github.com/stevenlovegrove/Pangolin.git
//右键提取到此处解压Pangolin文件
cd Pangolin
mkdir build
cd build
cmake ..

但是得到以下错误

 -- The C compiler identification is GNU 5.4.
-- The CXX compiler identification is GNU 5.4.
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Build type not set (defaults to release)
-DCMAKE_BUILD_TYPE=Debug for debug
CMake Error at CMakeModules/FindGLEW.cmake: (MESSAGE):
Could not find GLEW
Call Stack (most recent call first):
src/CMakeLists.txt: (find_package)

没有安装GLEW,利用apt-get进行安装

sudo apt-get install libglew-dev

重新编译Pangolin,成功。然后按照上部分提供的官网教程进行编译

接着我们来看一下build_ros.sh

 echo "Building ROS nodes"

 cd Examples/ROS/ORB_SLAM2
mkdir build
cd build
cmake .. -DROS_BUILD_TYPE=Release
make -j

官方给的教程就是运行这个文件进行编译。也可以进行成功编译。

ORB_SLAM2安装