高翔 视觉SLAM十四讲从理论到实践 第六讲g2o make失败的解决方法

1.将 CMakeLists.txt 中的 C++ 标准设置为 C++17

CMakeLists.txt 中添加下面几行

# 设置 C++ 标准为 C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

2.修改g2oCurveFitting.cpp 中g2o::make_unique

90 91行

auto solver = new g2o::OptimizationAlgorithmGaussNewton(
   g2o::make_unique<BlockSolverType>(g2o::make_unique<LinearSolverType>()));

将 g2o::make_unique改成std::make_unique

auto solver = new g2o::OptimizationAlgorithmGaussNewton(
     std::make_unique<BlockSolverType>(std::make_unique<LinearSolverType>()));

编译成功,跑个结果


start optimization
iteration= 0	 chi2= 376785.128234	 time= 4.3018e-05	 cumTime= 4.3018e-05	 edges= 100	 schur= 0
iteration= 1	 chi2= 35673.566018	 time= 8.17001e-06	 cumTime= 5.1188e-05	 edges= 100	 schur= 0
iteration= 2	 chi2= 2195.012304	 time= 7.76901e-06	 cumTime= 5.8957e-05	 edges= 100	 schur= 0
iteration= 3	 chi2= 174.853126	 time= 6.524e-06	 cumTime= 6.5481e-05	 edges= 100	 schur= 0
iteration= 4	 chi2= 102.779695	 time= 8.976e-06	 cumTime= 7.4457e-05	 edges= 100	 schur= 0
iteration= 5	 chi2= 101.937194	 time= 9.49e-06	 cumTime= 8.3947e-05	 edges= 100	 schur= 0
iteration= 6	 chi2= 101.937020	 time= 8.905e-06	 cumTime= 9.2852e-05	 edges= 100	 schur= 0
iteration= 7	 chi2= 101.937020	 time= 6.552e-06	 cumTime= 9.9404e-05	 edges= 100	 schur= 0
iteration= 8	 chi2= 101.937020	 time= 7.327e-06	 cumTime= 0.000106731	 edges= 100	 schur= 0
iteration= 9	 chi2= 101.937020	 time= 6.707e-06	 cumTime= 0.000113438	 edges= 100	 schur= 0
solve time cost = 0.00123968 seconds. 
estimated model: 0.890912   2.1719 0.943629



  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值