https://blog.csdn.net/weixin_53660567/article/details/119823955?spm=1001.2014.3001.5501
在这片帖子里我已经介绍了相应的步骤,过程都是一样的,但是我在Ubuntu20.04编译的时候出现了两个错误,Ubuntu18.04没有出现:
在编译ORB_SLAM2的时候:
./build.sh
在进行到这一个步骤时候:
(1)error1:
error: ‘usleep’ was not declared in this scope
解决办法:
将system.h头文件修改,加入下面的代码
#include<unistd.h>
(2)error2:
error: template argument 1 is invalid
50 | Eigen::aligned_allocator<std::pair<const KeyFrame* g2o::Sim3> > > KeyFrameAndPose;
| ^
/home/liqiang/Downloads/ORB_SLAM2/include/LoopClosing.h:50:73: error: template argument 4 is invalid
50 | Eigen::aligned_allocator<std::pair<const KeyFrame* g2o::Sim3> > > KeyFrameAndPose;
| ^
/home/liqiang/Downloads/ORB_SLAM2/src/Optimizer.cc: In static member function ‘static void ORB_SLAM2::Optimizer::OptimizeEssentialGraph(ORB_SLAM2::Map*, ORB_SLAM2::KeyFrame*, ORB_SLAM2::KeyFrame*, const KeyFrameAndPose&, const KeyFrameAndPose&, const std::map<ORB_SLAM2::KeyFrame*, std::set<ORB_SLAM2::KeyFrame*> >&, const bool&)’:
/home/liqiang/Downloads/ORB_SLAM2/src/Optimizer.cc:818:54: error: qualified-id in declaration before ‘it’
818 | LoopClosing::KeyFrameAndPose::const_iterator it = CorrectedSim3.find(pKF);
| ^~
/home/liqiang/Downloads/ORB_SLAM2/src/Optimizer.cc:820:12: error: ‘it’ was not declared in this scope; did you mean ‘i’?
820 | if(it!=CorrectedSim3.end())
| ^~
| i
解决办法:
将LoopClosing.h文件里的代码做一点小小的修改:
将文件改成下面一样的问题就能解决了
在Ubuntu20.04上编译的效果如下所示: