首先恭喜你看到这篇博客,我已经把弯路走遍了,你可以直接少走30年弯路
目录
一、安装依赖
二、安装编译gtsam
三、安装编译LeGo-LOAM
四、LeGo-LOAM复现
1.安装依赖项
(我把过程中出现的报错整理放最后了,红色数字对应,请移步后面对应解决“报错问题”)
(不记得报错 3 opencv 和报错 4 pcl在那个地方运行报错了,先写在这里,后续知道或者告知我再改)
sudo apt-get install libboost-all-dev
sudo apt-get install cmake
sudo apt-get install libtbb-dev
sudo apt-get install libparmetis-dev
Boost >= 1.43
gcc >= 4.7.3
CMake >= 3.0
2.安装编译gtsam
1.压缩包下载
压缩包下载连接(解压压缩包安装):
https://research.cc.gatech.edu/borg/download?destination=node%2F299
2.git安装(gtsam出现debug报错0)(我进行make check出现报错1)
cd gtsam/
mkdir build &&cd build
cmake ..
make check
sudo make install
check和install很慢,根据情况加入多线程(-j12)或其他线程报错2
make check -j12
sudo make install -j12
3.安装编译LeGo-LOAM
参考:
LeGO-LOAM:Ubuntu20.04下的编译与运行_lego loam ubuntu 20.04 yuanma-CSDN博客
cd ~/legoloam_ws/src
git clone https://github.com/RobustFieldAutonomyLab/LeGO-LOAM.git
cd ..
catkin_make -j1
单独编译ROS包
catkin_make -DCATKIN_WHITELIST_PACKAGES="lego_loam;cloud_msgs"
第一次编译代码时,需要在“catkin_make”后面加上“-j1”来生成一些消息类型。以后的编译不需要“-j1”。
4.LeGo-SLAM数据集复现
4.1数据集下载
LeGO-LOAM:Ubuntu20.04下的编译与运行_lego loam ubuntu 20.04 yuanma-CSDN博客
直接参考上面链接博主(NSH indoor outdoor 数据集,云盘失效可以去评论区看或者官网)
4.2在legoloam_ws文件下source并代码运行
roslaunch lego_loam run.launch
4.3在LeGo-Loam文件夹下运行运行数据包
rosbag play *.bag --clock --topic /velodyne_points /imu/data
4.3在LeGo-Loam文件夹下运行运行数据包
4.4rviz设置(save config)
报错Failed to transform from frame [/camera] to frame [map]
找到~/legoloam_ws/src/LeGO-LOAM/LeGO-LOAM/src下的.cpp文件(ctrl+F查找)
将/registered_cloud
对应的发布者pubRegisteredCloud的 / 删除
例如:
cloudMsgTemp.header.frame_id = "/camera_init";
pubRegisteredCloud.publish(cloudMsgTemp);
改为
cloudMsgTemp.header.frame_id = "camera_init";
pubRegisteredCloud.publish(cloudMsgTemp);
运行结果:(还有部分点云未调好)
我rviz设置如下(可根据自己需要设置)
报错问题汇总
(报错1)出现了(行数可能不一样):
CMake Warning (dev) at gtsam/CMakeLists.txt:105 (target_link_libraries):
Link library type specifier "debug" is followed by specifier "optimized"
instead of a library name. The first specifier will be ignored.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at gtsam/CMakeLists.txt:105 (target_link_libraries):
The "debug" argument must be followed by a library.
-- Configuring incomplete, errors occurred!
See also "/home/hawkbot/gtsam/build/CMakeFiles/CMakeOutput.log".
See also "/home/hawkbot/gtsam/build/CMakeFiles/CMakeError.log".
解决:将debug注释掉
1.找到(gtsam/CMakeLists.txt)如下:
if (GTSAM_DISABLE_NEW_TIMERS)
message("WARNING: GTSAM timing instrumentation manually disabled")
list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC DGTSAM_DISABLE_NEW_TIMERS)
else()
if(Boost_TIMER_LIBRARY)
list(APPEND GTSAM_BOOST_LIBRARIES
optimized ${Boost_TIMER_LIBRARY_RELEASE}
optimized ${Boost_CHRONO_LIBRARY_RELEASE}
#debug ${Boost_TIMER_LIBRARY_DEBUG}
#debug ${Boost_CHRONO_LIBRARY_DEBUG}
)
else()
list(APPEND GTSAM_BOOST_LIBRARIES rt) # When using the header-only boost timer library, need -lrt
message("WARNING: GTSAM timing instrumentation will use the older, less accurate, Boost timer library because boost older than 1.48 was found.")
endif()
endif()
2.找到(gtsam/wrap/CMakeLists.txt)如下:
set(WRAP_BOOST_LIBRARIES
optimized
${Boost_FILESYSTEM_LIBRARY_RELEASE}
${Boost_SYSTEM_LIBRARY_RELEASE}
${Boost_THREAD_LIBRARY_RELEASE}
# debug
#${Boost_FILESYSTEM_LIBRARY_DEBUG}
#${Boost_SYSTEM_LIBRARY_DEBUG}
#${Boost_THREAD_LIBRARY_DEBUG}
完成后重新之前的操作
(报错1)在check中出现(不知啥问题,别人博客中同样存在,出现没有影响后续的install)
error: invalid initialization of reference of type ‘const std::vector<bool>&’ from expression of type ‘const std::vector<long unsigned int>’
124 | const std::vector<bool>& mask() const { return mask_; }
其中还写了一个install中出现的bug(我也是一样的问题,暂时没出现影响)
(报错2)我用的虚拟机,出现这个,内存不足的问题,减少线程数
c++: fatal error: 已杀死 signal terminated program cc1plus
compilation terminated.
(报错3)出现opencv报错
参考:
LeGO-LOAM:Ubuntu20.04下的编译与运行_lego loam ubuntu 20.04 yuanma-CSDN博客
/home/hawkbot/legoloam_ws/src/LeGO-LOAM/LeGO-LOAM/include/utility.h:13:10: fatal error: opencv/cv.h: 没有那个文件或目录
13 | #include <opencv/cv.h>
| ^~~~~~~~~~~~~
fatal error: opencv/cv.h: 没有那个文件或目录 13 | #include <opencv/cv.h>
报错原因:这是由于20.04自带的是OpenCV4。
~/legoloam_ws/src/LeGO-LOAM/LeGO-LOAM/includ下的utility.h文件
#include<opencv/cv.h>
修改为
#include<opencv2/imgproc.hpp>
(报错4)继续编译又出现关于点云pcl库的问题
POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::CPPFSignature,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pcl-1.10/pcl/point_types.h:574:1: error: ‘minusscalar’ is not a member of ‘pcl::traits’
报错原因:这是由于用的C++11,但是需要支持C++14,解决如下:
将legoloam_ws/src/LeGO-LOAM/LeGO-LOAM下的CMakeLists.txt文件:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3")
改为如下
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
还有报错:‘Index’ is not a member of ‘Eigen’等其他请看这篇博客(我没遇到就没加上了)
LeGO-LOAM:Ubuntu20.04下的编译与运行_lego loam ubuntu 20.04 yuanma-CSDN博客
标签:LeGO,LOAM,LeGo,LIBRARY,报错,gtsam,Boost,20.04 From: https://blog.csdn.net/qq_53004665/article/details/141346191