What is generating the comments in ROS messages?

When I run the command rosmsg show geometry_msgs/TwistStamped the output is

std_msgs/Header header
uint32 seq
time stamp
string frame_id
geometry_msgs/Twist twist
geometry_msgs/Vector3 linear
float64 x
float64 y
float64 z
geometry_msgs/Vector3 angular
float64 x
float64 y
float64 z


When I run rosmsg show --raw geometry_msgs/TwistStamped the output is

# A twist with reference coordinate frame and timestamp
Twist twist


When I run rosmsg show --raw geometry_msgs/TwistStamped --bag=<input.bag> I get the output of

# A twist with reference coordinate frame and timestamp
Twist twist
================================================================================
# Standard metadata for higher-level stamped data types.
# This is generally used to communicate timestamped data
# in a particular coordinate frame.
#
# sequence ID: consecutively increasing ID
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
string frame_id

================================================================================
MSG: geometry_msgs/Twist
# This expresses velocity in free space broken into its linear and angular parts.
Vector3  linear
Vector3  angular
================================================================================
MSG: geometry_msgs/Vector3
# This represents a vector in free space.
# It is only meant to represent a direction. Therefore, it does not
# make sense to apply a translation to it (e.g., when applying a
# generic rigid transformation to a Vector3, tf2 will only apply the
# rotation). If you want your data to be translatable too, use the
float64 x
float64 y
float64 z


This last example is also what I can see as the full text of a message in a debug session. Where are the comments coming from and who is generating them? I'm finding that some of my messages have all of the correct fields, but the comments are missing and many post-processing tools use the long line of ==== to parse through a message definition.

edit retag close merge delete

Sort by » oldest newest most voted

The comments are just part of the original .msg file (TwistStamped, then Header, Twist and finally Vector3).

rosmsg show geometry_msgs/TwistStamped only shows you message fields and layout. It doesn't show the comments.

rosmsg show --raw geometry_msgs/TwistStamped shows you the raw message definition (identical to the one in the source repository I linked above).

Finally: rosmsg show --raw geometry_msgs/TwistStamped --bag=<input.bag> reads the message definition from the .bag, which is slightly special: .bags store the complete message definition, recursively, down to the last non-primitive types. So for TwistStamped, it first stores the definition of TwistStamped, then goes down one level, stores the definition of Header, then moves onto Twist, then Vector3. It separates each of those with =-signs.

It does this to make a .bag (almost) completely stand-alone, and independent of the message definitions as they happen to be present on a machine that plays back the .bag (as message definitions can change, which would make it impossible to replay the .bag).

Where are the comments coming from and who is generating them?

I hope this is now clear: they aren't being generated. They have always been part of the message/service/action definition files.

more

Awesome. Thank you! Right before I saw this answer I found the header file for geometry_msgs/TwistStamped in /opt/ros/melodic/include/geometry_msgs, which contains this full message definition.

( 2019-07-19 14:29:42 -0600 )edit