-3
$\begingroup$

Can anyone please explain what is a publisher and a subscriber when we talk about ROS?

Where is which of them installed and what do they do? Any simple example is appreciated.

$\endgroup$
  • $\begingroup$ What did you try ? Did you look at the ros tutorials ? They are very easy and nice $\endgroup$ – Malcolm Feb 4 '18 at 17:53
  • $\begingroup$ Hello, qili! And welcome to Robotics Beta stack exchange. Please check out this tutorial on YouTube. $\endgroup$ – Szczepan Feb 5 '18 at 16:32
0
$\begingroup$

Publishers and subscribers are your own ROS nodes - programs that you write which make use of ROS' API.

A publisher basically just puts data into a ROS topic, and a subscriber gets said data from a topic.

Take a look at section 2.1: http://wiki.ros.org/ROS/Tutorials/UnderstandingTopics

Someone wrote 2 programs (or nodes). One of them is called "teleop_turtle" which reads your keyboard input and uses the ROS API to publish that information on a topic called "/turtle1/command_velocity".

The other is called "turtlesim" and it "subscribes" to that topic, meaning that a specific function in the node's code will be executed when new data is published to that topic.

| improve this answer | |
$\endgroup$
0
$\begingroup$

Think about writing code that provides information which needs to be consumed by a number of other functions. That information could be written to a memory structure, and sent to each routine that needs the information. With this design, every time a new method is written that needs this information, both the source and the consumer of the data need to be rewritten to link the data from the source to the consumer.

With a publisher-subscriber model, the integration becomes easier. The source of the information just needs to write the results to a message. It does not need to know who all will be consuming the data. The subscriber(s) sign up to receive these particular messages. When new data becomes available, the publisher sends a new message. The subscribers all receive this data because they have signed up to receive these messages.

This design is particularly useful for state information such as health checks. Any routine that causes motion can subscribe to a “health” message, and each of these routines can “check health” before moving a joint. Without the publisher-subscriber model, both the motion routine and the health monitoring routine would need to be updated before this health check would work.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.