- Robot Operating System Cookbook
- Kumar Bipin
- 777字
- 2025-03-01 11:46:05
Getting ready
This computation network can be called the computation graph. The basic concepts in the computation graph are ROS nodes, master, parameter server, messages, topics, services, and bags. Each concept in the computational graph has a specific contribution in different ways.
The ROS communication-related packages, including core client libraries, such as roscpp and rospython, and the implementation of concepts such as topics, nodes, parameters, and services, are included in a metapackage called ros_comm. Moreover, this stack also consists of tools such as rostopic, rosparam, rosservice, and rosnode, which introspect the preceding concepts.
The ros_comm stack contains the ROS communication middleware packages, and these packages are collectively called the ROS graph layer, which is show in the following figure:

ROS computational graph
The following are abstracts of each graph's concepts:
- ROS nodes: ROS nodes correspond to the process in the Linux system that performs specific tasks. Also, ROS nodes are written using ROS client libraries such as roscpp and rospy, which support the implementation of different types of communication methods, mostly ROS messages and ROS services. Using the ROS communication methods, they can exchange data and create an ROS computational network. However, ROS has a design philosophy of having several nodes that provide only a single functionality, rather than having a large node that makes everything in the system. For example, in a robotic system, there will be different nodes to perform specific kinds of tasks such as perception, planning, and control.
- The ROS master: The ROS master provides the registration of names and the lookup service for the rest of the nodes and is responsible for setting up connections between the nodes. In an ROS system, nodes will not be able to find each other, exchange messages, or invoke services without a ROS master. However, in a distributed system, it could be possible to run the master on one computer, and other remote nodes can find each other by communicating with this master.
- The ROS parameter server: The parameter server allows the ROS system to keep the data or configuration information stored in a central place. All nodes can access and modify these values. The parameter server is a part of the ROS master.
- ROS messages: ROS nodes communicate with each other through messages, which contain data that provides information to other nodes. Although ROS has standard primitive types (integer, floating point, Boolean, and so on), it provides a mechanism to develop custom types of messages using standard message types.
- ROS topics: Each message in ROS is transported using named buses called topics. When a node sends a message through a topic, in ROS terminology, it is said that the node is publishing a topic. Similarly, when a node receives a message through a topic, it is said that the node is subscribing to a topic. However, as the publishing node and subscribing node are not aware of each other's existence, a node could even subscribe to a topic that might not have a publisher. This allows us to decouple production from consumption. Moreover, it's important that topic names are unique to avoid problems and confusion between topics with the same name.
- ROS services: In some robot applications, a publish-subscribe model will not be enough although it needs a request-response interaction. The publish-subscribe model is a kind of one-way transport system whereas when, working with a distributed system, a request-response kind of interaction might be required. ROS services are used in such cases. Also, the ROS service definition contains two parts – one is for requests and the other is for responses. In addition, it also requires two node servers and clients. The server node provides the service under a name, and when the client node sends a request message to this server, it will respond and send the result to the client. The client might need to wait until the server responds. The ROS service interaction is like a remote procedure call (RPC).
- ROS bags: ROS bags are a file format for saving and playing back ROS message data. These are an important mechanism for storing data, such as sensor data, which can be difficult to collect but is necessary for developing and testing robotic algorithms. Bags are very useful features for development and debugging. We will discuss ROS bags in upcoming chapters.
The following graph shows how the nodes communicate with each other using topics. The topics are represented in a rectangle and nodes are represented in ellipses. The messages and parameters are not included in this graph. The tool used to create the graph is rqt_graph; we will discuss it in detail in Chapter 3, ROS Visualization and Debugging Tools:

Communication graph