使用的源码是http://github.com/electech6/ORB_SLAM2_detailed_comments
系统是ubuntu 20.04
在cmake的时候遇到pangolin版本不对的问题,
具体报错:
Build type: Release
-- Using flag -std=c++11.
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.
-- Configuring incomplete, errors occurred!
Makefile:911: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
————————————————
把pangolin版本回退到0.5版本。
首先清理原有的pangolin版本
在终端输入
locate pangolin
使用以下命令删除 Pangolin 的安装目录,通常位于 `/usr/local` 或 `/usr/include`:
sudo rm -rf /usr/local/include/pangolin
sudo rm -rf /usr/local/lib/libpangolin
卸载完毕后安装0.5版本,在
https://github.com/stevenlovegrove/Pangolin.git
里面选择0.5版本,不过ubuntu20.04安装0.5版本时会编译报错
具体参考博客:视觉SLAM十四讲 Ubuntu20.04 Pangolin 环境配置-优快云博客
安装完成后在编译时会报一段错误:
/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,
| ^~~~~
解决办法是在LoopClosing.h中修改
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;
至此编译成功。
参考博客:(总结)编译ORB_SLAM2遇到的错误_error: no match for call to ‘(pcl::getfieldindex(c-优快云博客