《视觉SLAM十四讲》第一版源码slambook编译调试

本文详细记录了《视觉SLAM十四讲》书中各章节实践代码在不同项目中的编译问题及解决方案,包括错误原因分析和修复步骤,涉及SLAM、g2o、ceres、opencv等库的版本兼容性问题,以及编译选项设置等。
摘要由CSDN通过智能技术生成

  1. slambook-master/ch2

编译正常,log如下:

slambook-master/ch2# mkdir build && cd build && cmake .. && make -j8

-- The C compiler identification is GNU 9.4.0

-- The CXX compiler identification is GNU 9.4.0

-- Check for working C compiler: /usr/bin/cc

-- Check for working C compiler: /usr/bin/cc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Detecting C compile features

-- Detecting C compile features - done

-- Check for working CXX compiler: /usr/bin/c++

-- Check for working CXX compiler: /usr/bin/c++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Detecting CXX compile features

-- Detecting CXX compile features - done

-- Configuring done

-- Generating done

-- Build files have been written to: /mnt/d/slam14/slambook-master/ch2/build

Scanning dependencies of target helloSLAM

Scanning dependencies of target hello

Scanning dependencies of target hello_shared

[ 37%] Building CXX object CMakeFiles/hello_shared.dir/libHelloSLAM.cpp.o

[ 37%] Building CXX object CMakeFiles/hello.dir/libHelloSLAM.cpp.o

[ 37%] Building CXX object CMakeFiles/helloSLAM.dir/helloSLAM.cpp.o

[ 50%] Linking CXX executable helloSLAM

[ 75%] Linking CXX shared library libhello_shared.so

[ 75%] Linking CXX static library libhello.a

[ 75%] Built target hello

[ 75%] Built target helloSLAM

[ 75%] Built target hello_shared

Scanning dependencies of target useHello

[ 87%] Building CXX object CMakeFiles/useHello.dir/useHello.cpp.o

[100%] Linking CXX executable useHello

[100%] Built target useHello

slambook-master/ch2/build# ./helloSLAM

Hello SLAM!

slambook-master/ch2/build# ./helloSLAM

Hello SLAM!

  1. slambook-master/ch3

1.编译问题

slambook-master/ch3/visualizeGeometry# mkdir build && cd build && cmake .. && make -j8

……

Scanning dependencies of target visualizeGeometry

[ 50%] Building CXX object CMakeFiles/visualizeGeometry.dir/visualizeGeometry.cpp.o

In file included from /usr/local/include/pangolin/utils/signal_slot.h:3,

                 from /usr/local/include/pangolin/windowing/window.h:35,

                 from /usr/local/include/pangolin/display/display.h:34,

                 from /usr/local/include/pangolin/pangolin.h:38,

                 from /mnt/d/slam14/slambook-master/ch3/visualizeGeometry/visualizeGeometry.cpp:9:

/usr/local/include/sigslot/signal.hpp:109:79: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?

  109 | constexpr bool is_weak_ptr_compatible_v = detail::is_weak_ptr_compatible<std::decay_t<P>>::value;

      |                                                                               ^~~~~~~

1.解决方案

将CMakeLists中set(CMAKE_CXX_FLAGS "-std=c++11")注释掉即可

#set(CMAKE_CXX_FLAGS "-std=c++11")

不过编译后运行./visualizeGeometry会有如下报错:

2.编译问题

slambook-master/ch3/visualizeGeometry/build# ./visualizeGeometry

terminate called after throwing an instance of 'std::runtime_error'

  what():  Pangolin X11: Failed to open X display

Aborted

2.解决方案

这个估计是WSL系统没有没有配置界面显示所致,待配置了界面显示估计问题就解决了。

  1. slambook-master/ch4

1.编译问题

slambook-master/ch4/useSophus/useSophus.cpp:5:10: fatal error: Eigen/Core: No such file or directory

5 | #include <Eigen/Core>

1.解决方案

在CMakeLists中添加Eigen库

# 添加Eigen头文件

include_directories( "/usr/include/eigen3" )  #apt命令自动安装的eigen库路径

#include_directories( "/usr/local/include/eigen3" ) #源码编译安装的eigen库路径

2.编译问题

 slambook-master/ch4/useSophus/useSophus.cpp编译问题

(1)slambook-master/ch4/useSophus/useSophus.cpp:8:10: fatal error: sophus/so3.h: No such file or directory

8 | #include "sophus/so3.h"

2.解决方案

因新版本Sophus库中头文件名有改变,将代码useSophus.cpp:8中

#include <sophus/so3.h>

#include <sophus/se3.h>

改为

#include <sophus/so3.hpp>

#include <sophus/se3.hpp>

3.编译问题

slambook-master/ch4/useSophus/useSophus.cpp:16:17: error: missing template arguments before ‘SO3_R’

   16 |     Sophus::SO3 SO3_R(R);               // Sophus::SO(3)可以直接从旋转矩阵构造

slambook-master/ch4/useSophus/useSophus.cpp:24:34: error: ‘SO3_v’ was not declared in this scope; did you mean ‘SO3_R’?

   24 |     cout<<"SO(3) from vector: "<<SO3_v<<endl;

slambook-master/ch4/useSophus/useSophus.cpp:25:38: error: ‘SO3_q’ was not declared in this scope; did you mean ‘SO3_R’?

   25 |     cout<<"SO(3) from quaternion :"<<SO3_q<<endl;

3.解决方案

Sophus库新版本是模板类,定义时需要指定类型,将代码useSophus.cpp中:

Sophus::SO3 SO3_R(R);               // Sophus::SO(3)可以直接从旋转矩阵构造

Sophus::SO3d SO3_v( 0, 0, M_PI/2 );  // 亦可从旋转向量构造

Eigen::Quaterniond q(R);            // 或者四元数

Sophus::SO3d SO3_q( q );

改为:

//Sophus::SO3 SO3_R(R);               // Sophus::SO(3)可以直接从旋转矩阵构造

Sophus::SO3d SO3_R(R);              // Sophus::SO(3)可以直接从旋转矩阵构造

//Sophus::SO3 SO3_v( 0, 0, M_PI/2 );  // 亦可从旋转向量构造

Sophus::SO3d SO3_v( 0, 0, M_PI/2 );  // 亦可从旋转向量构造

Eigen::Quaterniond q(R);            // 或者四元数

//Sophus::SO3 SO3_q( q );

Sophus::SO3d SO3_q( q );

4.编译问题

slambook-master/ch4/useSophus/useSophus.cpp:33:33: error: ‘template<class Scalar_, int Options> class Sophus::SO3’ used without template arguments

   33 |     cout<<"so3 hat=\n"<<Sophus::SO3::hat(so3)<<endl;

4.解决方案

因新版本Sophus库打印需要log()函数:,将代码useSophus.cpp中:

cout<<"SO(3) from matrix: "<<SO3_R<<endl;

改为:

cout<<"SO(3) from matrix: "<<SO3_R.log()<<endl;

5.编译问题

/usr/bin/ld: CMakeFiles/useSophus.dir/useSophus.cpp.o: in function `std::make_unsigned<int>::type fmt::v8::detail::to_unsigned<int>(int)':

useSophus.cpp:(.text._ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_[_ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_]+0x23): undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'

……

collect2: error: ld returned 1 exit status

make[2]: *** [CMakeFiles/useSophus.dir/build.make:97: useSophus] Error 1

make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/useSophus.dir/all] Error 2

make: *** [Makefile:91: all] Error 2

5.解决方案

没有链接fmt库,链接上fmt 库就没问题了,将CMakeLists.txt中:

target_link_libraries( useSophus ${Sophus_LIBRARIES} )

改为:

target_link_libraries(useSophus ${Sophus_LIBRARIES} fmt)

  1. slambook-master/ch5

1.编译问题

/slambook-master/ch5/imageBasics

CMake Error at CMakeLists.txt:8 (find_package):

  Could not find a configuration file for package "OpenCV" that is compatible

  with requested version "3".

  The following configuration files were considered but not accepted:

    /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.5

-- Configuring incomplete, errors occurred!

See also "/mnt/d/slam14/slambook-master/ch5/imageBasics/build/CMakeFiles/CMakeOutput.log".

1.解决方案

因为按照了opencv4.5.5版本不是opencv3.x.x版本,将CMakeLists.txt中:

find_package( OpenCV 3 REQUIRED )

改为:

find_package( OpenCV REQUIRED )

2.编译问题

slambook-master/ch5/imageBasics/build# ./imageBasics

terminate called after throwing an instance of 'std::logic_error'

  what():  basic_string::_M_construct null not valid

Aborted

2.解决方案

//TODO有待解决,解决其他问题后一并解决

应该是由于wsl没有安装UI界面,导致编译的程序调用界面显示时不能显示所致。

3.编译问题

CMake Error at CMakeLists.txt:15 (find_package):

  By not providing "FindPCL.cmake" in CMAKE_MODULE_PATH this project has

  asked CMake to find a package configuration file provided by "PCL", but

  CMake did not find one.

  Could not find a package configuration file provided by "PCL" with any of

  the following names:

    PCLConfig.cmake

    pcl-config.cmake

  Add the installation prefix of "PCL" to CMAKE_PREFIX_PATH or set "PCL_DIR"

  to a directory containing one of the above files.  If "PCL" provides a

  separate development package or SDK, be sure it has been installed.

[ 50%] Building CXX object CMakeFiles/joinMap.dir/joinMap.cpp.o

/mnt/d/slam14/slambook-master/ch5/joinMap/joinMap.cpp:10:10: fatal error: pcl/visualization/pcl_visualizer.h: No such file or directory

   10 | #include <pcl/visualization/pcl_visualizer.h>

      |

3.解决方案

# eigen

#include_directories( "/usr/include/eigen3/" )

include_directories( "/usr/local/include/eigen3/" )

应该时PCL库没有安装成功,需要重新安装PCL库。

4.编译问题

Scanning dependencies of target joinMap

[ 50%] Building CXX object CMakeFiles/joinMap.dir/joinMap.cpp.o

In file included from /usr/local/include/pcl-1.12/pcl/pcl_macros.h:74,

                 from /usr/local/include/pcl-1.12/pcl/impl/point_types.hpp:42,

                 from /usr/local/include/pcl-1.12/pcl/point_types.h:354,

                 from /mnt/d/slam14/slambook-master/ch5/joinMap/joinMap.cpp:8:

/usr/local/include/pcl-1.12/pcl/pcl_config.h:7:4: error: #error PCL requires C++14 or above

7 |   #error PCL requires C++14 or above

4.解决方案

在CMakeLists中添加C++14编译

set( CMAKE_CXX_STANDARD 14)

5.编译问题

slambook-master/ch5/joinMap/build# ./joinMap

请在有pose.txt的目录下运行此程序

5.解决方案

解决办法1:

将make生成的build/joinMap文件复制到pose.txt文件下,在运行./joinMap。

解决办法2:

在joinMap.cpp中:

将ifstream fin("./pose.txt");改为ifstream fin("…/pose.txt");

将boost::format fmt( “./%s/%d.%s” ); 改为boost::format fmt( “…/%s/%d.%s” );

之后保存,重新编译运行即可。

  1. slambook-master/ch6

1.编译问题

slambook-master/ch6/ceres_curve_fitting/build# make -j16

[ 50%] Building CXX object CMakeFiles/curve_fitting.dir/main.cpp.o

In file included from /usr/local/include/ceres/internal/parameter_dims.h:37,

                 from /usr/local/include/ceres/internal/autodiff.h:151,

                 from /usr/local/include/ceres/autodiff_cost_function.h:130,

                 from /usr/local/include/ceres/ceres.h:37,

                 from /mnt/d/slam14/slambook-master/ch6/ceres_curve_fitting/main.cpp:3:

/usr/local/include/ceres/internal/integer_sequence_algorithm.h:64:21: error: ‘integer_sequence’ is not a member of ‘std’

   64 | struct SumImpl<std::integer_sequence<T, N, Ns...>> {

1.解决方案

在CMakeLists中添加C++14编译

set( CMAKE_CXX_STANDARD 14)

2.编译问题

slambook-master/ch6/g2o_curve_fitting/build

[ 50%] Building CXX object CMakeFiles/curve_fitting.dir/main.cpp.o

In file included from /usr/local/include/g2o/core/base_unary_edge.h:30,

                 from /mnt/d/slam14/slambook-master/ch6/g2o_curve_fitting/main.cpp:3:

/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:32: error: ‘index_sequence’ is not a member of ‘std’

  199 |   struct HessianTupleType<std::index_sequence<Ints...>> {

2.解决方案

在CMakeLists中添加C++14编译

set( CMAKE_CXX_STANDARD 14)

3.编译问题

/mnt/d/slam14/slambook-master/ch6/g2o_curve_fitting/main.cpp: In function ‘int main(int, char**)’:

/mnt/d/slam14/slambook-master/ch6/g2o_curve_fitting/main.cpp:77:49: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::LinearSolverType*&)’

   77 |     Block* solver_ptr = new Block( linearSolver );      // 矩阵块求解器

      |                                                 ^

In file included from /usr/local/include/g2o/core/block_solver.h:206,

                 from /mnt/d/slam14/slambook-master/ch6/g2o_curve_fitting/main.cpp:4:

/usr/local/include/g2o/core/block_solver.hpp:39:1: note: candidate: ‘g2o::BlockSolver<Traits>::BlockSolver(std::unique_ptr<typename Traits::LinearSolverType>) [with Traits = g2o::BlockSolverTraits<3, 1>; typename Traits::LinearSolverType = g2o::LinearSolver<Eigen::Matrix<double, 3, 3> >]’

   39 | BlockSolver<Traits>::BlockSolver(std::unique_ptr<LinearSolverType> linearSolver)

      | ^~~~~~~~~~~~~~~~~~~

/usr/local/include/g2o/core/block_solver.hpp:39:68: note:   no known conversion for argument 1 from ‘g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::LinearSolverType*’ {aka ‘g2o::LinearSolver<Eigen::Matrix<double, 3, 3> >*’} to ‘std::unique_ptr<g2o::LinearSolver<Eigen::Matrix<double, 3, 3> >, std::default_delete<g2o::LinearSolver<Eigen::Matrix<double, 3, 3> > > >’

   39 | BlockSolver<Traits>::BlockSolver(std::unique_ptr<LinearSolverType> linearSolver)

      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

/mnt/d/slam14/slambook-master/ch6/g2o_curve_fitting/main.cpp:79:103: error: no matching function for call to ‘g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(Block*&)’

   79 |     g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( solver_ptr );

      |                                                                                                       ^

3.解决方案

将源码main.cpp相关部分修改如下:

// 构建图优化,先设定g2o

    typedef g2o::BlockSolver< g2o::BlockSolverTraits<3,1> > Block;  // 每个误差项优化变量维度为3,误差值维度为1

    //Block::LinearSolverType* linearSolver = new g2o::LinearSolverDense<Block::PoseMatrixType>(); // 线性方程求解器

       std::unique_ptr<Block::LinearSolverType> linearSolver ( new g2o::LinearSolverDense<Block::PoseMatrixType>());

    //Block* solver_ptr = new Block( linearSolver );      // 矩阵块求解器

      std::unique_ptr<Block> solver_ptr ( new Block ( std::move(linearSolver)));     // 矩阵块求解器

    // 梯度下降方法,从GN, LM, DogLeg 中选

    //g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( solver_ptr );

    g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( std::move(solver_ptr));

       // g2o::OptimizationAlgorithmGaussNewton* solver = new g2o::OptimizationAlgorithmGaussNewton( solver_ptr );

    // g2o::OptimizationAlgorithmDogleg* solver = new g2o::OptimizationAlgorithmDogleg( solver_ptr );

    g2o::SparseOptimizer optimizer;     // 图模型

    optimizer.setAlgorithm( solver );   // 设置求解器

    optimizer.setVerbose( true );       // 打开调试输出

#参考关于高博十四讲中由于g2o更新出现的问题解决_xiaoshuiyisheng的博客-CSDN博客

  1. slambook-master/ch7

1.编译问题

CMake Error at CMakeLists.txt:10 (find_package):

  Could not find a configuration file for package "OpenCV" that is compatible

  with requested version "3.1".

  The following configuration files were considered but not accepted:

    /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.5

1.解决方案

将CMakeLists改为:

#find_package( OpenCV 3.1 REQUIRED )

find_package( OpenCV REQUIRED )

# find_package( OpenCV REQUIRED ) # use this if in OpenCV2

find_package( G2O REQUIRED )

find_package( CSparse REQUIRED )

include_directories(

    ${OpenCV_INCLUDE_DIRS}

    ${G2O_INCLUDE_DIRS}

    ${CSPARSE_INCLUDE_DIR}

    #"/usr/include/eigen3/"

    "/usr/include/eigen3/"

)

2.编译问题

CSPARSE_LIBRARY

    linked by target "pose_estimation_3d3d" in directory /mnt/d/slam14/slambook-master/ch7

    linked by target "pose_estimation_3d2d" in directory /mnt/d/slam14/slambook-master/ch7

CMake Warning (dev) in CMakeLists.txt:

  Policy CMP0021 is not set: Fatal error on relative paths in

  INCLUDE_DIRECTORIES target property.  Run "cmake --help-policy CMP0021" for

  policy details.  Use the cmake_policy command to set the policy and

  suppress this warning.

  Found relative path while evaluating include directories of

  "feature_extraction":

    "CSPARSE_INCLUDE_DIR-NOTFOUND"

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:

  Policy CMP0021 is not set: Fatal error on relative paths in

  INCLUDE_DIRECTORIES target property.  Run "cmake --help-policy CMP0021" for

  policy details.  Use the cmake_policy command to set the policy and

  suppress this warning.

  Found relative path while evaluating include directories of

  "pose_estimation_2d2d":

    "CSPARSE_INCLUDE_DIR-NOTFOUND"

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:

  Policy CMP0021 is not set: Fatal error on relative paths in

  INCLUDE_DIRECTORIES target property.  Run "cmake --help-policy CMP0021" for

  policy details.  Use the cmake_policy command to set the policy and

  suppress this warning.

  Found relative path while evaluating include directories of

  "triangulation":

    "CSPARSE_INCLUDE_DIR-NOTFOUND"

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:

  Policy CMP0021 is not set: Fatal error on relative paths in

  INCLUDE_DIRECTORIES target property.  Run "cmake --help-policy CMP0021" for

  policy details.  Use the cmake_policy command to set the policy and

  suppress this warning.

  Found relative path while evaluating include directories of

  "pose_estimation_3d2d":

    "CSPARSE_INCLUDE_DIR-NOTFOUND"

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:

  Policy CMP0021 is not set: Fatal error on relative paths in

  INCLUDE_DIRECTORIES target property.  Run "cmake --help-policy CMP0021" for

  policy details.  Use the cmake_policy command to set the policy and

  suppress this warning.

  Found relative path while evaluating include directories of

  "pose_estimation_3d3d":

    "CSPARSE_INCLUDE_DIR-NOTFOUND"

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done

CMake Generate step failed.  Build files cannot be regenerated correctly.

2.解决方案

未安装CSparse,需要执行以下命令来安装CSparse。

sudo apt-get install libsuitesparse-dev

3.编译问题

[ 10%] Building CXX object CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o

/mnt/d/slam14/slambook-master/ch7/pose_estimation_3d2d.cpp:12:10: fatal error: g2o/solvers/csparse/linear_solver_csparse.h: No such file or directory

   12 | #include <g2o/solvers/csparse/linear_solver_csparse.h>

3.解决方案

g2o安装有问题导致缺少/usr/local/include/g2o/solvers/csparse文件夹而找不到g2o/solvers/csparse/linear_solver_csparse.h头文件,重新安装g2o库即可。

4.编译问题

slambook-master/ch7/feature_extraction.cpp: In function ‘int main(int, char**)’:

/mnt/d/slam14/slambook-master/ch7/feature_extraction.cpp:17:35: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope

   17 |     Mat img_1 = imread ( argv[1], CV_LOAD_IMAGE_COLOR );

……

4.解决方案

在源码feature_extraction.cpp、pose_estimation_2d2d.cpp、pose_estimation_3d2d.cpp、pose_estimation_3d3d.cpp中添加头文件

#include <opencv2/imgcodecs/legacy/constants_c.h>

#参考链接

SLAM十四讲,第七章程序ch7报错, error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope_XXX的博客-CSDN博客_cv_load_image_color

5.编译问题

slambook-master/ch7/pose_estimation_2d2d.cpp:155:65: error: ‘CV_FM_8POINT’ was not declared in this scope

  155 |     fundamental_matrix = findFundamentalMat ( points1, points2, CV_FM_8POINT );

5.解决方案

将源码/slambook-master/ch7/pose_estimation_2d2d.cpp中CV_FM_8POINT改为FM_8POINT即可。如下所示:

//fundamental_matrix = findFundamentalMat ( points1, points2, CV_FM_8POINT );

fundamental_matrix = findFundamentalMat ( points1, points2, FM_8POINT );

#参考链接高翔slam14讲中ch7代码中的一些修改_jywell-CSDN博客

6.编译问题

slambook-master/ch7/pose_estimation_3d2d.cpp:9:

/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:32: error: ‘index_sequence’ is not a member of ‘std’

  199 |   struct HessianTupleType<std::index_sequence<Ints...>> {

6.解决方案

需要在Cmakelists中更新至c++14,在CMakeLists中添加set( CMAKE_CXX_STANDARD 14)

7.编译问题

slambook-master/ch7/pose_estimation_3d2d.cpp:178:14: error: ‘VertexSBAPointXYZ’ is not a member of ‘g2o’; did you mean ‘VertexPointXYZ’?

  178 |         g2o::VertexSBAPointXYZ* point = new g2o::VertexSBAPointXYZ();

      |              ^~~~~~~~~~~~~~~~~

      |              VertexPointXYZ

7.解决方案

新版g2o库中不再存在原先的VertexSBAPointXYZ,将所有报错的地方改为VertexPointXYZ即可。

8.编译问题

(1)slambook-master/ch7/pose_estimation_3d2d.cpp:152:50: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<6, 3> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<6, 3> >::LinearSolverType*&)’

  152 |     Block* solver_ptr = new Block ( linearSolver );     // 矩阵块求解器

(2)slambook-master/ch7/pose_estimation_3d3d.cpp:280:49: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<6, 3> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<6, 3> >::LinearSolverType*&)’

  280 |     Block* solver_ptr = new Block( linearSolver );      // 矩阵块求解器

8.解决方案

新版本g2o中API接口变了,有两种修改模式,基本意义相同但第一种更简洁:

(1)slambook-master/ch7/pose_estimation_3d2d.cpp解决方案采用第一种方法:参考增加智能指针 std::unique_ptr,第一种方法是根据新版本中的示例来进行语句修改。如下所示:

// 初始化g2o

    typedef g2o::BlockSolver< g2o::BlockSolverTraits<6,3> > Block;  // pose 维度为 6, landmark 维度为 3

    //Block::LinearSolverType* linearSolver = new g2o::LinearSolverCSparse<Block::PoseMatrixType>(); // 线性方程求解器

    std::unique_ptr<Block::LinearSolverType> linearSolver ( new g2o::LinearSolverCSparse<Block::PoseMatrixType>());

       //Block* solver_ptr = new Block ( linearSolver );     // 矩阵块求解器

    //std::unique_ptr<Block> solver_ptr( new Block( linearSolver) );

      std::unique_ptr<Block> solver_ptr ( new Block ( std::move(linearSolver)));     // 矩阵块求解器

    //g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( solver_ptr );

    g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( std::move(solver_ptr));

       g2o::SparseOptimizer optimizer;

    optimizer.setAlgorithm ( solver );

(2)slambook-master/ch7/pose_estimation_3d3d.cpp解决方案采用第二种方法:根据报错来修改Block的初始化方法,在每个语句对应加入unique_ptr。如下所示:

// 初始化g2o

    typedef g2o::BlockSolver< g2o::BlockSolverTraits<6,3> > Block;  // pose维度为 6, landmark 维度为 3

    Block::LinearSolverType* linearSolver = new g2o::LinearSolverEigen<Block::PoseMatrixType>(); // 线性方程求解器

    //Block* solver_ptr = new Block( linearSolver );      // 矩阵块求解器

       //std::unique_ptr<Block> solver_ptr ( new Block ( std::move(linearSolver)));     // 矩阵块求解器

       Block* solver_ptr = new Block( std::unique_ptr<Block::LinearSolverType>(linearSolver) );      // 矩阵块求解器

    //g2o::OptimizationAlgorithmGaussNewton* solver = new g2o::OptimizationAlgorithmGaussNewton( solver_ptr );

       //g2o::OptimizationAlgorithmGaussNewton* solver = new g2o::OptimizationAlgorithmGaussNewton ( std::move(solver_ptr));

       g2o::OptimizationAlgorithmGaussNewton* solver = new g2o::OptimizationAlgorithmGaussNewton( unique_ptr<Block>(solver_ptr) );

    g2o::SparseOptimizer optimizer;

optimizer.setAlgorithm( solver );

9.编译问题

/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: undefined reference to symbol '_ZTVN3g2o14VertexPointXYZE'

/usr/bin/ld: /usr/local/lib/libg2o_types_slam3d.so: error adding symbols: DSO missing from command line

collect2: error: ld returned 1 exit status

make[2]: *** [CMakeFiles/pose_estimation_3d2d.dir/build.make:113: pose_estimation_3d2d] Error 1

make[1]: *** [CMakeFiles/Makefile2:169: CMakeFiles/pose_estimation_3d2d.dir/all] Error 2

9.解决方案

(1)DSO missing的原因基本上是因为有库没有连接上,导致未识别。最保险的方法是在最前端将所有库设置为G2O_LIBS:

SET(G2O_LIBS g2o_cli g2o_ext_freeglut_minimal g2o_simulator g2o_solver_slam2d_linear g2o_types_icp g2o_types_slam2d g2o_core g2o_interface g2o_solver_csparse g2o_solver_structure_only g2o_types_sba g2o_types_slam3d g2o_csparse_extension g2o_opengl_helper g2o_solver_dense g2o_stuff g2o_types_sclam2d g2o_parser g2o_solver_pcg g2o_types_data g2o_types_sim3 cxsparse )

(2)由于是在pose_estimation_3d2d中出现问题,所以可以在随后对应的链接中加入${G2O_LIBS}

target_link_libraries( pose_estimation_3d2d

   ${OpenCV_LIBS}

   ${CSPARSE_LIBRARY}

   g2o_core g2o_stuff g2o_types_sba g2o_csparse_extension ${G2O_LIBS}

)

#参考链接

SLAM十四讲ch7代码调整(undefined reference to symbol)_山馗的博客-CSDN博客

10.编译问题

(1)slambook-master/ch7/build# ./feature_extraction

usage: feature_extraction img1 img2

类似的问题还有

slambook-master/ch7/build# ./triangulation

usage: triangulation img1 img2

slambook-master/ch7/build# . /pose_estimation_2d2d

usage: pose_estimation_2d2d img1 img2

slambook-master/ch7/build# . /pose_estimation_3d2d

usage: pose_estimation_3d2d img1 img2 depth1 depth2

slambook-master/ch7/build# . /pose_estimation_3d3d

usage: pose_estimation_3d3d img1 img2 depth1 depth2

(2)slambook-master/ch7/build# ./feature_extraction ../1.png ../2.png

terminate called after throwing an instance of 'cv::Exception'

  what():  OpenCV(4.5.5-dev) /mnt/d/slam14/wsl_libs/opencv-4.x/modules/highgui/src/window.cpp:1268: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'

Aborted

10.解决方案

(1)报错的意思就是以下运行命令格式不对:

./feature_extraction

./triangulation

./pose_estimation_2d2d

./pose_estimation_3d2d

./pose_estimation_3d3d

正确的命令运行格式应该为:

./feature_extraction img1 img2

./triangulation img1 img2

./pose_estimation_2d2d img1 img2

./pose_estimation_3d2d img1 img2 depth1 depth2

./pose_estimation_3d3d img1 img2 depth1 depth2

如果这些二进制文件feature_extraction、triangulation、pose_estimation_2d2d img1 img2、pose_estimation_3d2d、pose_estimation_3d3d是在源代码目录生成的或者是在新建的build目录中编译生成后移动或者拷贝到源码文件目录下的,实际的运行命令为:

./feature_extraction 1.png 2.png

./triangulation 1.png  2.png

./pose_estimation_2d2d 1.png 2.png

./pose_estimation_3d2d 1.png 2.png 1_depth.png 2_depth.png

./pose_estimation_3d3d 1.png 2.png 1_depth.png 2_depth.png

如果这些二进制文件feature_extraction、triangulation、pose_estimation_2d2d img1 img2、pose_estimation_3d2d、pose_estimation_3d3d是在新建的build目录中编译生成的不移动或拷贝它们,实际的运行命令为:

./feature_extraction ../1.png ../2.png

./triangulation ../1.png ../2.png

./pose_estimation_2d2d ../1.png ../2.png

./pose_estimation_3d2d ../1.png ../2.png ../1_depth.png ../2_depth.png

./pose_estimation_3d3d ../1.png ../2.png ../1_depth.png ../2_depth.png

(2)//TODO有待解决,解决其他问题后一并解决

应该是由于wsl没有安装UI界面,导致编译的程序调用界面显示时不能显示所致。

  1. slambook-master/ch8

1.编译问题

(1)slambook-master/ch8/LKFlow/build# ./useLK

usage: useLK path_to_dataset

(2)slambook-master/ch8/LKFlow/build# ./useLK ../../data/

LK Flow use time:0.0142803 seconds.

tracked keypoints: 1750

terminate called after throwing an instance of 'cv::Exception'

  what():  OpenCV(4.5.5-dev) /mnt/d/slam14/wsl_libs/opencv-4.x/modules/highgui/src/window.cpp:1268: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'

Aborted

1.解决方案

(1)退出LKFlow文件夹,进入data文件夹并将将data文件夹中的压缩文件用tar -zxvf data.tar.gz命令解压,然后进入LKFlow/build文件夹目录执行./useLK ../../data/命令

(2)//TODO有待解决,解决其他问题后一并解决

应该是由于wsl没有安装UI界面,导致编译的程序调用界面显示时不能显示所致。

2.编译问题

[ 50%] Building CXX object CMakeFiles/direct_semidense.dir/direct_semidense.cpp.o

In file included from /usr/local/include/g2o/core/base_unary_edge.h:30,

                 from /mnt/d/slam14/slambook-master/ch8/directMethod/direct_sparse.cpp:14:

/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:32: error: ‘index_sequence’ is not a member of ‘std’

  199 |   struct HessianTupleType<std::index_sequence<Ints...>> {

2.解决方案

在CMakeLists中添加C++14编译

set( CMAKE_CXX_STANDARD 14)

3.编译问题

(1)slambook-master/ch8/directMethod/direct_semidense.cpp: In function ‘bool poseEstimationDirect(const std::vector<Measurement>&, cv::Mat*, Eigen::Matrix3f&, Eigen::Isometry3d&)’:

/mnt/d/slam14/slambook-master/ch8/directMethod/direct_semidense.cpp:266:62: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<6, 1> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<6, 1> >::LinearSolverType*&)’

  266 |     DirectBlock* solver_ptr = new DirectBlock ( linearSolver );

(2)slambook-master/ch8/directMethod/direct_sparse.cpp:258:62: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<6, 1> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<6, 1> >::LinearSolverType*&)’

  258 |     DirectBlock* solver_ptr = new DirectBlock ( linearSolver );

3.解决方案

新版本g2o中API接口变了,有两种修改模式,基本意义相同但第一种更简洁:

(1)slambook-master/ch8/directMethod/direct_semidense.cpp解决方案采用第一种方法:参考增加智能指针 std::unique_ptr,第一种方法是根据新版本中的示例来进行语句修改。如下所示:

// 初始化g2o

    typedef g2o::BlockSolver<g2o::BlockSolverTraits<6,1>> DirectBlock;  // 求解的向量是6*1的

    //DirectBlock::LinearSolverType* linearSolver = new g2o::LinearSolverDense< DirectBlock::PoseMatrixType > ();

       std::unique_ptr<DirectBlock::LinearSolverType> linearSolver ( new g2o::LinearSolverDense<DirectBlock::PoseMatrixType>());

    //DirectBlock* solver_ptr = new DirectBlock ( linearSolver );

       std::unique_ptr<DirectBlock> solver_ptr ( new DirectBlock ( std::move(linearSolver)));     // 矩阵块求解器

    // g2o::OptimizationAlgorithmGaussNewton* solver = new g2o::OptimizationAlgorithmGaussNewton( solver_ptr ); // G-N

    //g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( solver_ptr ); // L-M

       g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( std::move(solver_ptr));

    g2o::SparseOptimizer optimizer;

    optimizer.setAlgorithm ( solver );

    optimizer.setVerbose( true );

(2)slambook-master/ch8/directMethod/direct_sparse.cpp解决方案也采用第一种方法:参考增加智能指针 std::unique_ptr,第一种方法是根据新版本中的示例来进行语句修改。如下所示:

// 初始化g2o

    typedef g2o::BlockSolver<g2o::BlockSolverTraits<6,1>> DirectBlock;  // 求解的向量是6*1的

    //DirectBlock::LinearSolverType* linearSolver = new g2o::LinearSolverDense< DirectBlock::PoseMatrixType > ();

       std::unique_ptr<DirectBlock::LinearSolverType> linearSolver ( new g2o::LinearSolverDense<DirectBlock::PoseMatrixType>());

    //DirectBlock* solver_ptr = new DirectBlock ( linearSolver );

       std::unique_ptr<DirectBlock> solver_ptr ( new DirectBlock ( std::move(linearSolver)));     // 矩阵块求解器

    // g2o::OptimizationAlgorithmGaussNewton* solver = new g2o::OptimizationAlgorithmGaussNewton( solver_ptr ); // G-N

    //g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( solver_ptr ); // L-M

       g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( std::move(solver_ptr));

    g2o::SparseOptimizer optimizer;

    optimizer.setAlgorithm ( solver );

    optimizer.setVerbose( true );

4.编译问题

slambook-master/ch8/directMethod/build# ./direct_semidense

usage: useLK path_to_dataset

4.解决方案

运行命令格式不对,采用useLK path_to_dataset格式如下:

slambook-master/ch8/directMethod/build# ./direct_semidense  ../../data/

  1. slambook-master/ch9

1.编译问题

CMake Error at CMakeLists.txt:16 (find_package):

  Could not find a configuration file for package "OpenCV" that is compatible

  with requested version "3.1".

  The following configuration files were considered but not accepted:

    /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.5

1.解决方案

将CMakeLists改为:

# OpenCV

#find_package( OpenCV 3.1 REQUIRED )

find_package( OpenCV REQUIRED )

2.编译问题

[ 83%] Building CXX object src/CMakeFiles/myslam.dir/config.cpp.o

In file included from /mnt/d/slam14/slambook-master/project/0.1/src/mappoint.cpp:20:

/mnt/d/slam14/slambook-master/project/0.1/include/myslam/common_include.h:32:10: fatal error: sophus/se3.h: No such file or directory

   32 | #include <sophus/se3.h>

2.解决方案

因新版本Sophus库中头文件名有改变,将代码common_include.h:32中

// for Sophus

#include <sophus/se3.hpp>

改为

// for Sophus

//#include <sophus/se3.h>

#include <sophus/se3.hpp>

3.编译问题

In file included from /mnt/d/slam14/slambook-master/project/0.3/src/g2o_types.cpp:1:

/mnt/d/slam14/slambook-master/project/0.3/include/myslam/g2o_types.h:37:80: error: ‘VertexSBAPointXYZ’ is not a member of ‘g2o’; did you mean ‘VertexPointXYZ’?

   37 | class EdgeProjectXYZRGBD : public g2o::BaseBinaryEdge<3, Eigen::Vector3d, g2o::VertexSBAPointXYZ, g2o::VertexSE3Expmap>

3.解决方案

将g2o_types.cpp 和g2o_types.h中‘VertexSBAPointXYZ’修改为 ‘VertexPointXYZ’

4.编译问题

/mnt/d/slam14/slambook-master/project/0.3/src/visual_odometry.cpp:202:26: error: ‘class Sophus::SE3<double>’ has no member named ‘rotation_matrix’; did you mean ‘rotationMatrix’?

  202 |         T_c_r_estimated_.rotation_matrix(),

      |                          ^~~~~~~~~~~~~~~

4.解决方案

将visual_odometry.cpp中‘rotation_matrix’修改为‘rotationMatrix’

5.编译问题

/mnt/d/slam14/slambook-master/project/0.3/src/visual_odometry.cpp:194:49: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<6, 2> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<6, 2> >::LinearSolverType*&)’

  194 |     Block* solver_ptr = new Block( linearSolver );

5.解决方案

将visual_odometry.cpp中相关代码修改如下:

// using bundle adjustment to optimize the pose

    typedef g2o::BlockSolver<g2o::BlockSolverTraits<6,2>> Block;

    //Block::LinearSolverType* linearSolver = new g2o::LinearSolverDense<Block::PoseMatrixType>();

    std::unique_ptr<Block::LinearSolverType> linearSolver ( new g2o::LinearSolverDense<Block::PoseMatrixType>());

       //Block* solver_ptr = new Block( linearSolver );

      std::unique_ptr<Block> solver_ptr ( new Block ( std::move(linearSolver)));     // 矩阵块求解器

    //g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( solver_ptr );

       g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( std::move(solver_ptr));

    g2o::SparseOptimizer optimizer;

optimizer.setAlgorithm ( solver );

6.编译问题

(1)[ 50%] Building CXX object src/CMakeFiles/myslam.dir/camera.cpp.o

In file included from /mnt/d/slam14/slambook-master/project/0.1/include/myslam/frame.h:24,

                 from /mnt/d/slam14/slambook-master/project/0.1/include/myslam/map.h:24,

                 from /mnt/d/slam14/slambook-master/project/0.1/src/map.cpp:20:

/mnt/d/slam14/slambook-master/project/0.1/include/myslam/camera.h:41:55: error: invalid use of template-name ‘Sophus::SE3’ without an argument list

   41 |     Vector3d world2camera( const Vector3d& p_w, const SE3& T_c_w );

(2)[ 83%] Building CXX object src/CMakeFiles/myslam.dir/config.cpp.o

In file included from /mnt/d/slam14/slambook-master/project/0.1/src/frame.cpp:20:

/mnt/d/slam14/slambook-master/project/0.1/include/myslam/frame.h:37:5: error: invalid use of template-name ‘Sophus::SE3’ without an argument list

   37 |     SE3                            T_c_w_;      // transform from world to camera

(3)[ 50%] Building CXX object src/CMakeFiles/myslam.dir/camera.cpp.o

/mnt/d/slam14/slambook-master/project/0.1/src/camera.cpp:29:60: error: invalid use of template-name ‘Sophus::SE3’ without an argument list

   29 | Vector3d Camera::world2camera ( const Vector3d& p_w, const SE3& T_c_w )

(4)[ 33%] Building CXX object src/CMakeFiles/myslam.dir/camera.cpp.o

/mnt/d/slam14/slambook-master/project/0.1/src/frame.cpp:30:44: error: ‘SE3’ is not a type

   30 | Frame::Frame ( long id, double time_stamp, SE3 T_c_w, Camera::Ptr camera, Mat color, Mat depth )

      |                                            ^~~

/mnt/d/slam14/slambook-master/project/0.1/src/frame.cpp:30:1: error: no declaration matches ‘myslam::Frame::Frame(long int, double, int, myslam::Camera::Ptr, cv::Mat, cv::Mat)’

   30 | Frame::Frame ( long id, double time_stamp, SE3 T_c_w, Camera::Ptr camera, Mat color, Mat depth )

(5)/mnt/d/slam14/slambook-master/project/0.2/test/run_vo.cpp:79:9: error: ‘SE3’ was not declared in this scope; did you mean ‘Sophus::SE3’?

   79 |         SE3 Tcw = pFrame->T_c_w_.inverse();

      |         ^~~

      |         Sophus::SE3

In file included from /mnt/d/slam14/slambook-master/project/0.2/include/myslam/common_include.h:34,

                 from /mnt/d/slam14/slambook-master/project/0.2/include/myslam/config.h:23,

                 from /mnt/d/slam14/slambook-master/project/0.2/test/run_vo.cpp:8:

/usr/local/include/sophus/se3.hpp:11:7: note: ‘Sophus::SE3’ declared here

   11 | class SE3;

      |       ^~~

(6)/mnt/d/slam14/slambook-master/project/0.2/src/visual_odometry.cpp: In member function ‘void myslam::VisualOdometry::poseEstimationPnP()’:

/mnt/d/slam14/slambook-master/project/0.2/src/visual_odometry.cpp:181:27: error: missing template arguments before ‘(’ token

  181 |     T_c_r_estimated_ = SE3(

      |                           ^

/mnt/d/slam14/slambook-master/project/0.2/src/visual_odometry.cpp:182:12: error: missing template arguments before ‘(’ token

  182 |         SO3(rvec.at<double>(0,0), rvec.at<double>(1,0), rvec.at<double>(2,0)),

      |            ^

6.解决方案

// project中0.1、0.2、0.3、0.4项目中均有此问题。

由于Sophus::SE3和Sophus::SO3在Sophus库新版本中都是模板类,需要声明模板类的数据类型,有两种办法:

(1)一种办法是

using Sophus::SE3;

using Sophus::SO3;

SE3<double> xxx;

SO3<double> yyy;

(2)另一种办法是

using Sophus::SE3d;

using Sophus::SO3d;

SE3d xxx;

SO3d yyy;

采用第二种方法后可将const SE3& T_c_w改为:const SE3d & T_c_w,其他类似地把SE3改为SE3d。最难修改的是T_c_r_estimated_初始化部分,采用第二种方法修改源码如下:

//T_c_r_estimated_ = SE3(

    //    SO3(rvec.at<double>(0,0), rvec.at<double>(1,0), rvec.at<double>(2,0)),

    //    Vector3d( tvec.at<double>(0,0), tvec.at<double>(1,0), tvec.at<double>(2,0))

       // 此处旋转向量经罗德里格斯转换

    Mat R;

    cv::Rodrigues(rvec, R);

    Eigen::Matrix3d RE;

    RE << R.at<double>(0,0), R.at<double>(0,1), R.at<double>(0,2),

            R.at<double>(1,0), R.at<double>(1,1), R.at<double>(1,2),

            R.at<double>(2,0), R.at<double>(2,1), R.at<double>(2,2);

       // SO3构造函数参数为旋转矩阵

    T_c_r_estimated_ = SE3d(

              SO3d(RE),

              Vector3d(tvec.at<double>(0,0), tvec.at<double>(1,0), tvec.at<double>(2,0)));

#参考链接

关于使用新版Sophus(2018年6月github版本)的使用_王勇的博客-CSDN博客

视觉SLAM十四讲 从理论到实践-第九讲实践:设计前端,关于Sophus库中SO3类构造函数使用疑惑_RobotLife的博客-CSDN博客

7.编译问题

[ 88%] Building CXX object test/CMakeFiles/run_vo.dir/run_vo.cpp.o

/mnt/d/slam14/slambook-master/project/0.2/test/run_vo.cpp:6:10: fatal error: opencv2/viz.hpp: No such file or directory

    6 | #include <opencv2/viz.hpp>

7.解决方案

这是由于编译VTK+opencv+opencv_contrib不完整所致,重新编译opencv+opencv_contrib即可,编译命令中要开VTK:-D WITH_VTK=ON。

8.编译问题

/mnt/d/slam14/slambook-master/project/0.2/test/run_vo.cpp:84:17: error: ‘Tcw’ was not declared in this scope

   84 |                 Tcw.rotation_matrix()(0,0), Tcw.rotation_matrix()(0,1), Tcw.rotation_matrix()(0,2),

/mnt/d/slam14/slambook-master/project/0.2/test/run_vo.cpp:84:21: error: ‘using SE3d = class Sophus::SE3<double>’ {aka ‘class Sophus::SE3<double>’} has no member named ‘

rotation_matrix’; did you mean ‘rotationMatrix’?

   84 |                 Tcw.rotation_matrix()(0,0), Tcw.rotation_matrix()(0,1), Tcw.rotation_matrix()(0,2),

8.解决方案

将‘rotation_matrix’修改为‘rotationMatrix’即可。

9.编译问题

[100%] Linking CXX executable ../../bin/run_vo

/usr/bin/ld: CMakeFiles/run_vo.dir/run_vo.cpp.o: in function `char const* fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >&>(char const*, char const*, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >&)':

run_vo.cpp:(.text._ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_[_ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_]+0x163): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'

9.解决方案

没有链接fmt库,链接上fmt 库就没问题了,将CMakeLists.txt中:

add_executable( run_vo run_vo.cpp )

target_link_libraries( run_vo myslam )

改为:

add_executable( run_vo run_vo.cpp )

target_link_libraries( run_vo myslam fmt)

10.编译问题

/mnt/d/slam14/slambook-master/project/0.4/src/g2o_types.cpp:7:16: error: ‘SE3’ in namespace ‘g2o’ does not name a type

    7 |     const g2o::SE3* point = static_cast<const g2o::SE3*> ( _vertices[0] );

      |                ^~~

/mnt/d/slam14/slambook-master/project/0.4/src/g2o_types.cpp:9:52: error: ‘point’ was not declared in this scope

    9 |     _error = _measurement - pose->estimate().map ( point->estimate() );

      |                                                    ^~~~~

10.解决方案

在头文件g2o_types.h中添加以下头文件引用即可:

#include <g2o/core/base_vertex.h>

#include <g2o/core/base_binary_edge.h>

#include <g2o/core/block_solver.h>

#include <g2o/core/optimization_algorithm_levenberg.h>

#include <g2o/solvers/eigen/linear_solver_eigen.h>

#include <g2o/types/slam3d/types_slam3d.h>

#include <g2o/types/slam3d/types_slam3d.h>

#include <g2o/core/sparse_optimizer.h>

#include <g2o/core/block_solver.h>

#include <g2o/core/factory.h>

#include <g2o/core/optimization_algorithm_factory.h>

#include <g2o/core/optimization_algorithm_gauss_newton.h>

#include <g2o/core/robust_kernel.h>

#include <g2o/core/robust_kernel_factory.h>

#include <g2o/core/optimization_algorithm_levenberg.h>

#include <g2o/solvers/eigen/linear_solver_eigen.h>

#include <g2o/solvers/csparse/linear_solver_csparse.h>

#参考链接:ORB_SLAM之error: ‘Sim3’ in namespace ‘g2o’ does not name a type简单暴力解决问题_英雄小摔哥的博客-CSDN博客

11.编译问题

[100%] Linking CXX executable ../../bin/run_vo

/usr/bin/ld: ../../bin/run_vo: hidden symbol `_ZNK3fmt2v86detail10locale_ref3getISt6localeEET_v' in /usr/local/lib/libfmt.a(format.cc.o) is referenced by DSO

/usr/bin/ld: final link failed: bad value

collect2: error: ld returned 1 exit status

make[2]: *** [test/CMakeFiles/run_vo.dir/build.make:154: ../bin/run_vo] Error 1

make[1]: *** [CMakeFiles/Makefile2:142: test/CMakeFiles/run_vo.dir/all] Error 2

make: *** [Makefile:91: all] Error 2

11.解决方案

本以为安装将gcc,g++版本升级到6.5之后解决了,一查gcc/g++版本是9.4.0的适配Ubuntu20.04LTS版本的,故此法不可行。

#参考链接

【Linux】报错/usr/bin/ld: demo: hidden symbol `__cpu_indicator_init‘ in /usr/lib/gcc/x86_64-linux-gnu/5/_怡宝2号_51CTO博客

后来考虑到跟fmt库兼容问题,重新安装Sophus库(编译命令中添加"-DUSE_BASIC_LOGGING=ON")编译问题依旧,故此法也行不通。

#参考链接hidden symbol `_ZNK3fmt2v86detail10locale_ref3getISt6localeEET_v‘_一个有梦想,有追求,有抱负的人-CSDN博客

//TODO有待解决,0.2、0.3、0.4项目中均有此编译问题

12.编译问题

[ 20%] Building CXX object src/CMakeFiles/myslam.dir/visual_odometry.cpp.o

In file included from /usr/local/include/g2o/solvers/csparse/csparse_helper.h:30,

                 from /usr/local/include/g2o/solvers/csparse/linear_solver_csparse.h:32,

                 from /mnt/d/slam14/slambook-master/project/0.4/include/myslam/g2o_types.h:51,

                 from /mnt/d/slam14/slambook-master/project/0.4/src/g2o_types.cpp:1:

/usr/local/include/g2o/solvers/csparse/csparse_extension.h:27:10: fatal error: cs.h: No such file or directory

   27 | #include <cs.h>

      |          ^~~~~~

compilation terminated.

make[2]: *** [src/CMakeFiles/myslam.dir/build.make:146: src/CMakeFiles/myslam.dir/g2o_types.cpp.o] Error 1

make[2]: *** Waiting for unfinished jobs....

In file included from /usr/local/include/g2o/solvers/csparse/csparse_helper.h:30,

                 from /usr/local/include/g2o/solvers/csparse/linear_solver_csparse.h:32,

                 from /mnt/d/slam14/slambook-master/project/0.4/include/myslam/g2o_types.h:51,

                 from /mnt/d/slam14/slambook-master/project/0.4/src/visual_odometry.cpp:28:

/usr/local/include/g2o/solvers/csparse/csparse_extension.h:27:10: fatal error: cs.h: No such file or directory

   27 | #include <cs.h>

      |          ^~~~~~

compilation terminated.

make[2]: *** [src/CMakeFiles/myslam.dir/build.make:160: src/CMakeFiles/myslam.dir/visual_odometry.cpp.o] Error 1

make[1]: *** [CMakeFiles/Makefile2:116: src/CMakeFiles/myslam.dir/all] Error 2

make: *** [Makefile:91: all] Error 2

12.解决方案

//TODO有待解决, 0.4项目中均有此编译问题

  1. slambook-master/ch10

1.编译问题

/mnt/d/slam14/slambook-master/ch10/ceres_custombundle/common/BALProblem.cpp:8:10: fatal error: Eigen/Core: No such file or directory

8 | #include <Eigen/Core>

1.解决方案

在CMakeLists中添加"/usr/include/eigen3",如下所示:

include_directories(${CERES_INCLUDE_DIRS}

                    ${PROJECT_SOURCE_DIR}/common

                    ${PROJECT_SOURCE_DIR}/common/tools

                    ${PROJECT_SOURCE_DIR}/common/flags

                                   "/usr/include/eigen3" )

2.编译问题

[ 83%] Building CXX object CMakeFiles/ceres_customBundle.dir/ceresBundle.cpp.o

In file included from /usr/local/include/ceres/internal/parameter_dims.h:37,

                 from /usr/local/include/ceres/internal/autodiff.h:151,

                 from /usr/local/include/ceres/autodiff_cost_function.h:130,

                 from /usr/local/include/ceres/ceres.h:37,

                 from /mnt/d/slam14/slambook-master/ch10/ceres_custombundle/ceresBundle.cpp:3:

/usr/local/include/ceres/internal/integer_sequence_algorithm.h:64:21: error: ‘integer_sequence’ is not a member of ‘std’

   64 | struct SumImpl<std::integer_sequence<T, N, Ns...>> {

2.解决方案

在CMakeLists中添加set( CMAKE_CXX_STANDARD 14)

3.编译问题

/mnt/d/slam14/slambook-master/ch10/ceres_custombundle/ceresBundle.cpp:17:14: error: ‘struct ceres::Solver::Options’ has no member named ‘num_linear_solver_threads’; did you mean ‘linear_solver_type’?

   17 |     options->num_linear_solver_threads = params.num_threads;

      |              ^~~~~~~~~~~~~~~~~~~~~~~~~

      |              linear_solver_type

3.解决方案

规避的话注释掉options->num_linear_solver_threads = params.num_threads;

//options->num_linear_solver_threads = params.num_threads;

更好的方法是用“options->num_threads = params.num_threads;”替换原来的“options->num_linear_solver_threads = params.num_threads;”

这是因为“Solver::Options::num_linear_solver_threads is deprecated, Solver::Options::num_threads controls all parallelism in Ceres Solver now.“

4.编译问题

slambook-master/ch10/ceres_custombundle/build# ./ceres_customBundle

Usage: bundle_adjuster -input <path for dataset>

4.解决方案

运行命令应该按照bundle_adjuster -input <path for dataset>,故修改运行命令如下:

./ceres_customBundle -input ../data/problem-16-22106-pre.txt

5.编译问题

[ 83%] Building CXX object CMakeFiles/g2o_customBundle.dir/g2o_bundle.cpp.o

In file included from /usr/local/include/g2o/types/sba/edge_project_psi2uv.h:30,

                 from /usr/local/include/g2o/types/sba/types_six_dof_expmap.h:38,

                 from /mnt/d/slam14/slambook-master/ch10/g2o_custombundle/g2o_bundle.cpp:25:

/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:32: error: ‘index_sequence’ is not a member of ‘std’

  199 |   struct HessianTupleType<std::index_sequence<Ints...>> {

5.解决方案

在CMakeLists中添加set( CMAKE_CXX_STANDARD 14)

6.编译问题

[ 83%] Building CXX object CMakeFiles/g2o_customBundle.dir/g2o_bundle.cpp.o

/mnt/d/slam14/slambook-master/ch10/g2o_custombundle/g2o_bundle.cpp: In function ‘void SetMinimizerOptions(std::shared_ptr<g2o::BlockSolver<g2o::BlockSolverTraits<9, 3> > >&, const BundleParams&, g2o::SparseOptimizer*)’:

/mnt/d/slam14/slambook-master/ch10/g2o_custombundle/g2o_bundle.cpp:136:74: error: no matching function for call to ‘g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(std::__shared_ptr<g2o::BlockSolver<g2o::BlockSolverTraits<9, 3> >, __gnu_cxx::_S_atomic>::element_type*)’

  136 |         solver = new g2o::OptimizationAlgorithmLevenberg(solver_ptr.get());

6.解决方案

//this function is  unused yet..

//void SetMinimizerOptions(std::shared_ptr<BalBlockSolver>& solver_ptr, const BundleParams& params, g2o::SparseOptimizer* optimizer)

void SetMinimizerOptions(std::unique_ptr<BalBlockSolver>& solver_ptr, const BundleParams& params, g2o::SparseOptimizer* optimizer)

{

    //std::cout<<"Set Minimizer  .."<< std::endl;

    g2o::OptimizationAlgorithmWithHessian* solver;

    if(params.trust_region_strategy == "levenberg_marquardt"){

        //solver = new g2o::OptimizationAlgorithmLevenberg(solver_ptr.get());

              solver = new g2o::OptimizationAlgorithmLevenberg(std::move(solver_ptr));

    }

    else if(params.trust_region_strategy == "dogleg"){

        //solver = new g2o::OptimizationAlgorithmDogleg(solver_ptr.get());

              solver = new g2o::OptimizationAlgorithmDogleg(std::move(solver_ptr));

    }

    else

    {

        std::cout << "Please check your trust_region_strategy parameter again.."<< std::endl;

        exit(EXIT_FAILURE);

    }

    optimizer->setAlgorithm(solver);

    //std::cout<<"Set Minimizer  .."<< std::endl;

}

void SetSolverOptionsFromFlags(BALProblem* bal_problem, const BundleParams& params, g2o::SparseOptimizer* optimizer)

{  

    //BalBlockSolver* solver_ptr;

   

   

    //g2o::LinearSolver<BalBlockSolver::PoseMatrixType>* linearSolver = 0;

       std::unique_ptr<BalBlockSolver::LinearSolverType> linearSolver;

   

    if(params.linear_solver == "dense_schur" ){

        //linearSolver = new g2o::LinearSolverDense<BalBlockSolver::PoseMatrixType>();

              linearSolver = g2o::make_unique<g2o::LinearSolverDense<BalBlockSolver::PoseMatrixType> >();

    }

    else if(params.linear_solver == "sparse_schur"){

        //linearSolver = new g2o::LinearSolverCholmod<BalBlockSolver::PoseMatrixType>();

        //dynamic_cast<g2o::LinearSolverCholmod<BalBlockSolver::PoseMatrixType>* >(linearSolver)->setBlockOrdering(true);  // AMD ordering , only needed for sparse cholesky solver

         auto cholesky = g2o::make_unique<g2o::LinearSolverCholmod<BalBlockSolver::PoseMatrixType> >();

        cholesky->setBlockOrdering(true);

        linearSolver = std::move(cholesky);

       }

   

    //solver_ptr = new BalBlockSolver(linearSolver);

       std::unique_ptr<BalBlockSolver> solver_ptr( new BalBlockSolver(std::move(linearSolver)));

    //SetLinearSolver(solver_ptr, params);

    //SetMinimizerOptions(solver_ptr, params, optimizer);

    g2o::OptimizationAlgorithmWithHessian* solver;

    if(params.trust_region_strategy == "levenberg_marquardt"){

        //solver = new g2o::OptimizationAlgorithmLevenberg(solver_ptr);

              solver = new g2o::OptimizationAlgorithmLevenberg(std::move(solver_ptr));

    }

    else if(params.trust_region_strategy == "dogleg"){

        //solver = new g2o::OptimizationAlgorithmDogleg(solver_ptr);

              solver = new g2o::OptimizationAlgorithmDogleg(std::move(solver_ptr));

    }

    else

    {

        std::cout << "Please check your trust_region_strategy parameter again.."<< std::endl;

        exit(EXIT_FAILURE);

    }

    optimizer->setAlgorithm(solver);

}

7.编译问题

slambook-master/ch10/g2o_custombundle/ceres/autodiff.h:225:11: error: ‘class ceres::internal::FixedArray<ceres::Jet<double, 12>, 17, Eigen::aligned_allocator<ceres::Jet<double, 12> > >’ has no member named ‘get’

  225 |         x.get() + jet0,

      |         ~~^~~

7.解决方案

//TODO有待解决

8.编译问题

slambook-master/ch10/g2o_custombundle/g2o_bundle.cpp:169:63:   required from here

/usr/include/c++/9/ext/new_allocator.h:146:4: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<9, 3> >::BlockSolver(g2o::LinearSolver<Eigen::Matrix<double, 9, 9, 0, 9, 9> >*&)’

  146 |  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }

8.解决方案

//TODO未解决

  1. slambook-master/ch11

1.编译问题

(1)slambook-master/ch11/pose_graph_gtsam.cpp:6:10: fatal error: sophus/se3.h: No such file or directory

    6 | #include <sophus/se3.h>

      |          ^~~~~~~~~~~~~~

(2)slambook-master/ch11/pose_graph_g2o_lie_algebra.cpp:15:10: fatal error: sophus/se3.h: No such file or directory

   15 | #include <sophus/se3.h>

1.解决方案

(1)将slambook-master/ch11/pose_graph_gtsam.cpp:6中代码修改如下:

//#include <sophus/se3.h>

//#include <sophus/so3.h>

#include <sophus/se3.hpp>

#include <sophus/so3.hpp>

(2)将slambook-master/ch11/pose_graph_g2o_lie_algebra.cpp:15中代码修改如下:

//#include <sophus/se3.h>

//#include <sophus/so3.h>

#include <sophus/se3.hpp>

#include <sophus/so3.hpp>

2.编译问题

[ 66%] Built target pose_graph_gtsam

In file included from /usr/local/include/g2o/core/base_binary_edge.h:30,

                 from /mnt/d/slam14/slambook-master/ch11/pose_graph_g2o_lie_algebra.cpp:7:

/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:32: error: ‘index_sequence’ is not a member of ‘std’

  199 |   struct HessianTupleType<std::index_sequence<Ints...>> {

2.解决方案

在CMakeLists中添加C++14编译

set( CMAKE_CXX_STANDARD 14)

3.编译问题

slambook-master/ch11/pose_graph_g2o_lie_algebra.cpp:33:21: error: missing template arguments before ‘e’

   33 | Matrix6d JRInv( SE3 e )

3.解决方案

将SE3修改为SE3<double>

类似的问题将SO3修改为SO3<double>

4.编译问题

slambook-master/ch11/pose_graph_g2o_SE3.cpp:38:103: error: no matching function for call to ‘g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(Block*&)’

   38 |     g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( solver_ptr );

4.解决方案

将pose_graph_g2o_lie_algebra.cpp和pose_graph_g2o_SE3.cpp中相关代码修改为:

typedef g2o::BlockSolver<g2o::BlockSolverTraits<6,6>> Block;  // 6x6 BlockSolver

    //Block::LinearSolverType* linearSolver = new g2o::LinearSolverCholmod<Block::PoseMatrixType>(); // 线性方程求解器

       std::unique_ptr<Block::LinearSolverType> linearSolver ( new g2o::LinearSolverCholmod<Block::PoseMatrixType>());

       //Block* solver_ptr = new Block ( linearSolver );     // 矩阵块求解器

      std::unique_ptr<Block> solver_ptr ( new Block ( std::move(linearSolver)));     // 矩阵块求解器

    // 梯度下降方法,从GN, LM, DogLeg 中选

       //g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( solver_ptr );

       g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( std::move(solver_ptr));

5.编译问题

slambook-master/ch11/pose_graph_g2o_lie_algebra.cpp:77:67: error: no matching function for call to ‘Sophus::SO3<double>::SO3(const double&, const double&, const double&)’

   77 |             Sophus::SO3<double> ( update[3], update[4], update[5] ),

5.解决方案

//TODO 有待解决

  1. slambook-master/ch12

1.编译问题

CMake Error at CMakeLists.txt:8 (find_package):

  Could not find a configuration file for package "OpenCV" that is compatible

  with requested version "3.1".

  The following configuration files were considered but not accepted:

/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.5

1.解决方案

将CMakeLists改为:

# opencv

#find_package( OpenCV 3.1 REQUIRED )

find_package( OpenCV REQUIRED )

2.编译问题

-- Build files have been written to: /mnt/d/slam14/slambook-master/ch12/build

make[2]: *** No rule to make target '/usr/local/lib/libDBoW3.a', needed by 'feature_training'.  Stop.

make[2]: *** Waiting for unfinished jobs....

make[2]: *** No rule to make target '/usr/local/lib/libDBoW3.a', needed by 'loop_closure'.  Stop.

make[2]: *** Waiting for unfinished jobs....

make[2]: *** No rule to make target '/usr/local/lib/libDBoW3.a', needed by 'gen_vocab'.  Stop.

make[2]: *** Waiting for unfinished jobs....

[ 50%] Building CXX object CMakeFiles/gen_vocab.dir/gen_vocab_large.cpp.o

[ 50%] Building CXX object CMakeFiles/loop_closure.dir/loop_closure.cpp.o

[ 50%] Building CXX object CMakeFiles/feature_training.dir/feature_training.cpp.o

make[1]: *** [CMakeFiles/Makefile2:139: CMakeFiles/gen_vocab.dir/all] Error 2

make[1]: *** Waiting for unfinished jobs....

make[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/feature_training.dir/all] Error 2

make[1]: *** [CMakeFiles/Makefile2:113: CMakeFiles/loop_closure.dir/all] Error 2

make: *** [Makefile:91: all] Error 2

2.解决方案

由于/usr/local/lib/中只有libDBoW3.so没有libDBoW3.a,将CMakeLists中libDBoW3.a改为libDBoW3.so即可,如下所示:

#set( DBoW3_LIBS "/usr/local/lib/libDBoW3.a" )

set( DBoW3_LIBS "/usr/local/lib/libDBoW3.so" )

#参考链接

make[2]: *** No rule to make target ‘/usr/local/lib/libDBoW3.a‘, needed by ‘feature_training‘. Stop_听雪楼主长恨水的博客-CSDN博客

高翔视觉slam十四讲第二版第十一章DBow3词库安装与出现的问题 - JavaShuo

  1. slambook-master/ch13

1.编译问题

[ 75%] Building CXX object CMakeFiles/pointcloud_mapping.dir/pointcloud_mapping.cpp.o

In file included from /usr/local/include/pcl-1.12/pcl/pcl_macros.h:74,

                 from /usr/local/include/pcl-1.12/pcl/impl/point_types.hpp:42,

                 from /usr/local/include/pcl-1.12/pcl/point_types.h:354,

                 from /mnt/d/slam14/slambook-master/ch13/dense_RGBD/pointcloud_mapping.cpp:9:

/usr/local/include/pcl-1.12/pcl/pcl_config.h:7:4: error: #error PCL requires C++14 or above

    7 |   # PCL requires C++14 or above

      |    ^~~~~

1.解决方案

在CMakeLists中添加

set( CMAKE_CXX_STANDARD 14)

2.编译问题

slambook-master/ch13/dense_RGBD/build# ./octomap_mapping

cannot find pose file

slambook-master/ch13/dense_RGBD/build# ./pointcloud_mapping

cannot find pose file

2.解决方案

回退到源码目录,执行./build/pointcloud_mapping命令,如下:

slambook-master/ch13/dense_RGBD# ./build/pointcloud_mapping

Segmentation fault

//TODO有待解决,可能是由于UI界面显示问题导致的

3.编译问题

CMake Error at CMakeLists.txt:11 (find_package):

  Could not find a configuration file for package "OpenCV" that is compatible

  with requested version "3.1".

  The following configuration files were considered but not accepted:

    /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.5

3.解决方案

将CMakeLists改为:

# opencv

#find_package( OpenCV 3.1 REQUIRED )

find_package( OpenCV REQUIRED )

4.编译问题

slambook-master/ch13/dense_monocular/dense_mapping.cpp:8:10: fatal error: sophus/se3.h: No such file or directory

    8 | #include <sophus/se3.h>

4.解决方案

// for sophus

//#include <sophus/se3.h>

#include <sophus/se3.hpp>

5.编译问题

/mnt/d/slam14/slambook-master/ch13/dense_monocular/dense_mapping.cpp:402:34: error: ‘CV_GRAY2BGR’ was not declared in this scope

  402 |     cv::cvtColor( ref, ref_show, CV_GRAY2BGR );

5.解决方案

这是由于OpenCV版本更新导致的,用COLOR_GRAY2BGR替换掉CV_GRAY2BGR即可。

6.编译问题

slambook-master/ch13/dense_monocular/dense_mapping.cpp:51:15: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’

   51 |     vector<SE3>& poses

      |               ^

/mnt/d/slam14/slambook-master/ch13/dense_monocular/dense_mapping.cpp:51:15: note:   expected a type, got ‘SE3’

/mnt/d/slam14/slambook-master/ch13/dense_monocular/dense_mapping.cpp:51:15: error: template argument 2 is invalid

/mnt/d/slam14/slambook-master/ch13/dense_monocular/dense_mapping.cpp:58:11: error: invalid use of template-name ‘Sophus::SE3’ without an argument list

   58 |     const SE3& T_C_R,

6.解决方案

//TODO

将SE3修改为SE3d,例如:

//using Sophus::SE3;

using Sophus::SE3d;

7.编译问题

/mnt/d/slam14/slambook-master/ch13/dense_monocular/dense_mapping.cpp:351:25: error: ‘using SE3d = class Sophus::SE3<double>’ {aka ‘class Sophus::SE3<double>’} has no member named ‘rotation_matrix’; did you mean ‘rotationMatrix’?

  351 |     Vector3d f2 = T_R_C.rotation_matrix() * f_curr;

      |                         ^~~~~~~~~~~~~~~

      |                         rotationMatrix

7.解决方案

将‘rotation_matrix’修改为‘rotationMatrix’

8.编译问题

[100%] Linking CXX executable dense_mapping

/usr/bin/ld: CMakeFiles/dense_mapping.dir/dense_mapping.cpp.o: in function `Sophus::SO3Base<Sophus::SO3<double, 0> >::normalize() [clone .part.0]':

dense_mapping.cpp:(.text+0x171): undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'

/usr/bin/ld: CMakeFiles/dense_mapping.dir/dense_mapping.cpp.o: in function `updateDepthFilter(Eigen::Matrix<double, 2, 1, 0, 2, 1> const&, Eigen::Matrix<double, 2, 1, 0, 2, 1> const&, Sophus::SE3<double, 0> const&, cv::Mat&, cv::Mat&)':

8.解决方案

在CMakeLists中添加fmt库链接,如下所示:

#target_link_libraries( dense_mapping ${THIRD_PARTY_LIBS})

target_link_libraries( dense_mapping ${THIRD_PARTY_LIBS} fmt)

9.编译问题

slambook-master/ch13/dense_RGBD# pcl_viewer map.pcd

2022-02-09 00:18:10.525 (   0.158s) [        7B4A0800] vtkContextDevice2D.cxx:32    WARN| Error: no override found for 'vtkContextDevice2D'.

The viewer window provides interactive commands; for help, press 'h' or 'H' from within the window.

> Loading map.pcd 2022-02-09 00:18:10.964 (   0.597s) [        7B4A0800]vtkXOpenGLRenderWindow.:1212   ERR| vtkXOpenGLRenderWindow (0x5606ef7f5b80): bad X server connection. DISPLAY=

Aborted

9.解决方案

//TODO有待解决掉其他问题后一并解决

应该是由于wsl没有安装UI界面,导致编译的程序调用界面显示时不能显示所致。

其他说明

slambook-master/ch13/dense_monocular编译完后,需要下载remode_test_data.zip并解压到源码目录(下载链接http://rpg.ifi.uzh.ch/datasets/remode_test_data.zip)。然后进入slambook-master/ch13/dense_monocular/build目录,执行./dense_mapping ../test_data即可运行。

#参考链接【读书笔记】《视觉SLAM十四讲(高翔著)》 第13讲_dahailuoa6的博客-CSDN博客

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值