Topics – Sending and Receiving Messages between Nodes
Now that you can write nodes, how can you make several nodes communicate with each other, and how can you interact with existing nodes in an application?
There are three kinds of communication in ROS 2: topics, services, and actions. In this chapter, we will dive into ROS 2 topics.
To understand how topics work, we will start with a real-life analogy. This will allow you to grasp the concept using existing and common knowledge. Then, you will dive into the code and write a publisher and a subscriber inside a node—first with existing interfaces, and then by building custom interfaces. You will also use ROS 2 tools such as the ros2
command line and rqt_graph
to introspect topics and unlock more functionalities.
By the end of this chapter, you will be able to make your nodes communicate with each other using ROS 2 topics. You will learn by writing code and will be provided with an additional challenge at the...