激光slam学习笔记4--slam_in_autonomous_driving编译碰到问题汇总

背景:项目需要,学习一些imu姿态估计知识。从组长那边借来高翔新作:自动驾驶与机器人中的slam技术,仔细看一看。环境,ubuntu20.04。

一、资料准备

课本对应的代码

一些依赖,首先参考github上对应的readme介绍安装

二、踩到的坑

报错1:

cpp 复制代码
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CHOLMOD_LIBRARY
    linked by target "run_gins_pre_integ" in directory /home/ylh/code_ws/slam_in_autonomous_driving/src/ch4

解决方式:

cpp 复制代码
sudo apt install libcholmod3 libsuitesparse-dev

报错2:

cpp 复制代码
/home/ylh/code_ws/slam_in_autonomous_driving/thirdparty/g2o/g2o/core/openmp_mutex.h:30:10: fatal error: g2o/config.h: No such file or directory
   30 | #include "g2o/config.h"

解决方式:

cpp 复制代码
将thirdparty/g2o/build/g2o/config.h拷贝到thirdparty/g20/目录下

报错3:

cpp 复制代码
fatal error: velodyne_msgs/VelodyneScan.h: No such file or directory
   18 | #include "velodyne_msgs/VelodyneScan.h"

解决方式:

cpp 复制代码
sudo apt install ros-noetic-velodyne-msgs安装消息依赖

报错4:

cpp 复制代码
make[2]: *** No rule to make target 'gmock', needed by '../bin/test_nn'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:4227: src/ch5/CMakeFiles/test_nn.dir/all] Error 2

解决方式:

修改ch4、ch5对应的cmakelists.txt:

ch4:

cpp 复制代码
# 查找 Google Test,它应该也包含了 Google Mock
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
 
# 添加您的库
add_library(${PROJECT_NAME}.ch4
        gins_pre_integ.cc
        imu_preintegration.cc
        g2o_types.cc
)
 
# 添加您的测试可执行文件
add_executable(test_preintegration test_preintegration.cc)
 
# 链接 Google Test (它应该包含了 gmock) 以及其他依赖项
target_link_libraries(test_preintegration
        ${GTEST_LIBRARIES}
        pthread glog gflags ${PROJECT_NAME}.ch4 ${PROJECT_NAME}.ch3 ${PROJECT_NAME}.common
)
 
# 添加测试
add_test(NAME test_preintegration COMMAND test_preintegration)
 
# 添加其他可执行文件
add_executable(run_gins_pre_integ run_gins_pre_integ.cc)
target_link_libraries(run_gins_pre_integ
        ${PROJECT_NAME}.ch3
        ${PROJECT_NAME}.ch4
        ${G2O_LIBS}
)

ch5:

cpp 复制代码
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

add_executable(point_cloud_load_and_vis point_cloud_load_and_vis.cc)
target_link_libraries(point_cloud_load_and_vis
        ${PCL_LIBRARIES}
        ${GLOG_LIBRARIES}
        gflags
        )

add_executable(pcd_to_bird_eye pcd_to_bird_eye.cc)
target_link_libraries(pcd_to_bird_eye
        ${PCL_LIBRARIES}
        ${GLOG_LIBRARIES}
        ${OpenCV_LIBS}
        gflags
        )

add_executable(scan_to_range_image scan_to_range_image.cc)
target_link_libraries(scan_to_range_image
        ${PCL_LIBRARIES}
        ${GLOG_LIBRARIES}
        ${OpenCV_LIBS}
        gflags
        )

add_library(${PROJECT_NAME}.ch5
        bfnn.cc
        kdtree.cc
        octo_tree.cc
        )
target_link_libraries(${PROJECT_NAME}.ch5
        tbb
        )

add_executable(linear_fitting linear_fitting.cc)
target_link_libraries(linear_fitting
        ${PCL_LIBRARIES}
        ${GLOG_LIBRARIES}
        ${OpenCV_LIBS}
        gflags
        )

ADD_EXECUTABLE(test_nn test_nn.cc)
ADD_TEST(test_nn test_bfnn)

target_link_libraries(test_nn
        gtest pthread glog gflags ${PROJECT_NAME}.ch5 ${PROJECT_NAME}.common ${PCL_LIBRARIES} tbb
        )

参考

报错5:

cpp 复制代码
Failed to find glog - Could not find glog include directory

解决方式:

cpp 复制代码
sudo apt-get install libgoogle-glog-dev

三、小结

1、thirdparty目录下,对g2o、livox_ros_driver、Pangolin进行:

cpp 复制代码
mkdir build && cd build
cmake .. && make

其他包没有进行编译操作

2、确保上述对应的坑都踩了,编译时还提示奇奇怪怪错误,可将根目录下build删除新建,再进行cmake .. && make 操作

###################

好记性不如烂笔头

积跬步期千里

相关推荐
scdifsn4 小时前
动手学深度学习12.7. 参数服务器-笔记&练习(PyTorch)
pytorch·笔记·深度学习·分布式计算·数据并行·参数服务器
jackson凌7 小时前
【Java学习笔记】SringBuffer类(重点)
java·笔记·学习
huangyuchi.8 小时前
【Linux】LInux下第一个程序:进度条
linux·运维·服务器·笔记·进度条·c/c++
大写-凌祁9 小时前
论文阅读:HySCDG生成式数据处理流程
论文阅读·人工智能·笔记·python·机器学习
Unpredictable2229 小时前
【VINS-Mono算法深度解析:边缘化策略、初始化与关键技术】
c++·笔记·算法·ubuntu·计算机视觉
傍晚冰川10 小时前
FreeRTOS任务调度过程vTaskStartScheduler()&任务设计和划分
开发语言·笔记·stm32·单片机·嵌入式硬件·学习
Love__Tay11 小时前
【学习笔记】Python金融基础
开发语言·笔记·python·学习·金融
半导体守望者12 小时前
ADVANTEST R3764 66 R3765 67爱德万测试networki connection programming网络程序设计手册
经验分享·笔记·功能测试·自动化·制造
柠石榴13 小时前
【论文阅读笔记】《A survey on deep learning approaches for text-to-SQL》
论文阅读·笔记·深度学习·nlp·text-to-sql
田梓燊14 小时前
数学复习笔记 27
笔记