ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Show all message types which contain a given msg

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

lucasw gravatar image

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

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 -0600 )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 -0600 )edit

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

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

1 Answer

Sort by ยป oldest newest most voted

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

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

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 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



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

Seen: 274 times

Last updated: Nov 21 '15