Robosense 激光雷达slam建图(2):使用pointcloud_to_laserscan包实现三维转二维

在上一篇博文中,我们在linux中测试了Robosense 16线激光雷达。

最终我们是要实现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文件

cd ~/catkin_ws/src/pointcloud_to_laserscan/launch
gedit point_to_scan.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即可。如下图所示,白线即为二维点云图:

在这里插入图片描述

最后,运行rqt_graph可以直观的显示各个节点及消息的流程图,如下:

在这里插入图片描述

本文参考自:https://blog.csdn.net/bluewhalerobot/article/details/81673030。

  • 17
    点赞
  • 186
    收藏
    觉得还不错? 一键收藏
  • 52
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 52
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值