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:
- you have access to the sources of those packages (including
.launch
files) - 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 Twist
s 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
.