赞
踩
最终我们是要实现slam功能,而slam需要的是2D激光雷达,因此我们首先需要将3D线束转换成2D线束。可以通过pointcloud_to_laserscan包实现。
1,安装pointcloud_to_laserscan包
- cd ~/catkin_ws/src
- git clone https://github.com/ros-perception/pointcloud_to_laserscan.git
-
- cd ~/catkin_ws
- catkin_make
2,创建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="/rslidar_points"/>
-
- <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>
这里需要注意的是这句代码:<remap from="cloud_in" to="/rslidar_points"/>。因为激光雷达节点发布的信息是/rslidar_points,因此需要将pointcloud_to_laserscan的订阅信息从默认的cloud_in改为/rslidar_points。
3,启动ros_rslidiar雷达驱动包和pointcloud_to_laserscan节点
雷达驱动发布三维点云数据/rsldiar_points, pointcloud_to_laserscan节点订阅后将其转换成laserscan话题/scan,两者的frame_id都是“rslidar”。
- #新开一个终端,启动3d雷达驱动
- roslaunch rslidar_pointcloud rs_lidar_16.launch
- #新开一个终端,启动pointcloud_to_laserscan节点
- roslaunch pointcloud_to_laserscan point_to_scan.launch
这时我们可以看到三维点云数据,如果想要显示二维点云,还需要在rviz中添加laserscan. 然后将topic改为/scan即可。如下图所示,白线即为二维点云图:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。