两个orbslam2_modified中make报错但网上很难找到直接答案的问题:
在build过程中Optimizer.cc出现类似下述开头的no matching function for call to错误:
no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<6
是因为g2o新版本更新了函数的参数列表,而仓库中的代码维持稳定,没有做相应更新。其实这个问题在视觉SLAM十四讲里也有出现。
解决方案:根据报错提示,应该用std::unique_ptr<pointer type> ()来改变作为参数的5处solver_ptr和5处linearSolver(可用“solver_ptr)”和“linearSolver)”为关键字ctrl+F搜索),具体而言:
(1). 第60行修改为:
g2o::BlockSolver_6_3 * solver_ptr = new g2o::BlockSolver_6_3(std::unique_ptr<g2o::BlockSolver_6_3::LinearSolverType>(linearSolver));
第62行修改为:
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg(std::unique_ptr<g2o::BlockSolver_6_3> (solver_ptr));
(2).第246行改为:
g2o::BlockSolver_6_3 * solver_ptr = new g2o::BlockSolver_6_3(std::unique_ptr<g2o::BlockSolver_6_3::LinearSolverType>(linearSolver));
第248行改为:
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg(std::unique_ptr<g2o::BlockSolver_6_3> (solver_ptr));
(3).第512行改为:
g2o::BlockSolver_6_3 * solver_ptr = new g2o::BlockSolver_6_3(std::unique_ptr<g2o::BlockSolver_6_3::LinearSolverType>(linearSolver));
第514行改为:
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg(std::unique_ptr<g2o::BlockSolver_6_3> (solver_ptr));
(4).第791行改为:
g2o::BlockSolver_7_3 * solver_ptr= new g2o::BlockSolver_7_3(std::unique_ptr<g2o::BlockSolver_7_3::LinearSolverType>(linearSolver));
第792行改为:
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg(std::unique_ptr<g2o::BlockSolver_7_3> (solver_ptr));
(5).第1053行改为:
g2o::BlockSolverX * solver_ptr = new g2o::BlockSolverX(std::unique_ptr<g2o::BlockSolverX::LinearSolverType>(linearSolver));
第1055行改为:
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg(std::unique_ptr<g2o::BlockSolverX> (solver_ptr));
原因是pangolin 0.6版本太高,具体原因不明,欢迎大神科普TvT。解决方案:
方法一:重装pangolin到0.5版本
ubuntu18.04跑orbslam2时编译出现找不到-lEigen3::Eigen_kbfvictory的博客-CSDN博客
方法二:由于有其他软件要用高版本的pangolin,笔者无法降低pangolin版本。在bing上搜到一个外网的解决方案:将CMakeLists.txt的第39行
find_package(Eigen3 3.1.0 REQUIRED)
改为:
find_package(Eigen3 3.1.0 REQUIRED NO_MODULE)
最后测试可以运行OvO