First time here? Check out the FAQ!


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

How to echo messages published on a particular topic by a node?

asked Feb 3 '21

updated Feb 3 '21

Let's say that we have 2 nodes named node_a and node_b. Let's assume that both the nodes are publishing on the topics - topic_1, topic_2, topic_3 and topic_4. Is there a way to find out what the node_a is publishing on the topic_1 ?

Preview: (hide)

Comments

Are you looking for something as simple as rostopic echo \topic_a or something more detailed? This will only work if your topic_a is sourced of course.

Akhil Kurup gravatar image Akhil Kurup  ( Feb 3 '21 )edit

I have edited the question. Does it make sense now?

I don't want to echo everything that is being published to topic_1. I just want to echo the messages being published by node_a on topic_1.

skpro19 gravatar image skpro19  ( Feb 3 '21 )edit

2 Answers

Sort by » oldest newest most voted
0

answered Feb 3 '21

felixN gravatar image

One idea (not tested):

1) change the name of the outputs topics if node a (for example topic_1_a instead of topic_1), or remap the names (using a launch file)

2) use the relay node (http://wiki.ros.org/topic_tools/relay) to copy the content of topic_1_a into topic_1.

This way, you have all your data from topic one in separated topics, but you also have your "normal" topic with messages from all nodes.

You might do the same for node_b and group the messages in topic_x.

Preview: (hide)
0

answered Feb 3 '21

g.bardaro gravatar image

updated Feb 3 '21

It is not clear from your description, but I assume you are talking about a situation where multiple nodes are publishing on the same topic. If this is the case, there is no way to find who is the owner of the message, since the publishing system is "fire-and-forget". (Apparently this is not true)

I think you should change the design of your connection to avoid this situation, especially if you end up in an N-to-N (multiple nodes on both sides of a topic) situation. However, a workaround is to define an extra field on the message to add an ID to identify the source.

Preview: (hide)

Comments

1

If this is the case, there is no way to find who is the owner of the message

this is actually not true.

a MessageEvent can tell you which node published a message.

Whether this leads to a properly designed application is something else.

gvdhoorn gravatar image gvdhoorn  ( Feb 3 '21 )edit

Question Tools

2 followers

Stats

Asked: Feb 3 '21

Seen: 558 times

Last updated: Feb 03 '21