ROS 三维激光数据转化为二维激光数据

博客转自:https://blog.csdn.net/weixin_42005898/article/details/102498358 和 ros-perception

1. 安装pointcloud_to_laserscan包

cd /home/ke/ros/pointcloud_to_laserscan_ws/src
git clone https://github.com/ros-perception/pointcloud_to_laserscan.git
 
cd ..
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="/velodyne_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="/velodyne_points"/>。因为激光雷达节点发布的信息是/velodyne_points,因此需要将pointcloud_to_laserscan的订阅信息从默认的cloud_in改为/velodyne_points。我使用的是如下的包,可从网络上下载

发布的是/velodyne_points消息,类型为sensor_msgs/PointCloud2

3.启动pointcloud_to_laserscan节点和利用rosbag回放激光数据

#terminal 1
rocore
#terminal 2
rosbag plag out.bag

之后启动rviz 和 pointcloud_to_laserscan节点

#terminal 3
rosrun rviz rviz
#terminal 4
roslaunch pointcloud_to_laserscan point_to_scan.launch

效果如下,分别为三维点云,二维点云和混合效果

rviz的配置如下

Q1. 如何确定 Global Options的属性Fixed Frame: https://blog.csdn.net/sunyoop/article/details/78804941

Q2. 如何使用rosbag回放激光数据:https://blog.csdn.net/wutao1201/article/details/88225649

posted @ 2020-04-23 10:47  采男孩的小蘑菇  阅读(2165)  评论(0编辑  收藏  举报