How to decode binary data from a rosbag ?
When i try to echo the topics of a bag file, i get a message :
data: !!binary |
ChQJpiM5J7b11UESB2dhdGV3YXkYSRI7GAEt0YmNPjUAAAAARQAAAABNAAAAAF0AAAAAqAEAsAEA
uAEAygEUCaYjOSe29dVBEgdjaGFzc2lzGAcamgEKGwl+jANaaLcaQRG3Y7kbwu1QQRlNc4QFq/qd
vxIkCQAAAAAAAAAAEQAAAAAAAAAAGbZX/zsVBNw/IYPT7lNnxew/GhsJlaAsEDqx0T8R+pqtiJCs
kzwZBQSdL5XVZj8iGwmW/f98qKacPxHERbyH1aKhvBlzAOArHy9+vyobCfeLggMmjbI8ER2XZG1t
Jzg/GfBTn4g5Yn08IQAAAAAAABxA
This data seems to be binary encoded. The message type of this topic is string
. How can i read this data ?
Can you show us the command you are using to try and echo the topics of a bag file. This doesn't look like anything I've seen from
rostopic echo
before.The command is normal
rostopic echo /pnc/carstatus
but there seems to be a unicode error. It also says :UnicodeDecodeError: 'ascii' codec cant decode byte 0xe7 in position 1496: ordinal not in range(128)
.This is most likely a
std_msgs/String
that either:It would help if you could show the message definition @aakash_sehgal.
@gvdhoorn could you kindly guide me how to do that ? I only have the rosbag file.
ran the python script from the command line :
./ message_definition.py Bagname
but it gives the same error :UnicodeDecodeError: 'ascii' codec cant decode byte 0xe7 in position 1496: ordinal not in range(128)
. Exactly thisYes, that's a problem. I don't have time to look into this right now, but it's one of the consequences of
mostsome of ROS Python code not being Unicode aware/safe.What you could do is open the bag file with a text editor (don't save it), then scroll down a bit until you ..
.. come across message definitions.
If you know a bit of text from the definition that would help, as you can then just search for it.
Then carefully copy-paste the def into a new file and save it as a msg def.
I seem to remember you got this bag / these bags from a colleague. If that is the case, it would be infinitely easier / more convenient to just get the definitions from him.