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

Show all message types which contain a given msg

asked 2015-11-14 16:55:33 -0500

lucasw gravatar image

updated 2020-11-21 12:05:28 -0500

Is there a way to use rosmsg to query for all messages that contain another msg type?

For instance, I'd like to see all message types which contain a sensor_msgs/Image. (querying services the same thing would also be useful)

Doing a rosmsg show on every message output by rosmsg and grepping it for the type is super slow, probably 10 minutes or more for all the messages.

edit retag flag offensive close merge delete



I've never heard of a function/script for that, but the code for the auto completion for 'rosmsg show' should be able to create a list of msg definitions in which you could just grep. Sounds like a fun python finger exercise.

NEngelhard gravatar image NEngelhard  ( 2015-11-15 10:22:48 -0500 )edit

Are you looking for "all" published topics that contain that message type? Or are you looking for messages that contain another message type (the message hierarchy)?

jeremya gravatar image jeremya  ( 2015-11-15 22:15:52 -0500 )edit

@jeremya messages types, I updated the question to reflect that.

lucasw gravatar image lucasw  ( 2015-11-16 11:13:43 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-17 05:14:51 -0500

updated 2015-11-21 06:05:37 -0500

lucasw gravatar image

This can be a good start:

 grep -R --include \*.msg --include \*.srv "sensor_msgs/Image" $(echo $ROS_PACKAGE_PATH | sed 's/:/ /g')

Maybe a recursive call to grep is necessary, so you could find message types that use Image indirectly. But in my case this can be done manually, because I get just one result (and 2 comments):

/opt/ros/indigo/share/polled_camera/srv/GetPolledImage.srv:                      # against incoming sensor_msgs/Image header.
/opt/ros/indigo/share/stereo_msgs/msg/DisparityImage.msg:sensor_msgs/Image image
/opt/ros/indigo/share/theora_image_transport/msg/Packet.msg:Header header     # Original sensor_msgs/Image header

To exclude the comments:

 grep -R --include \*.msg --include \*.srv "^sensor_msgs/Image" $(echo $ROS_PACKAGE_PATH | sed 's/:/ /g')
edit flag offensive delete link more



Cool! I've edited your answer to search the entire ROS_PACKAGE_PATH

lucasw gravatar image lucasw  ( 2015-11-21 06:05:23 -0500 )edit

Question Tools



Asked: 2015-11-14 16:55:33 -0500

Seen: 322 times

Last updated: Nov 21 '15