本文参考的链接如下,感谢以下参考文章的原作者:
1. https://blog.csdn.net/sru_alo/article/details/87450161 (雷达3D点云数据转2D激光数据)
2. https://blog.csdn.net/geerniya/article/details/84880514 (Robosense 激光雷达slam建图(2):使用pointcloud_to_laserscan包实现三维转二维)
3. https://blog.csdn.net/xingdou520/article/details/85098314 (3D激光雷达传感器建图:速腾聚创、velodyne建图过程总结)
4. https://www.cnblogs.com/lightweh/p/10076294.html(Velodyne VLP-16 gmapping 建图)
正文:
1、新建一个名叫catkin_ws的工程:
mkdir -p catkin_ws/src
cd catkin_ws/src
cd ..
catkin_initworkspace
2、下载激光雷达的ROS接口驱动和point_to_laserscan包:(此时路径:~/catkin_ws/src)
git clone https://github.com/ros-drivers/velodyne.git
git clone https://github.com/ros-perception/pointcloud_to_laserscan
catkin_make
source devel/setup.bash
(注意①记得在home目录下的.bashrc文件中添加该工程的路径,然后source一下。)
(注意②编译时可能会出现少包,通过“sudo apt-get install ros-kinetic-什么包”安装即可)
3、 连接激光雷达
网线直连本机与激光雷达,已知 Velodyne VLP-16 的 IP 地址为 192.168.1.201,配置本机地址为 192.168.1.77,打开浏览器输入 192.168.1.201 查看激光雷达的配置文件,将 Host (Destination) 的 IP 地址修改成与本机的IP相同。
4、 把 Velodyne VLP-16.xml 转换成 VLP-16.yaml 文件
rosrun velodyne_pointcloud gen_calibration.py ~/VLP-16.xml #这个“~”就是直接home目录下就行,而不是在工程内。
5、创建launch文件
cd ~/catkin_ws/src/pointcloud_to_laserscan/launch
nano vlidar.launch #名字随意
在打开的文本中输入如下:(注意看第六行的注释)
<?xml version="1.0"?>
<launch>
<!-- run pointcloud_to_laserscan node -->
<node pkg="pointcloud_to_laserscan" type="pointcloud_to_laserscan_node" name="pointcloud_to_laserscan">
<remap from="cloud_in" to="/velodyne_points"/> #注意这里写的是velodyne,如果是其他雷达的话,可以通过打开点云程序,然后rostopic list 便得知是什么points了
<remap from="scan" to="/velodyne/scan"/>
<rosparam>
# target_frame: rslidar # Leave disabled to output scan in pointcloud frame
transform_tolerance: 0.01
min_height: -0.4
max_height: 1.0
angle_min: -3.1415926 # -M_PI
angle_max: 3.1415926 # M_PI
angle_increment: 0.003 # 0.17degree
scan_time: 0.1
range_min: 0.2
range_max: 100
use_inf: true
inf_epsilon: 1.0
# Concurrency level, affects number of pointclouds queued for processing and number of threads used
# 0 : Detect number of cores
# 1 : Single threaded
# 2->inf : Parallelism level
concurrency_level: 1
</rosparam>
</node>
</launch>
参数说明:
min_height 、max_height #这两个参数用来指定这段z轴高度范围内的输入点云将参与转换,范围外的不参与
angle_min、angle_max #这两个参数用来指定这段yaw角度范围内的输入点云将参与转换,范围外的不参与
angle_increment #输出的2d雷达数据的角分辨率,即相邻扫描点的角度增量
scan_time #扫描时间,即话题的发布周期
range_min、range_max #这两个参数用来指定输出数据的有效距离,即2d雷达的有效测量范围
6、打开新终端,启动雷达:
roslaunch velodyne_pointcloud VLP16_points.launch
rosrun rviz rviz
再修改Global Options/Fixed Frame为velodyne
然后在rviz中点“Add→By Topic”增加velodyne_points/PointCloud2,即可实时显示获取的3D点云数据。(此时若点“add→by topic→laserscan”也可看到单线(彩色线条))
7、接下来是把3D点云转成2D:
关掉rviz,其余不要关,再打开新终端,输入:
roslaunch pointcloud_to_laserscan rslidar.launch
添加话题,“add→by topic→/vlidar/scan”,
即可看到:(白色线条)
问题:白色(经过转换的)的lasercan和彩色(官方生成的)的laserscan有什么不同?