Author sebaleme
Recipients sebaleme
Date 2020-11-28.21:19:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>

I am using an old version, but maybe you can still help me. I am using the ROS operating system, and there, the unpack_from function is used for reading values from bags.
When I try to read uint16 with the function pointcloud2.readpoint(), it returns 2 values instead of 1, and I couldn t understand why. Since this readpoint() is from the official pointcloud2 package from ros, and unpack_from is from official struct package, I don t think I could do many error here. In the screenshot, you can see that the inputs parameters seems ok. I am reading a field from my bag which is 2 bytes, and the offset (12) make also sense (4th value after 3 floats).

def read_points(cloud, field_names=None):


    Read points from a L{sensor_msgs.PointCloud2} message.


    @param cloud: The point cloud to read from.

    @type  cloud: L{sensor_msgs.PointCloud2}

    @param field_names: The names of fields to read. If None, read all fields. [default: None]

    @type  field_names: iterable

    @param skip_nans: If True, then don't return any point with a NaN value.

    @type  skip_nans: bool [default: False]

    @param uvs: If specified, then only return the points at the given coordinates. [default: empty list]

    @type  uvs: iterable

    @return: Generator which yields a list of values for each point.

    @rtype:  generator


    assert isinstance(cloud, roslib.message.Message) and cloud._type == 'sensor_msgs/PointCloud2', 'cloud is not a sensor_msgs.msg.PointCloud2'

    fmt = _get_struct_fmt(cloud.is_bigendian, cloud.fields, field_names)

    print('fmt size ' , str(struct.calcsize(fmt)))

    print('cloud.height ' , str(cloud.height))

    print('cloud.row_step ' , str(cloud.row_step))

    width, height, point_step, row_step, data, isnan = cloud.width, cloud.height, cloud.point_step, cloud.row_step,, math.isnan

    unpack_from = struct.Struct(fmt).unpack_from


    for v in range(height):

        offset = row_step * v

        for u in range(width):      

            yield unpack_from(data, offset)

            offset += point_step

def callback(data):

    print("pointcloud size is %d bytes" % len(

    pointCloudArray_a = [1,2,3,4,5]


    for indoux in range(4):



        pointCloudArray_a[indoux] = np.array(list((read_points2(data, field_names=(fields_PI6[indoux])))))

Here my mail again if you need more infos:

Date User Action Args
2020-11-28 21:19:50sebalemesetrecipients: + sebaleme
2020-11-28 21:19:50sebalemesetmessageid: <>
2020-11-28 21:19:50sebalemelinkissue42494 messages
2020-11-28 21:19:49sebalemecreate