Ask Your Question
0

ROS How can I determine which node is currently feeding a specific topic?

asked 2020-11-09 09:18:40 -0500

jchodorowski gravatar image

Hi !

For debugging purposes I need to know, in real time, which node is posting on a given topic. More precisely my /cmd_vel topic is fed by several nodes on the code of which I have no control. I would like to know which of these nodes pollutes my topic. Is there a method for this?

Thank you in advance for your suggestions.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-11-09 12:02:16 -0500

gvdhoorn gravatar image

updated 2020-11-10 02:38:04 -0500

The precise question is : "when /cmd_vel received a message how to know which node among all publishers sent it to this tpoic"

It would have been good to mention this in your OP, as that could have saved @skpro19 from posting the answer he posted.

Based on your new description, I believe this is something a MessageEvent subscriber can tell you. See #q240362 for what is essentially a duplicate of your post (see #q335977 for a related one).

Note: needing/wanting to use the name of the publishing node and basing behaviour of the subscriber on that is what some consider an anti-pattern. It violates the decoupling in the space dimension (#q203129), which is one of the fundamental tenets of publish-subscribe I believe.

Or at least of anonymous publish-subscribe.


Edit:

I'm really seeking to determine which node provided by manufactor is moving my robot (in unwanted way) in order to ask him for support to disable it.

I'm not sure that would be necessary. The main point here is that in a ROS application (or more generally: a dataflow driven application), behaviour is as much a result of the combination of nodes which are running, as it is of the dataflows between nodes. If you change the dataflows, you change the behaviour.

There are roughly two cases I believe:

  1. you have access to the sources of those packages (including .launch files)
  2. you have no access to the sources of those packages

If you're stuck with 2, you can probably remap (#q303611) on the subscriber side. If you make the consumer subscribe to /my_cmd_vel, it will never see Twists published to /cmd_vel.

If you're lucky and are in situation 1, you could remap on the publisher side (you could also create your own .launch file to launch the nodes for which you have no sources, then you could still remap on the publisher side without needing access to the sources). Same idea: avoid messages from ending up on the topic you're subscribing to (ie: /cmd_vel).

If you now still want to sometimes allow some of those messages to end up on /cmd_vel, you could use topic_tools/mux to select from the remapped publishers and redirect one of them, at runtime, to /cmd_vel.

edit flag offensive delete link more

Comments

Hi ! Thanks for your reply. It's my first question on answers.ros.org : I'll follow your advice about mentionning the precision in OP (which is the main question I presume, I'm not english native speaker nor used to ask for support in such way). MessageEvent is exactly what I was looking for ! I understand perfectly your note, I'm really seeking to determine which node provided by manufactor is moving my robot (in unwanted way) in order to ask him for support to disable it.

jchodorowski gravatar image jchodorowski  ( 2020-11-10 02:21:20 -0500 )edit
0

answered 2020-11-09 11:43:10 -0500

updated 2020-11-09 11:50:20 -0500

You can type rostopic info /cmd_vel in a new terminal.

This would give you the list of Publishers and Subscribers for the given topic.

edit flag offensive delete link more

Comments

Thanks for your reply. Indeed I did know this way which nodes were publishing into /cmd_vel. The precise question is : "when /cmd_vel received a message how to know which node among all publishers sent it to this tpoic"

jchodorowski gravatar image jchodorowski  ( 2020-11-09 11:55:53 -0500 )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

2 followers

Stats

Asked: 2020-11-09 09:18:40 -0500

Seen: 264 times

Last updated: Nov 10 '20