Is it possible to parse the fields and values of a custom ros msg binary file in python without knowing the message definition?

asked 2017-02-16 10:05:44 -0500

I have stored several files which contain the serialized binary data from custom ros messages. Now I'm attempting to parse the data in those files from a python script that knows nothing about the message definition or ros's messaging system at all, is this possible?

edit retag flag offensive close merge delete

Comments

Do you have just the binary stream (ie: exchanged by two nodes after negotiation), or also the topic/service negotiation data?

gvdhoorn gravatar image gvdhoorn  ( 2017-02-16 10:19:51 -0500 )edit

I have is the binary stream which was generated with ros::serialization::serialize from the message object, as well as .msg file definition.

jrgnicho gravatar image jrgnicho  ( 2017-02-16 13:15:50 -0500 )edit

You mean you want to do the de-serialization yourself, without having to import custom_msg.msg? If yes you would be re-doing what genpy does. look at https://github.com/ros/genpy/blob/kin...

afakih gravatar image afakih  ( 2017-02-16 13:49:41 -0500 )edit

afakih yes that's what I meant, thanks for the link. It isn't obvious to me from looking at that genpy code how I would de-serialize binary data from a custom message.

jrgnicho gravatar image jrgnicho  ( 2017-02-16 14:20:17 -0500 )edit

You would need to do something similar to what's is in 'msg_generator` function which generates python code from the .msg. To load the .msg into a MsgSpec you would need something similar to https://github.com/ros/genmsg/blob/in...

afakih gravatar image afakih  ( 2017-02-16 15:28:45 -0500 )edit

I do have the definition message file (an MyMsg.msg file) and several other files with serialized data generated from instances of my custom message. The libraries you pointed to allow you to create a MsgSpec instance but it doesn't look like there's a way of filling it with the serialized data.

jrgnicho gravatar image jrgnicho  ( 2017-02-17 13:07:07 -0500 )edit