ros Getting Started tutorial (Four) - Communications Architecture (lower)


This section describes the contents continue along the section of the communication architecture

Communication (Continued)

Service

We said before topic is the use of publish-subscribe way, but this one-way message transmission sometimes can not meet our needs.

ROS in the synchronous communication mode, may communicate by way of request-reply between Node.

Request
Reply
Client
/Service
Server

Here server Serveroutside will provide a service Service, another nodecan by request Requestto invoke the service. If no one calls, this service will not be executed.

Applies to some scenarios, such as a node wants to time to get the coordinates of the human body. At this point if we are to communicate with the Service's way, then you do not need to have been acquired sensor information and coordinate human transmission is performed only when there is a request.

Note: synchronous communication signifies, after sending the request will be blocked in the Client, until the server returns a result, Client will continue.

Topic VS Service

Here Insert Picture Description

Callback and RPC clear understanding

srv

Service data type or the format of the communication standard, in the definition file * .srv.

Request
Reply
node
/pose
node

srv file written as
Here Insert Picture Description

Fixed path, while the horizontal line format of the service request is required, the format of the response returned by the horizontal line. Request message should be as simple as possible. And it can only be nested inside srv msg files in HumanPose[]the file format in the following format on the requirements of the specification.

note

In their definition and finished modifying srv msg or after, to modify package.xmland CMakeList.txtfiles. Visible red portion of the FIG.

Common Commands

Here Insert Picture Description

Parameter Server

In fact, the server parameters in the execution roscorecommand, the system will automatically help us have a good start. It is inside a communication mode different from ROS synchronous communication and asynchronous communication. The way before topic and service more than static. Normally, we do not often change some of the parameters on the PS in order to read and write. At the same time, we can use the command line, launch files, and node (API) to read and write operations.

PS maintains a key store various parameters of the dictionary, the dictionary stores various parameters and configurations.
Here Insert Picture Description

From the command line

Here Insert Picture Description
In loadand dump, the must is YAML format, the following

name:'ZHANGSAN'
age:20
gender:'M'
score:{Chinese:80,Math:90|
Operation in launch file

Here Insert Picture Description

Modified API

See section roscpp and rospy

Action

For synchronous communication, Service needs to block after sending a request to wait for the results. The results may take some time relatively long, but this time for the client, the server does not know it is in execution or crashed. So we hope that server can provide feedback on the progress of a real-time follow-up. Meanwhile, when the server at time of service, we may also want to do anything else to interrupt the service operation, service at this time that this communication does not meet the needs. On this issue, Action came into being.

Action similar Service, communication with state feedback. Commonly used in a long time (e.g., a distance), preemptive (half done can be interrupted) tasks.

Here Insert Picture Description
goal: i.e. Request
Cancel: interrupt instruction
status: status of the server in which the
result: the operation result returned after processing
feedback: real-time status

action

Action communication data format defined in the file * .action.
Here Insert Picture Description
action should be divided into three sections:

  • The first paragraph: goal
  • The second paragraph: result (action executing the return, pass only once)
  • Third paragraph: feedback (real-time status, it may have been several times or return)
For example

Here Insert Picture Description

Please indicate the source.
This paper summarizes the Chinese University of MOOC "Android OS Getting Started"
link: Link .
Pictures from the video capture program

Published 43 original articles · won praise 20 · views 1475

Guess you like

Origin blog.csdn.net/Chen_2018k/article/details/104298649