Read message structure at runtime from advertised topic
I have been looking in the roscore source code with no success. I want to "read" the structure of a given message (by topic name for example). By structure I mean a tree showing the fields a message has and their data types. The format doesn't really matter (XML, JSON etc.).
Is this possible to do in C++? One of my goals would be to dynamically generate a message container at runtime in c++ (maybe eventually a subscriber too).
The only solution I found right know is to run rosmsg show MSG
and parse its output.