ROS learning (3): message communication process

     The master node manages node information, and each node connects and communicates with other nodes as needed. Here, let's take a look at the process of the most important master nodes, nodes, topics, services, and action information.

1. Run the master node

     Among the message communication between nodes, the master node that manages the connection information is a necessary element that must be run first in order to use ROS. The ROS master node uses the roscore command to run, and uses XMLRPC to run the server. For the connection between the node and the node, the master node will register the name, topic, service, action name, message type, URI address and port of the node, and notify other nodes of this information when there is a request.

2. Run the subscriber node

     Subscriber nodes use rosrun or roslaunch commands to run. The subscriber node registers its subscriber node name, topic name, message type, URI address, and port with the master node at runtime. The master node and node communicate using XMLRPC.

 

Three. Run the publisher node

     The publisher node (similar to the subscriber node) is run using the rosrun or roslaunch command. The publisher node registers the publisher node name, topic name, message type, URI address, and port with the master node. The master node and the node communicate using XMLRPC.

Four. Notify the publisher of the information

     The master node sends to the subscriber node information such as the name, topic name, message type, URI address, and port of the publisher that the subscriber wants to access. The master node and the node communicate using XMLRPC.

Five. Subscriber node connection request

     The subscriber node requests a direct connection to the publisher node according to the publisher information received from the master node. In this case, the information to be sent includes subscriber node name, topic name, and message type. The publisher node and subscriber node communicate using XMLRPC.

 

6. The connection response of the publisher node

     The publisher node sends the URI address and port of the TCP server as a connection response to the subscriber node. The publisher node and subscriber node communicate using XMLRPC.

Seven. TCPROS connection

     The subscriber node uses TCPROS to create a client corresponding to the publisher node and directly connects to the publisher node. The communication between nodes uses a TCP/IP method called TCPROS.

 

8. Send a message

     The publisher node sends a message to the subscriber node. The communication between nodes uses a TCP/IP method called TCPROS.

 9. Service request and response

     The above content is equivalent to a topic in message communication. Topic message communication is that as long as the publisher or subscriber does not stop, it will continue to publish and subscribe. Services are divided into the following two types.

     1. Service client: wait for response after requesting service

     2. Service server: After receiving the service request, execute the specified task and send the response.

     The connection between the service server and the client is the same as the TCPROS connection between the publisher and the subscriber mentioned above, but different from the topic, the service connects only once, and disconnects each other after executing the request and response. If necessary, you need to reconnect.

 

10. The goal, result and feedback of the action (action)

     In the way of execution, it seems that there is only a halfway feedback link between the service request (goal) and the response (result), but the actual operation is the same as the topic. In fact, if you use the rostopic command to view topics, you can see five topics including goal, status, cancel, result, and feedback of the action. The connection between the action server and the client is the same as the TCPROS connection in the publisher and subscription described above, but some usages are slightly different. For example, if the action client sends a cancel command or the server sends a result value, the connection will be interrupted, etc.

In the previous content, we tested the operation of ROS with turtlesim. In this test, the main node and two nodes are used, and between the two nodes, the translation and rotation messages are transmitted using the topic /turtle1/cmd_vel

Give virtual turtles. If you think about it according to the ROS concept described above, it can be expressed in the following figure. Let us review the previous ROS operation test and think about it again with the concept of ROS.

Guess you like

Origin blog.csdn.net/kh815/article/details/88130015