Hey everybody,
I would like to know what's the best way (if possible) to convert any message in ros into something similar to xml or just a string. Let's say I have this message defined:
float64[6] a
float64[] b
int32 c
I'd like to parse it to something like:
<message>
<a type="float64" value="1.0,2.0,3.0,4.0,5.0,6.0"/>
<b type="float64" value="7.0,5.0,6.0"/>
<c type="int32" value="4"/>
</message>
What's the best way to achieve that? I want it to be the most generic possible (so, I don't want to manually put my message.a, message.b, message.c into a string). I'm going to use this into some kind of listener node subscribed to many topics so I don't want to define one callback for each topic and having to unpack manually each message.
Edit: I have been hinted somewhere else to use Python to achieve this because it's easier. I'd like a C++ solution but if that's too hard then I'd appreciate someone explaining how can I easily parse ros messages in python to know all the names, values and types in a somewhat dynamic way.
Thanks a lot!
Originally posted by pparescasellas on ROS Answers with karma: 95 on 2011-06-20
Post score: 7
Original comments
Comment by lucasw on 2016-02-08:
Similar to http://answers.ros.org/question/11289/read-or-write-message-fromto-file/ - the suggestion there is to use rosbag api.