使用G2O库遇到的问题
1. 问题:target_compile_features specified unknown feature “cxx_std_14” for target "core" 解决方案:cmake版本需要3.3以上,我选择3.3.15cmake通过
cmake地址:https:
执行 :
tar xvf cmake-3.15.0.tar.gz
找到cmake文件并卸载
不能直接sudo apt remove --purge cmake
locate cmake
之后进行:
./configure
make -j8
sudo make install
cmake --version
2.问题:error: ‘index_sequence’ is not a member of 'std’ 解决方法:所以需要把CMakeLists.txt文件中改为C++14编译。
将
set( CMAKE_CXX_FLAGS "-std=c++11" )
改成
set( CMAKE_CXX_FLAGS "-std=c++14" )
3.问题 error: ‘VertexSBAPointXYZ’ is not a member of ‘g2o’ 解决方案:
新版g2o库中不再存在原先的VertexSBAPointXYZ,将所有报错的地方改为VertexPointXYZ即可:
或者是
g2o 20200410_git版本也可以解决,该版本使用VertexSBAPointXYZ这个
https:
4.问题 usr/local/include/g2o/core/base_fixed_sized_edge.hpp:166:14: error: ‘FixedArray {aka class ceres::internal::FixedArray<double, 6>}’ has no member named ‘fill’ add_vertex.fill(0.); /usr/local/include/g2o/core/base_fixed_sized_edge.hpp:173:30: error: ‘FixedArray {aka class ceres::internal::FixedArray<double, 6>}’ has no member named ‘data’ vertex->oplus(add_vertex.data());
解决方案:因为新版本不兼容问题,需要将g2o版本换成 20200410_git版本,
https:
- 问题 DSO missing的原因基本上是因为有库没有连接上,导致未识别。最保险的方法是在最前端将所有库设置为G2O_LIBS:还有所用到的头文件名称
头名称:
#include <g2o/types/sba/types_sba.h>
#include <g2o/core/base_vertex.h>
#include <g2o/core/base_unary_edge.h>
#include <g2o/core/block_solver.h>
#include <g2o/core/optimization_algorithm_levenberg.h>
#include <g2o/core/optimization_algorithm_dogleg.h>
#include <g2o/solvers/dense/linear_solver_dense.h>
#include <g2o/solvers/eigen/linear_solver_eigen.h>
#include <g2o/solvers/csparse/linear_solver_csparse.h>
#include <g2o/core/robust_kernel_impl.h>
#include <g2o/core/sparse_optimizer.h>
#include <g2o/core/factory.h>
#include <g2o/core/hyper_graph.h>
#include <sophus/se3.hpp>
#include <g2o/types/slam3d/se3quat.h>
#include <g2o/types/sba/types_six_dof_expmap.h>
cmakelist.txt
include(cmake/FindG2O.cmake)
include(cmake/FindCSparse.cmake)
include_directories(
cmake
${OpenCV_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${Sophus_INCLUDE_DIRS}
${CSPARSE_INCLUDE_DIR}
)
target_link_libraries(project_name #工程名称
${catkin_LIBRARIES}
${OpenCV_LIBS} fmt
${EIGEN3_LIBS}
${EIGEN_DEFINITIONS}
${Sophus_LIBRARIES}
g2o_core g2o_stuff g2o_types_sba g2o_csparse_extension g2o_types_slam3d
${CSPARSE_LIB}
)
|