Unable to read sensor_msgs/Image in ROSBag2
Here is the file I use to read
from rosbags.rosbag2 import Reader
from rosbags.serde import deserialize_cdr
# create reader instance and open for reading
with Reader('ros2_bag') as reader:
for connection, timestamp, rawdata in reader.messages():
if connection.topic == "/camera/image":
msg = deserialize_cdr(rawdata, connection.msgtype)
It results in the following error
Traceback (most recent call last):
File "convert_ros2_to_ros1.py", line 11, in <module>
msg = deserialize_cdr(rawdata, connection.msgtype)
File "/usr/local/lib/python3.8/dist-packages/rosbags/serde/serdes.py", line 32, in deserialize_cdr
message, pos = func(rawdata[4:], 0, msgdef.cls)
File "<string>", line 28, in deserialize_cdr
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position 8: invalid start byte
I can't share the ROS2 bag since it is 140 Gigs. But I have played it and can confirm that the image is visible in Rviz2. It's of the standard sensor_msgs/msg/Image. It is 1544 x 2064.
Here is the header
header:
stamp:
sec: 1630169124
nanosec: 380860868
frame_id: camera
height: 1544
width: 2064
encoding: rgb8
is_bigendian: 0
step: 6192
I am using v0.9.3 as I do have to convert this to a ROS1 bag later