高博大神《一起做RGB-D SLAM (6)》问题总结

本人小白,初学slam,在尝试跑高博大神(嘤嘤嘤,可崇拜了)《一起做RGB-D SLAM 》系列6时,现将本人遇到的问题及解决总结如下,如有不当之处,感谢指出!

1g2o 安装

本人的平台为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

下载并安装g2o

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

g2o_viewer 无法链接到 libqglviewer.so解决办法

(1)/etc/ld.so.conf.d/目录下添加一个g2o.config文件,把/usr/local/lib复制进去

(2)sudo ldconfig更新动态链接库

2g2o版本导致编译有问题

(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 >::BlockSolver(SlamLinearSolver*&)’
     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(std::unique_ptr) [with Traits = g2o::BlockSolverTraits<6, 3>; typename Traits::LinearSolverType = g2o::LinearSolver >]
 BlockSolver::BlockSolver(std::unique_ptr linearSolver)

发现在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(linearSolver));
  g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( std::unique_ptr(BlockSolver) );

再次编译,咦,居然通过了,嘿嘿

贴出最后的结果图

高博大神《一起做RGB-D SLAM (6)》问题总结_第1张图片

 

参考链接:https://blog.csdn.net/n66040927/article/details/79316185

https://blog.csdn.net/LOVE1055259415/article/details/79877368

 

 

 

 

 

 

 

你可能感兴趣的:(rgbd_salm)