系统环境:Ubuntu18.04.6 LTS
1.Loam的安装前要求:
1.1 ROS安装:参考我的另一篇博客
1.2 PCL安装:
2.安装:
2.1.建立catkin工作空间(我取名为catkin_loam_velodyne)
2.2.建立src文件夹
2.3.编译
- cd ~/catkin_loam_velodyne/src/
- git clone https://github.com/laboshinl/loam_velodyne.git
- cd ~/catkin_loam_velodyne
- catkin_make -DCMAKE_BUILD_TYPE=Release
3.编译出现的问题:
3.1.找不到pcl_conversions:
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "pcl_conversions"
with any of the following names:
pcl_conversionsConfig.cmake
pcl_conversions-config.cmake
Add the installation prefix of "pcl_conversions" to CMAKE_PREFIX_PATH or
set "pcl_conversions_DIR" to a directory containing one of the above files.
If "pcl_conversions" provides a separate development package or SDK, be
sure it has been installed.
Call Stack (most recent call first):
loam_velodyne/CMakeLists.txt:4 (find_package)

原因:缺少某些库
解决办法:
- sudo apt-get install libvtk6-jni
- sudo apt-get install libvtk6-java
- sudo apt-get install libvtk6-dev
- sudo apt-get install libvtk6-qt-dev
- sudo apt-get install libpcl-dev
- sudo apt-get install ros-melodic-pcl-conversions
- sudo apt-get install ros-melodic-pcl-ros
- sudo apt-get install ros-melodic-navigation
以下代码只针对Ubuntu18.04对应的ROS melodic版本,其余版本可将代码中melodic自行替换为相应的版本。
4.运行Loam:
Shell1:
- source ~/catkin_slam/catkin_loam_velodyne/devel/setup.bash
-
- roslaunch loam_velodyne loam_velodyne.launch
Shell2:(跑Loam的数据集)
rosbag play ~/Dataset/A-LOAM/nsh_indoor_outdoor.bag
结果:

5.运行出现的问题:
5.1.找不到package路径:
ERROR: cannot launch node of type [loam_velodyne/multiScanRegistration]: Cannot locate node of type [multiScanRegistration] in package [loam_velodyne]. Make sure file exists in package path and permission is set to executable (chmod +x)
ERROR: cannot launch node of type [loam_velodyne/laserOdometry]: Cannot locate node of type [laserOdometry] in package [loam_velodyne]. Make sure file exists in package path and permission is set to executable (chmod +x)
ERROR: cannot launch node of type [loam_velodyne/laserMapping]: Cannot locate node of type [laserMapping] in package [loam_velodyne]. Make sure file exists in package path and permission is set to executable (chmod +x)
ERROR: cannot launch node of type [loam_velodyne/transformMaintenance]: Cannot locate node of type [transformMaintenance] in package [loam_velodyne]. Make sure file exists in package path and permission is set to executable (chmod +x)

原因:编译的时候devel/lib没生成对应文件
解决办法:删除build和devel文件夹,重新编译即可
5.2.线程down掉
[multiScanRegistration-2] process has died [pid 5419, exit code -11, cmd /home/shuhang/catkin_slam/catkin_loam_velodyne/devel/lib/loam_velodyne/multiScanRegistration /multi_scan_points:=/velodyne_points __name:=multiScanRegistration __log:=/home/shuhang/.ros/log/8ec97a84-24a3-11ee-a67c-49f24c8dffb1/multiScanRegistration-2.log].
log file: /home/shuhang/.ros/log/8ec97a84-24a3-11ee-a67c-49f24c8dffb1/multiScanRegistration-2*.log

原因:本人后来重装Ubuntu就暂时没有这个问题了,怀疑是PCL版本不匹配的问题
解决办法:卸载PCL并重装
第一次装Loam的时候各种问题,装PCL的时候也是各种问题。重装Ubuntu后安装PCL极其顺利,Loam也极其顺利。如果Loam编译和运行很艰难,多半是PCL的问题。