本人小白,初学slam,在尝试跑高博大神(嘤嘤嘤,可崇拜了)《一起做RGB-D SLAM 》系列6时,现将本人遇到的问题及解决总结如下,如有不当之处,感谢指出!
本人的平台为ubuntu14.04
(1)sudo rm -rf /usr/local/include/g2o
(2)cd /usr/local/lib
(3)sudo rm -rf libg2o_*
sudo apt-get install cmake libeigen3-dev libsuitesparse-dev libqt4-dev qt4-qmake libqglviewer-dev
https://codeload.github.com/RainerKuemmerle/g2o/zip/dbfea7aade1b808b4a7625175aa0dec54931a949
qt4版本的(良心推荐使用)
https://github.com/RainerKuemmerle/g2o
qt5版本(即使编译成功,最后使用g2o_viewer result_after.g2o会出现段错误,慎用)
cd g2o
mkdir build&&cd build
cmake ..
make
sudo make install
(1)/etc/ld.so.conf.d/目录下添加一个g2o.config文件,把/usr/local/lib复制进去
(2)sudo ldconfig更新动态链接库
(1)出现C++有关的编译问题,请在CMakeLists.txt添加
SET( CMAKE_CXX_FLAGS "-std=c++11 -O3")
(2)出现无frameID 的问题请在include/slamBase.h文件的FRAME帧结构中添加
int frameID;
(3)使用最新版本的g2o(链接2)在初始化求解器时出现不到函数或者函数参数匹配有问题,如下:
In function ‘int main(int, char**)’:/slamEnd.cpp:68:70: error: no matching function for call to ‘g2o::BlockSolver
SlamBlockSolver* blockSolver = new SlamBlockSolver( linearSolver );
^
/home/wanggang/slam/src/slamEnd.cpp:68:70: note: candidate is:
In file included from /usr/local/include/g2o/core/block_solver.h:199:0,
from /home/wanggang/slam/src/slamEnd.cpp:17:
/usr/local/include/g2o/core/block_solver.hpp:40:1: note: g2o::BlockSolver
BlockSolver
发现在salmEnd.cpp中的初始化求解器与/usr/local/include/g2o/core/block_solver.hpp中定义的不同(嘿嘿,不要问我怎么知道的,俺是小白,请参考https://blog.csdn.net/robinhjwy/article/details/78084210)
于是乎,模仿这改呗,将salmEnd.cpp中的代码
SlamBlockSolver* blockSolver = new SlamBlockSolver( linearSolver );
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( blockSolver );
改为
SlamBlockSolver* BlockSolver = new SlamBlockSolver(std::unique_ptr
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( std::unique_ptr
再次编译,咦,居然通过了,嘿嘿
贴出最后的结果图
参考链接:https://blog.csdn.net/n66040927/article/details/79316185
https://blog.csdn.net/LOVE1055259415/article/details/79877368