Service in ROS
Followed by previous post covering message in ROS, this one introduce service in ROS.
Service is another information exchange mechanism provided in ROS which
provides RPC (remote procedure call) style request-response pattern.
The service is defined by .srv
file, which can be treated as a combination
of two message representing service request and service reply, respectively.
Most of information in this post is refer to Services page in ROS wiki, srv page in ROS wiki and source code for ROS core module.
.srv
file
.srv
file declares an exposed service of a package. Service files are declared within srv
folder, and following the same composing rule as the message file, with an extra seperator for separation of request and response.
For example
utilize service
To utilize service, add corresponding declaration to build files.
Then catkin
will generate source code in all supported languages.
Import the generated code into your code base to provide service.