How to know where the next variable begins in a serialized message?
Hey everybody,
In the last few weeks I've been trying to serialize any ROS message received in some kind of listener node that's subscribed to all the existent topics. Once every message is serialized (using ros::serialize) I get an Ostream full of bytes. I need to deserialize this Ostream byte by byte (without using ros::deserialize) to rebuild all the containing data of any message and put the information into some xml-like format. My idea is to call __getMessageDefinition() (which is deprecated...) for each message to obtain the .msg definition so I get something like:
float64[6] a
float64[] b
float64[] x
int32 c
Once I have this information, I know that the first 8 bytes of the Ostream are a[0], the next 8 are a[1], etc. And the last 4 bytes belong to c. The problem would be solved if it wasn't for vectors without specified length and strings.
So my question is, how can I know how many bytes belong to a certain variable? In the example above, how can I know where b ends and x starts? There should be a way to do this right?
Thanks!