1.对于cs.h找不到的情况
1)编译的时候一定要把csparse在EXTERNAL文件中,编译进去。
2)修改CMakeLists.txt文件中的include_directories中的${CPARSE_INCLUDE_DIR},在DIR后面不能加上S。
2.编译报错,如下
error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<6, 3> >::BlockSolver(std::remove_reference<g2o::LinearSolver<Eigen::Matrix<double, 6, 6, 0> >*&>::type)’
std::unique_ptr<Block> solver_ptr (new Block ( std::move(linearSolver )));
参考http://www.cnblogs.com/xueyuanaichiyu/p/7921382.html,应该把响应内容更改为
typedef g2o::BlockSolver< g2o::BlockSolverTraits<6,3> > Block; // pose 维度为 6, landmark 维度为 3 Block::LinearSolverType* linearSolver = new g2o::LinearSolverCSparse<Block::PoseMatrixType>(); // 线性方程求解器 Block* solver_ptr = new Block ( std::unique_ptr<Block::LinearSolverType>(linearSolver )); // 矩阵块求解器 g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( std::unique_ptr<Block>(solver_ptr )); g2o::SparseOptimizer optimizer; optimizer.setAlgorithm ( solver );