Get information about topic message at runtime
I am trying to build an interface that universally bridges ROS topics to another system. I am importing the message type at runtime:
importcom = ( # import type
"from " +
topic_class +
".msg import " +
topic_type
)
exec(importcom, globals())
This allows me to later subscribe to this topic dynamically at runtime.
My question is now: How can I gain insight in the structure of this message at runtime? Ideally I need a json object that includes the types of all the parameters that i expect in a message. e.g.:
{
"angular" :
{
"x": float
"y": float
"linear" :
{
"x": float
"y": float
....
(or something like this)