What is Ros (2) - Overview of structure and communication

Table of contents

1. Architecture

2.Communication

references


Continued from:What is Ros (1)-CSDN Blog

1. Architecture

There are three layers in total: OS layer, middle layer, and application layer.

OS layer: The OS layer is the operating system layer, which is the ubuntu (linux) we use now. You only need to understand it. It is only used for applications and no changes are required

Middle layer: Here are TCPROS/UDPROS, Nodelet API, and ClientLibrary.

       TCPROS/UDPROS: is a secondary encapsulation based on TCP and IP protocols named TCPROS and UDPROS;

       Nodelet API: In order to make up for some deficiencies in the use of TCPROS/UDPROS, it uses a shared memory method instead of network transmission to achieve some data sharing;

       ClientLibrary: It is a client library. This library refers to encapsulating UDPROS and TCPROS into some specific communication implementation methods of ROS, such as the topics we will mention later. , services, etc.;

Application layer: The leftmost part of the application layer is a Master. The Master is framed together with the middle layer, and a Ros is marked on it. This is because the Master node is necessary and unique for every Ros process, so the Master node is also officially provided by Ros. It is used to manage the Nodes and so on of the application layers on the right. And each note is an independent application.

Summary: Just understand the OS layer and middle layer, what you really need to develop yourself is the application layer

node: an executable program process, usually a node is responsible for a single function of the robot, if the camera is connected to ROS , where Camera Node is a camera node. Different nodes can use different programming languages ​​C++ or python. Nodes under the same ROS have no requirements for programming languages. Each node can use different languages. You can also run the Image Display Node, an image processing node on another computer. In other words, Ros nodes can run on different robots under the same LAN. This is the distributed computing capability of ROS.

master: Each node is responsible for a separate part of the function. To discover each other, a master is needed for nodes to discover each other. The master is equivalent to a management center. When each node starts, it must first register with the master to tell the master its basic information, what topics it needs to subscribe to, and what topics it needs to publish. The communication between nodes is also "matched" by the master first, and then point-to-point communication can be carried out in pairs. There is only one master in a ROS calculation graph
 

2.Communication

Communication methods between nodesThere are 4 implementation methods, namely topic, service, action and parameter:

Topic: One-way communication, Publisher only sends and Subscriber only receives

Service: Two-way communication, the request is sent from the Client to the Server. After the request is executed, the server returns a response to the client. It is the service process, but if there is no response for a long time, it is considered that the communication has failed.

Action: It is an upgraded version of the service. The service is when the client sends a request and the server returns a response. This mode is very useful when the task execution cycle is short. For example, if you ask the server to turn off the lights, the server will turn off the lights immediately, and then return a response to tell you that the lights have been turned off. But if you use a service method to ask the robot to cut down a forest, you will not receive any reply until the cut is completed. At this time, it is impossible to determine whether the request has not been received or whether it is being executed. The service is not suitable for tasks with long execution cycles like this. So the action method was born. So in the action, the request containing goal and cancel is sent from the client to the server, and the response containing status, result and feedback is returned by the server.

The difference between Action and Service is that it has multiple replies. For example, if you ask a robot to cut down a forest, the robot will first respond with a status. It tells you the current status of starting to cut down, and also provides feedback to periodically report how many trees have been cut down so far. Finally, the cutting was completed, and a result was received indicating that the tree had been cut down. When the client receives the result, it knows that this set of actions has ended. If you want to cancel the action during execution, it also provides a cancel interface to cancel the request. It should be noted here that there can be multiple feedback and status, but the result will only be published once.

Parameter server: It is a relatively special mechanism. It is not a node, and we do not specifically start it when starting it. It runs in the Master and is where the nodes store parameters. For example, when a node starts, it needs to obtain the variable f. If this variable is not stored in the parameter server, it will use some default values

references

1.ROS introduction and common instructions_ros command-CSDN blog

Guess you like

Origin blog.csdn.net/weixin_48878618/article/details/134753874