Article Directory
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.
Here server Server
outside will provide a service Service
, another node
can by request Request
to 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
Callback and RPC clear understanding
srv
Service data type or the format of the communication standard, in the definition file * .srv.
srv file written as
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.xml
and CMakeList.txt
files. Visible red portion of the FIG.
Common Commands
Parameter Server
In fact, the server parameters in the execution roscore
command, 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.
From the command line
In load
and dump
, the must is YAML format, the following
name:'ZHANGSAN'
age:20
gender:'M'
score:{Chinese:80,Math:90|
Operation in launch file
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.
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.
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
Please indicate the source.
This paper summarizes the Chinese University of MOOC "Android OS Getting Started"
link: Link .
Pictures from the video capture program