velodyne_msgs/VelodyneScan消息转化为sensor_msgs/PointCloud2消息

test.bag 中有一个话题 /hdl64/velodyne_packets,消息类型为 velodyne_msgs/VelodyneScan(不是ros内置消息)

需要将其转化为point_cloud2形式的消息。

1、下载并编译velodyne的ros驱动(用catkin_make_isolated编译,而不是catkin_make)

mkdir -p ~/new_workspace/src
cd ~/new_workspace/src
git clone https://github.com/ros-drivers/velodyne.git
cd ..
catkin_make_isolated
source ~/new_workspace/devel_isolated/setup.bash

2、启动转换节点(有问题就再执行一下上面的 source 命令)

rosrun nodelet nodelet standalone velodyne_pointcloud/CloudNodelet _calibration:="/home/alan/alan_yaml/velodyne_lidar_VLP32db.yaml"

该节点默认订阅 /velodyne_packets 话题,消息类型为 velodyne_msgs/VelodyneScan 。转换完发布到 /velodyne_points 话题,消息类型为 sensor_msgs/PointCloud2

标定文件 velodyne_lidar_VLP32db.yaml 格式:

lasers:
- {dist_correction: 0.0, dist_correction_x: 0.0, dist_correction_y: 0.0, focal_distance: 0.0,
  focal_slope: 0.0, horiz_offset_correction: 0.0, laser_id: 0, rot_correction: -0.024434609527920613,
  vert_correction: -0.4363323129985824, vert_offset_correction: 0.0}
...
...
num_lasers: 32
distance_resolution: 0.004

3、回放 bag 文件,并将话题名字remap为  /velodyne_packets

rosbag play test.bag /hdl64/velodyne_packets:=/velodyne_packets

4、在rviz中显示,并选择合适的坐标系

velodyne_msgs/VelodyneScan消息转化为sensor_msgs/PointCloud2消息_第1张图片

参考:

http://wiki.ros.org/velodyne_pointcloud

你可能感兴趣的:(2019)