ROS读取激光雷达点云数据(RS-Lidar为例)

一、准备工作:

1、安装ROS (含有rviz);

2、安装pcl-ros。

    pcl(Point Cloud Library)-ros  是ROS中点云和3D几何处理的接口和工具。

   如果安装的是ros-kinetic-desktop版本,默认不包含pcl-ros,在rviz中无法显示点云。

   安装方法:

sudo apt-get install libpcap-dev #安装依赖
sudo apt-get install ros-kinetic-pcl-ros

  显示:

sudo apt-get install ros-kinetic-pcl-ros
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libflann-dev libflann1.8 libopenni-dev libopenni-sensor-pointclouds0
  libopenni0 libpcl-apps1.7 libpcl-common1.7 libpcl-dev libpcl-features1.7
  libpcl-filters1.7 libpcl-io1.7 libpcl-kdtree1.7 libpcl-keypoints1.7
  libpcl-octree1.7 libpcl-outofcore1.7 libpcl-people1.7 libpcl-recognition1.7
  libpcl-registration1.7 libpcl-sample-consensus1.7 libpcl-search1.7
  libpcl-segmentation1.7 libpcl-surface1.7 libpcl-tracking1.7
  libpcl-visualization1.7 libpcl1.7 openni-utils ros-kinetic-pcl-conversions
  ros-kinetic-pcl-msgs ros-kinetic-tf2-eigen
Suggested packages:
  openni-doc libpcl-doc
The following NEW packages will be installed:
  libflann-dev libflann1.8 libopenni-dev libopenni-sensor-pointclouds0
  libopenni0 libpcl-apps1.7 libpcl-common1.7 libpcl-dev libpcl-features1.7
  libpcl-filters1.7 libpcl-io1.7 libpcl-kdtree1.7 libpcl-keypoints1.7
  libpcl-octree1.7 libpcl-outofcore1.7 libpcl-people1.7 libpcl-recognition1.7
  libpcl-registration1.7 libpcl-sample-consensus1.7 libpcl-search1.7
  libpcl-segmentation1.7 libpcl-surface1.7 libpcl-tracking1.7
  libpcl-visualization1.7 libpcl1.7 openni-utils ros-kinetic-pcl-conversions
  ros-kinetic-pcl-msgs ros-kinetic-pcl-ros ros-kinetic-tf2-eigen

  如果对pcl-ros感兴趣,可以参考博客学习更多相关资料 https://www.cnblogs.com/qixianyu/p/6607440.html

3、安装RSLidar ROS驱动

ROBOSENSE的激光雷达。

mkdir -p ~/rslidar_ws/src 
cd ~/rslidar_ws/src 
git clone https://github.com/RoboSense-LiDAR/ros_rslidar
cd ..
catkin_make #编译和安装

4、录制好的激光点云数据(rosbag格式)

例如:rslidar_test.bag。

 

二、方法:

1、启用主节点

roscore  # 执行所有ROS程序前必须执行的指令

2、发布激光点云

Publisher:

rosbag play rslidar_test.bag

倍速播放:

rosbag play -r 100 rslidar_test.bag #100倍速度播放

bag time存储到txt文件中:

rosbag play -r 100 rslidar_test.bag >> bagtime.txt

 

3、运行

source ~/rslidar_ws/devel/setup.bash  #启用配置,同一个terminal下运行如下命令:
roslaunch rslidar_pointcloud rs_lidar_16.launch  #16表示16线的激光雷达,如果是32线的则运行rs_lidar_32.launch

则rviz被启动,相应的Fixed Frame、PointCloud2已经配置好。

三、其他:

1、查看bag信息

rosbag info rslidar_test.bag

则弹出如下信息:

path:        rslidar_test.bag
version:     2.0
duration:    2hr 23:11s
start:       Jun 23 2019 09:25:22.21 (1560903922.21)
end:         Jun 23 2019 12:51:11.43 (1560916271.43)
size:        13.4 GB
messages:    121634
compression: none [30448/30448 chunks]
types:       rslidar_msgs/rslidarScan [ff6baa58985b528481871cbaf1bb342f]
topics:      rslidar_packets   121634 msgs    : rslidar_msgs/rslidarScan

2、查看话题:

rostopic list

显示出:

/clicked_point
/clock
/diagnostics
/initialpose
/move_base_simple/goal
/rosout  #实质为rosgraph_msgs/Log
/rosout_agg
/rslidar_node/parameter_descriptions
/rslidar_node/parameter_updates
/rslidar_packets
/rslidar_packets_difop
/rslidar_points
/tf
/tf_static

3、查看话题发布速率:

rostopic hz /rslidar_points

4、打印出通道信息:

rostopic echo /rslidar_points

5、查看运行的节点

rosnode list

/play_1563514485981639105
/rosout
/rslidar_node
/rviz_1563514559520415329

 

参考资料:

1. https://www.ncnynl.com/archives/201807/2552.html

2. https://github.com/RoboSense-LiDAR/ros_rslidar/blob/master/doc/readme_cn.md

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页