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

What are the differences between broadcaster and publisher

asked 2022-05-14 15:04:12 -0500

Arete gravatar image

Hi guys,

I am new to ROS, and I just learned some ROS tutorials. I found that in some tutorials, they refer to a node as the "publisher", such as the "image publisher" in http://wiki.ros.org/image_transport/T.... However, in other tutorials, they refer to a node as the "broadcaster", such as the "tf broadcaster" in http://wiki.ros.org/tf/Tutorials/Writ.... Furthermore, the recipients of them, subscribers and listeners, are not the same either.

I noticed that they all send messages to topics, but subscribers have callback functions that listeners do not have. But

  1. I do not know the reasons for creating these two different nodes, or classes.

  2. Can I use the function subscribe() to subscribe to a topic from the broadcaster? Can they communicate with each other?

Thanks for any help or hints in advance. Sorry if I missed any information that already existed.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-05-16 10:17:37 -0500

emielke gravatar image

Short answer: subscriber and publisher are ROS-wide classes, listener and broadcaster are TF-specific classes.

Long answer: ROS uses a subscriber/publisher model to transfer data between nodes. A node can listen to or publish to a specific topic, which communicates a specific data type. For example, nodeA and nodeB want to communicate with each other about the ROS msg std_msgs::Float64 which is communicated through the topic /topic1. nodeA has a publisher class that creates the data and publishes it on topic1, while at the same time, nodeB has a callback function that is subscribing to topic1 and then extracts the data from the std_msgs::Float64 and utilizes it in whatever way is needed.

TF is a specific library within ROS that is used to perform transformation operations in a helpful manner. With TF you can create a frame tree, add children to an existing parent frame, add a new branch, get the relationship between frames, etc. TF has implemented it's own classes called listener and broadcaster so as not to confuse between subscriber and publisher. Under the hood, listener and broadcaster utilize the ROS subscriber and publisher model, but do not expose them to the user, instead giving other tools to be able to do what the user wants, but specifically is working within the transformation tree, which is usually exposed on the /tf and /tf_static topics.

Theoretically, you could subscribe to the /tf or /tf_static topics and do your own math, but it is largely taken care of by the TF library.

Anyway, long answer to say that the TF library is specifically designed for working with transformation math, whereas subscriber/publisher are the overall ROS way of moving data around between any two nodes, not just TF nodes.

edit flag offensive delete link more

Comments

Thank you so much for your exhaustive explanation.

Arete gravatar image Arete  ( 2022-05-16 12:22:09 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-05-14 15:04:12 -0500

Seen: 948 times

Last updated: May 16 '22