从nsh_indoor_outdoor.bag创建的示例地图(使用ccviewer打开)Sample map built from nsh_indoor_outdoor.bag (opened with ccViewer)
用ROS Indigo和Velodyne VLP16测试白色勾号。(屏幕放映) (Screencast)
所有资料均取自ROS文件 ROS documentation。
在这里提问 here。
如何用catkin建造
$ cd ~/catkin_ws/src/
$ git clone https://github.com/laboshinl/loam_velodyne.git
$ cd ~/catkin_ws
$ catkin_make -DCMAKE_BUILD_TYPE=Release
$ source ~/catkin_ws/devel/setup.bash
运行
roslaunch loam_velodyne loam_velodyne.launch
在第二终端播放中,来自VLP16 Rosbag的Velodyne数据示例:VLP16 rosbag
rosbag play ~/Downloads/velodyne.bag
或从Velodyne VLP16样品PCAP中读取:VLP16 sample pcap
roslaunch velodyne_pointcloud VLP16_points.launch pcap:="$HOME/Downloads/velodyne.pcap"
故障排除
多扫描注册在播放包文件后立即崩溃 multiScanRegistration
crashes right after playing bag file
问题#71 and #7解决了这个问题。当前已知的解决方案是从源代码构建与系统上相同版本的PCL,并相应地设置cmake_前缀_路径,以便catkin可以找到它。有关详细信息,请参阅此this issue问题。
土木工程用壤土航空激光雷达精度的量化。德里克·安东尼·沃尔夫
ROS和LOAM维洛丁
ROS_MASTER_URI=http://localhost:11311
ERROR: cannot launch node of type [loam_velodyne/multiScanRegistration]: can't locate node [multiScanRegistration] in package [loam_velodyne]
ERROR: cannot launch node of type [loam_velodyne/laserOdometry]: can't locate node [laserOdometry] in package [loam_velodyne]
ERROR: cannot launch node of type [loam_velodyne/laserMapping]: can't locate node [laserMapping] in package [loam_velodyne]
ERROR: cannot launch node of type [loam_velodyne/transformMaintenance]: can't locate node [transformMaintenance] in package [loam_velodyne]
The following cmd may help you:locate pcl_conversionsConfig.cmake
If no file found, you have to install the package. you can install it from apt by typing:sudo apt-get install ros-
-----------------------------------------
Remove the apt installed pcl libsudo apt-get remove --purge libpcl*
Verify loam cannot find any pcl lib
cd path/to/your/catkin_ws
rm -rf build devel
catkin_make
If the build failed due to lack of pcl lib, then you have removed pcl successfully :)
I solved it by installing pcl-1.9 from source, and everything is okay since then
You can download the latest release from here: https://github.com/PointCloudLibrary/pcl/releases
And the installation from source steps can be found here: http://www.pointclouds.org/documentation/tutorials/compiling_pcl_posix.php
对于LOAM和ROS的教程大部分都不是很详细,尤其是对于一些报错的解决方法,这周成功编译并运行了LOAM,把详细过程以及遇到的问题记录下来以供交流备份。
一.环境的安装(已安装Ubuntu和ROS的可以跳过)
1.LOAM是在ubuntu系统下运行的,16.04和14.04都可以,不推荐虚拟机使用ubuntu,容易遇到很多错误,推荐双系统安装 Ubuntu16.04,
2.在Ubuntu系统下,想编译使用LOAM,需要安装ROS,安装方法见ROS wiki,这里只提供Ubuntu 16.04加ROS kinetic的安装方法 http://wiki.ros.org/cn/kinetic/Installation/Ubuntu 如果在初始化rosdep时遇到问题,更换网络或者使用流量开热点,一般就可以解决。这个问题常出现于网络情况不好。
二.LOAM的依赖的安装
LOAM的编译和运行需要使用PCL,如果使用的是Ubuntu 16.04和Kinetic,需要使用源代码进行编译安装PCL1.8,作者实测如果使用apt-get安装的pcl1.7会造成后续运行LOAM时multiScanRegistration出错,如果已经安装了PCL1.7,可以先卸载PCL1.7
sudo apt-get remove libpcl1.7
sudo apt-get remove libpcl-*
如果遇到*号的报错,输入 (原因:如果使用zsh等SHELL,不支持通配符,可以切换到bash来执行也可以修改zshrc来支持通配符,本文只提供切换方法,如果需要修改zshrc,请在zshrc后输入setopt nonomatch )
/bin/bash
后再重新执行。再卸载时可能会卸载掉一部分的ROS文件,选Yes就可以,后续编译安装PCL1.8后可以再安装ROS的文件。
安装PCL的依赖
sudo apt-get update
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common
sudo apt-get install libflann1.8 libflann-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libvtk5.10-qt4 libvtk5.10 libvtk5-dev
sudo apt-get install libqhull* libgtest-dev
sudo apt-get install freeglut3-dev pkg-config
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install mono-complete
sudo apt-get install qt-sdk openjdk-8-jdk openjdk-8-jre
在安装依赖时遇见vtk5的那个输入后会提示卸载一堆东西,这行可以直接跳过。
下载PCL的源码
git clone https://github.com/PointCloudLibrary/pcl.git
如果没有安装git,可以输入来安装Git。
sudo apt-get install git
编译PCL源码
首先进入pcl的源代码文件新建release文件夹并执行cmake
cd pcl
mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON \
-DCMAKE_INSTALL_PREFIX=/usr ..
cmake成功后开始进行编译,如果你的电脑cpu为8线程使用
make -j8
如果为4线程输入,依次类推2线程,6线程
make -j4
推荐使用cpu的最大线程来编译,作者使用7700hq 8线程编译了大约20分钟。中途的Warning可以无视
编译成功后输入进行安装
sudo make install
之后使用apt-get安装ROS的一些文件
sudo apt-get install ros-kinetic-pcl-conversions ros-kinect-pcl-ros
至此,PCL1.8使用源代码编译安装的过程已经完成。
三.Loam的编译安装
1.Loam的编译需要使用catkin,如果已经建立catkin_ws,可以跳过下面这步
mkdir -p catkin_ws/src
cd catkin_ws/src
catkin_init_workspace
2.下载Loam的源码
cd ~/catkin_ws/src # catkin_ws自己的ROS工作空间。
git clone https://github.com/laboshinl/loam_velodyne.git
在编译安装之前,Loam的代码一部分需要修改,具体可以参照https://github.com/laboshinl/loam_velodyne/pull/84/files 把src/lib/LaserMapping.cpp 的139-153行注释掉
3.编译Loam
cd catkin_ws
catkin_make
source ~/devel/setup.bash
至此,Loam已经编译完成
四.Loam的运行
1.使用bag文件
roslaunch loam_velodyne loam_velodyne.launch
运行后会打开rviz并等待雷达数据。
播放bag
本文提供ROS wiki http://wiki.ros.org/loam_velodyne上无imu信息的bag百度云链接
链接: https://pan.baidu.com/s/18ISyr4ky2MfTl7TXJD2W-A 提取码: 2yea
下载后,输入
rosbag play ~/nsh_indoor_outdoor.bag
至此,可以在RVIZ里面观察到点云了
2.使用pcap文件:
安装驱动
sudo apt-get install ros-kinetic-velodyne
播放pcap文件
rosrun velodyne_driver velodyne_node _model:=VLP16 _pcap:=/home/wangzhiyong/dianyun1.pcap _read_once:=true
需要修改pcap文件的路径以及名称
五.错误处理
1.multiScanRegistration报错
如果在运行Loam后播放bag提示multiScanRegistration错误,原因是使用apt-get 安装了编译好的pcl,需要按照第二部分进行卸载PCL并下载源代码编译安装PCL,之后需要重新catkin_make
2.error: ‘downSizeFilterMap’ was not declared in this scope错误
catkin_make时可能会出现error: ‘downSizeFilterMap’ was not declared in this scope错误,这是因为没有修改Loam的源代码,参照https://github.com/laboshinl/loam_velodyne/pull/84/files 把src/lib/LaserMapping.cpp 的139-153行注释掉
3.提示缺少ROS package
输入
sudo apt-get install ros-kinetic-xxxxxxxx
来安装缺少的xxxxxx package。
Loam建好的地图的保存以及转pcd,ply和播放pcap格式的文件可以参考
https://blog.csdn.net/qq_36396941/article/details/83048415
使用vlp16运行Loam参考
---------------------------------------
I installed PCL.1.9.1 from source and tried to launch the file again.
This time, the SLAM was working but only for a few seconds. Then I got a segmentation fault.
Here is my gdb traceback.
my cpu details,
You can try removing the line:
loam_velodyne/CMakeLists.txt
add_definitions( -march=native )