SLAM系列——ORB_SLAM2

  • Post author:
  • Post category:其他




系列文章目录



SLAM系列——第一讲 预备知识[2023.1]



SLAM系列——第二讲 初识SLAM[2023.1]



SLAM系列——第三讲 三维空间刚体运动[2023.1]



SLAM系列——第四讲 李群李代数[2023.1]



SLAM系列——第五讲 相机与图像[2023.1]



SLAM系列——第六讲 非线性优化[2023.1]



SLAM系列——第七讲 视觉里程计1[2023.1]



SLAM系列——第八讲 视觉里程计2[2023.1]



SLAM系列——第九讲 后端1[2023.1]



SLAM系列——第十讲 后端2[2023.1]



SLAM系列——第十一讲 回环检测[2023.1]



SLAM系列——第十二讲 建图[2023.1]



SLAM系列——第十三讲 实践:设计SLAM系统[2023.1]



SLAM系列——第十四讲 SLAM:现在与未来[2023.1]



SLAM系列——g2o



SLAM系列——ORB_SLAM2





1. Prerequisites

  1. Pangolin
cd ~/your_fav_code_directory
git clone --recursive https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin

# See what package manager and packages are recommended
./scripts/install_prerequisites.sh --dry-run recommended

# Install dependencies (as described above, or your preferred method)
./scripts/install_prerequisites.sh recommended

# Configure and build
cmake -B build
cmake --build build

# with Ninja for faster builds (sudo apt install ninja-build)
cmake -B build -GNinja
cmake --build build

# GIVEME THE PYTHON STUFF!!!! (Check the output to verify selected python version)
cmake --build build -t pypangolin_pip_install

# Run me some tests! (Requires Catch2 which must be manually installed on Ubuntu.)
ctest

sudo make install



Build ORB_SLAM2

bash build.sh

踩坑:

  1. ORB-SLAM2编译时报错‘usleep’ was not declared in this scope

    解决方法:在LocalMapping.cc, System.cc, Tracking.cc, LoopClosing.cc, Viewer.cc, stereo_euroc.cc, rgbd_tum.cc, mono_tum.cc, mono_kitti.cc, stereo_kitti.cc, mono_euroc.cc文件中加入#include <unistd.h>

  2. ORB-SLAM2编译时报错error: ‘slots_reference’ was not declared in this scope

    解决方法:将./CMakeLists.txt和./Examples/ROS/ORB_SLAM2/CMakeLists.txt文件中的 c++11 替换为 c++14

  3. ORB-SLAM2编译时报错:

CMake Error at CMakeLists.txt:40 (find_package):
  Found package configuration file:

    /usr/local/lib/cmake/Pangolin/PangolinConfig.cmake

  but it set Pangolin_FOUND to FALSE so package "Pangolin" is considered to
  be NOT FOUND.  Reason given by package:

  Pangolin could not be found because dependency Eigen3 could not be found.

解决方法:

不需要重新安装Pangolin及Eigen,修改CMakeLists.txt如下:

在find_package(Eigen3 REQUIRED)后加NO_MUDULE,

find_package(Eigen3 REQUIRED NO_MODULE)
  1. ORB-SLAM2编译时报错(gcc-9、g++-9):
/home/moke/code/ORB_SLAM2/src/Optimizer.cc:818:37:   required from here
/usr/include/c++/9/bits/stl_map.h:122:71: error: static assertion failed: std::map must have the same value_type as its allocator
  122 |       static_assert(is_same<typename _Alloc::value_type, value_type>::value,
      |                                                                       ^~~~~
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/build.make:102: CMakeFiles/ORB_SLAM2.dir/src/LoopClosing.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/build.make:219: CMakeFiles/ORB_SLAM2.dir/src/Optimizer.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:250: CMakeFiles/ORB_SLAM2.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

解决方法:

1.降级至gcc-7、g++-7

2.修改LoopClosing.h

将51行代码

    typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
        Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;

修改为:

    typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
        Eigen::aligned_allocator<std::pair<KeyFrame* const, g2o::Sim3> > > KeyFrameAndPose;
  1. ORB-SLAM2编译时报错()
/home/moke/code/ml14m22z_ORB_SLAM2/Examples/Monocular/mono_euroc.cc: In function ‘int main(int, char**)’:
/home/moke/code/ml14m22z_ORB_SLAM2/Examples/Monocular/mono_euroc.cc:86:22: error: ‘std::chrono::monotonic_clock’ has not been declared
   86 |         std::chrono::monotonic_clock::time_point t1 = std::chrono::monotonic_clock::now();
      |                      ^~~~~~~~~~~~~~~
/home/moke/code/ml14m22z_ORB_SLAM2/Examples/Monocular/mono_euroc.cc:95:22: error: ‘std::chrono::monotonic_clock’ has not been declared
   95 |         std::chrono::monotonic_clock::time_point t2 = std::chrono::monotonic_clock::now();
      |                      ^~~~~~~~~~~~~~~



版权声明:本文为zmkzmkok原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。