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



Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐