ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Looking at the latest ROS2 master code, it looks like you can currently get the names of the message fields from __slots__, but not the types:

>>> import std_msgs.msg
>>> x = std_msgs.msg.Header()
>>> dir(x)
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '_frame_id', '_stamp', 'frame_id', 'stamp']
>>> print(x.__slots__)
['_stamp', '_frame_id']
>>>