What encoding is used for ros2bags data?

asked 2020-04-23 05:15:33 -0500

DanielRobotics gravatar image

updated 2020-04-23 09:01:06 -0500

I have a rosbag2 with some data from the topic /odom which has topic id 12 in my setup. I can see the data in bytes but I can't find the proper encoding to decode from.

import pandas as pd
messages = pd.read_sql('messages', 'sqlite:///outdoor_test.db3')
odom_data = messages[messages['topic_id'] == 12]
odom_data_h = odom_data.head(n=1)
print(odom_data_h['data'].values[0])

My output is:

b'\x00\x01\x00\x00B\xdf\x9c^0\x9d\x862\x05\x00\x00\x00odom\x00\x00\x00\x00\x0f\x00\x00\x00base_footprint\x00\x00\xfcD\xb9A\xf0a\xc0?\x04#F\t\xa7\xe8r\xbf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00$\x1e\\\xf3\r|\x92\xbf\x93\xd1\xcbJ\xaa\xfe\xef?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbf\xbd\x89\xf08m\x1e\xbd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 ...
(more)
edit retag flag offensive close merge delete

Comments

1

Afaik, it's a dump of the CDR serialised payload of the message. But it would depend on the serialisation plugin used.

See ros2/rosbag2: Serialization format plugin architecture for a hint.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-23 05:24:10 -0500 )edit

Thanks! I used ros2 bag record -a to record the bag, so it should be in CDR format. I can't seem to find any way to decode CDR format, do you know if it is possible to decode it right away? Or do I miss more steps in the process?

DanielRobotics gravatar image DanielRobotics  ( 2020-04-23 05:53:10 -0500 )edit

Looks like #q346934 is a related question/duplicate.

Note btw: the data even after deserialisation would be a ROS message, not a collection of Python primitive data. You would still still need the corresponding message classes and type support libraries to do anything meaningful with it I believe.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-23 09:36:24 -0500 )edit