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 2021-02-03 08:50:36 -0500

updated 2021-02-03 10:26:34 -0500

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 ?

edit retag flag offensive close merge delete

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  ( 2021-02-03 09:48:10 -0500 )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  ( 2021-02-03 10:24:56 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-02-03 11:21:06 -0500

g.bardaro gravatar image

updated 2021-02-03 11:32:37 -0500

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.

edit flag offensive delete link more

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  ( 2021-02-03 11:24:42 -0500 )edit
0

answered 2021-02-03 11:00:00 -0500

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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-02-03 08:50:36 -0500

Seen: 424 times

Last updated: Feb 03 '21