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

Revision history [back]

click to hide/show revision 1
initial version

As @Wolf and @gvdhoorn have pointed out, topics are Anonymous; this means that you can have any number of subscribers and any number of publishers on them. While it is technically possible to get the name of the publisher for a received message (say, for debugging), good system design should not depend on the publisher name for correct functionality.

It sounds like you want to make a subscriber that receives messages from two different sources, adds them and publishes the result. The typical ROS way to do this is to represent each source as a separate topic and subscribe to both topics.

Regards of whether you use one or two topics, keep in mind that since you're receiving data from two different sources, the data from each source will not arrive at the same time, and you will need to do something to synchronize it.

You can write your own synchronization, or, if your messages have a Header, ROS has the TimeSynchronizer in the message_filters library which can synchronize two or more topics based on the timestamp in their headers.