ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I used a modified version of the create_cloud_xyz32 function from point_cloud2.py

def create_cloud_xyzi32(header, points):

    fields = [PointField(name='x', offset=0,
                         datatype=PointField.FLOAT32, count=1),
              PointField(name='y', offset=4,
                         datatype=PointField.FLOAT32, count=1),
              PointField(name='z', offset=8,
                         datatype=PointField.FLOAT32, count=1),
              PointField(name='intensity', offset=12,
                         datatype=PointField.FLOAT32, count=1)]
    return create_cloud(header, fields, points)

This works for me with points being a list of tuples (x,y,z,intensity), and coverts it directly to a ROS2 message you can publish

Hope this helps :)