ubuntu16.04 g2o更新出现的问题解决

1.卸载并安装g2o

1)卸载

sudo rm -rf /usr/local/include/g2o
sudo rm -rf /usr/local/lib/libg2o*

rm -rf build
rm -rf bin

2)安装 

sudo apt-get install 
- libeigen3-dev 
- libsuitesparse-dev 
- libqt4-dev 
- qt4-qmake 
- libqglviewer-qt4-dev

sudo apt-get install libqglviewer-dev


git clone https://github.com/RainerKuemmerle/g2o/
git log |grep 8ba8a*
git checkout 8ba8a03f7863e1011e3270bb73c8ed9383ccc2a2
sudo apt-get install libqt4-dev
sudo apt-get install qt4-qmake
sudo apt-get install libqglviewer-dev
mkdir build
cd build
cmake ../
make 
sudo make install

2)解决更新安装g2o后问题

/*
    //BlockSolverX::LinearSolverType * linearSolver = new LinearSolverCSparse<BlockSolverX::PoseMatrixType>();


    // create the block solver on the top of the linear solver
    BlockSolverX* blockSolver = new BlockSolverX(linearSolver);
    
    //create the algorithm to carry out the optimization
    OptimizationAlgorithmLevenberg* optimizationAlgorithm = new OptimizationAlgorithmLevenberg(blockSolver);
*/



// 初始化g2o
    typedef g2o::BlockSolver< g2o::BlockSolverTraits<6,3> > Block;  // pose 维度为 6, landmark 维度为 3

    //Block::LinearSolverType* linearSolver = new g2o::LinearSolverCSparse<Block::PoseMatrixType>(); // 线性方程求解器
    std::unique_ptr<Block::LinearSolverType> linearSolver ( new g2o::LinearSolverCSparse<Block::PoseMatrixType>());

    //Block* solver_ptr = new Block ( linearSolver );
    //std::unique_ptr<Block> solver_ptr ( new Block ( linearSolver));
    std::unique_ptr<Block> solver_ptr ( new Block ( std::move(linearSolver)));     // 矩阵块求解器

// 梯度下降方法,从GN, LM, DogLeg 中选
g2o::OptimizationAlgorithmLevenberg* optimizationAlgorithm = new g2o::OptimizationAlgorithmLevenberg ( std::move(solver_ptr));

参考

1.https://blog.csdn.net/ktigerhero3/article/details/75457432

2.https://blog.csdn.net/weixin_38358435/article/details/79082733

3.https://blog.csdn.net/robinhjwy/article/details/78084210

4.http://www.voidcn.com/article/p-pzgxibai-km.html

猜你喜欢

转载自blog.csdn.net/weixin_39752599/article/details/82907340