编译正常,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/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
| ^~~~~~~
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/useSophus/useSophus.cpp:5:10: fatal error: Eigen/Core: No such file or directory
5 | #include
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
#include
改为
#include
#include
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: "< 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 :"< 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 33 | cout<<"so3 hat=\n"< 4.解决方案 因新版本Sophus库打印需要log()函数:,将代码useSophus.cpp中: cout<<"SO(3) from matrix: "< 改为: cout<<"SO(3) from matrix: "< 5.编译问题 /usr/bin/ld: CMakeFiles/useSophus.dir/useSophus.cpp.o: in function `std::make_unsigned 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/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 | 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/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 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 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 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 39 | BlockSolver | ^~~~~~~~~~~~~~~~~~~ /usr/local/include/g2o/core/block_solver.hpp:39:68: note: no known conversion for argument 1 from ‘g2o::BlockSolver 39 | BlockSolver | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ /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 std::unique_ptr //Block* solver_ptr = new Block( linearSolver ); // 矩阵块求解器 std::unique_ptr // 梯度下降方法,从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.编译问题 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 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 #参考链接 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 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 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 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 std::unique_ptr //Block* solver_ptr = new Block ( linearSolver ); // 矩阵块求解器 //std::unique_ptr std::unique_ptr //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* solver_ptr = new Block( linearSolver ); // 矩阵块求解器 //std::unique_ptr Block* solver_ptr = new Block( std::unique_ptr //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 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.编译问题 (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 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 /mnt/d/slam14/slambook-master/ch8/directMethod/direct_semidense.cpp:266:62: error: no matching function for call to ‘g2o::BlockSolver 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 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 //DirectBlock::LinearSolverType* linearSolver = new g2o::LinearSolverDense< DirectBlock::PoseMatrixType > (); std::unique_ptr //DirectBlock* solver_ptr = new DirectBlock ( linearSolver ); std::unique_ptr // 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 //DirectBlock::LinearSolverType* linearSolver = new g2o::LinearSolverDense< DirectBlock::PoseMatrixType > (); std::unique_ptr //DirectBlock* solver_ptr = new DirectBlock ( linearSolver ); std::unique_ptr // 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.编译问题 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 2.解决方案 因新版本Sophus库中头文件名有改变,将代码common_include.h:32中 // for Sophus #include 改为 // for Sophus //#include #include 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 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 194 | Block* solver_ptr = new Block( linearSolver ); 5.解决方案 将visual_odometry.cpp中相关代码修改如下: // using bundle adjustment to optimize the pose typedef g2o::BlockSolver //Block::LinearSolverType* linearSolver = new g2o::LinearSolverDense std::unique_ptr //Block* solver_ptr = new Block( linearSolver ); std::unique_ptr //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 | ^ 6.解决方案 // project中0.1、0.2、0.3、0.4项目中均有此问题。 由于Sophus::SE3和Sophus::SO3在Sophus库新版本中都是模板类,需要声明模板类的数据类型,有两种办法: (1)一种办法是 using Sophus::SE3; using Sophus::SO3; SE3 SO3 (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 // Vector3d( tvec.at // 此处旋转向量经罗德里格斯转换 Mat R; cv::Rodrigues(rvec, R); Eigen::Matrix3d RE; RE << R.at R.at R.at // SO3构造函数参数为旋转矩阵 T_c_r_estimated_ = SE3d( SO3d(RE), Vector3d(tvec.at #参考链接 关于使用新版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 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 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 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 | ^~~ /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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #参考链接: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 | ^~~~~~ 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 | ^~~~~~ 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.编译问题 /mnt/d/slam14/slambook-master/ch10/ceres_custombundle/common/BALProblem.cpp:8:10: fatal error: Eigen/Core: No such file or directory 8 | #include 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 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 4.解决方案 运行命令应该按照bundle_adjuster -input ./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 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 /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 136 | solver = new g2o::OptimizationAlgorithmLevenberg(solver_ptr.get()); 6.解决方案 //this function is unused yet.. //void SetMinimizerOptions(std::shared_ptr void SetMinimizerOptions(std::unique_ptr { //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 std::unique_ptr if(params.linear_solver == "dense_schur" ){ //linearSolver = new g2o::LinearSolverDense linearSolver = g2o::make_unique } else if(params.linear_solver == "sparse_schur"){ //linearSolver = new g2o::LinearSolverCholmod //dynamic_cast auto cholesky = g2o::make_unique cholesky->setBlockOrdering(true); linearSolver = std::move(cholesky); } //solver_ptr = new BalBlockSolver(linearSolver); std::unique_ptr //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 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 146 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } 8.解决方案 //TODO未解决 1.编译问题 (1)slambook-master/ch11/pose_graph_gtsam.cpp:6:10: fatal error: sophus/se3.h: No such file or directory 6 | #include | ^~~~~~~~~~~~~~ (2)slambook-master/ch11/pose_graph_g2o_lie_algebra.cpp:15:10: fatal error: sophus/se3.h: No such file or directory 15 | #include 1.解决方案 (1)将slambook-master/ch11/pose_graph_gtsam.cpp:6中代码修改如下: //#include //#include #include #include (2)将slambook-master/ch11/pose_graph_g2o_lie_algebra.cpp:15中代码修改如下: //#include //#include #include #include 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 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 类似的问题将SO3修改为SO3 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 //Block::LinearSolverType* linearSolver = new g2o::LinearSolverCholmod std::unique_ptr //Block* solver_ptr = new Block ( linearSolver ); // 矩阵块求解器 std::unique_ptr // 梯度下降方法,从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 77 | Sophus::SO3 5.解决方案 //TODO 有待解决 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.编译问题 [ 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 4.解决方案 // for sophus //#include #include 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 51 | vector | ^ /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 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 dense_mapping.cpp:(.text+0x171): undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view /usr/bin/ld: CMakeFiles/dense_mapping.dir/dense_mapping.cpp.o: in function `updateDepthFilter(Eigen::Matrix 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博客