Skip to content

Can't convert Images from a rosbag #2

@awesomebytes

Description

@awesomebytes

If reading messages from a rosbag one gets an error like:

ValueError: Unable to convert message _sensor_msgs__Image - only supports Numpy_sensor_msgs__Image, Numpy_geometry_msgs__Transform, Numpy_nav_msgs__OccupancyGrid, Numpy_sensor_msgs__PointField[], Transform, PointField[], Image, Numpy_geometry_msgs__Quaternion, OccupancyGrid, PointCloud2, Numpy_geometry_msgs__Point, Pose, Point, Numpy_geometry_msgs__Vector3, Numpy_geometry_msgs__Pose, Numpy_sensor_msgs__PointCloud2, Vector3, Quaternion

That's because

In [1]: from sensor_msgs.msg import Image

In [2]: img = Image()

In [3]: img.__class__
Out[3]: sensor_msgs.msg._Image.Image

In [4]: from rosbag import Bag   

In [5]: b = Bag('poc_bag.bag')

In [6]: r = b.read_messages(topics=['/pepper/camera/depth/image_raw'] )

In [7]: topic, msg, time = r.next()

In [8]: msg.__class__
Out[8]: tmpldS_vh._sensor_msgs__Image

In [13]: img.__class__.__name__
Out[13]: 'Image'

In [14]: msg.__class__.__name__
Out[14]: '_sensor_msgs__Image'

From a rosbag the messages don't seem to have the proper type (I guess it has something to do with the way messages are stored).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions