Important announcement

Dear visitor,

Please note that this OpenCourseWare platform will be replaced at the end of 2026 by a new platform (under the same url ocw.tudelft.nl).

Courses and their contents that are currently available the platform will partly be migrated. URL’s for this content will change and content might be unavailable for some time. In addition, some courses will not be available anymore.

If you are linking to specific courses on this platform (for instance for your students), please take timely measures to avoid problems with access. Possible actions are:

  • Download the materials to your local platform (laptop, server)
  • For educators only (including TU Delft lecturers): Contact us at ocw@tudelft.nl and inform us what course you are using in what context (institute, program, period of use, number of students). We will research (in collaboration with the authors of the course) and decide if we will migrate the course, and if yes, can supply you with a new url.

Thank you.

1.3.1 ROS Services

Course subject(s) Module 1. ROS Essentials

In this lecture, we will learn about the basic idea behind ROS services, that allow for a “request-response” communication between ROS nodes.

Summary:

So far, communications between nodes have been handled by topics. Topics can connect many nodes to many other other nodes. There are no acknowledgements between the nodes: they are simply pumping around information. This is very useful when monitoring certain values, but can become problematic with some types of information such as video data. In cases like those, it would be nice to only receive information when requested.

ROS services implement these request-response type of communications. They consist of two message types: One for requesting data, and one for the response. These services are the gateway to event-based ROS executions. Services are defined in the same package as messages, in their own /srv folder.
The nomenclature for ROS services: One ROS node is the service server. It advertises a service, and makes it available to other nodes. Another node is the service client. It sends a request message to the service server once the service is available.

Example

A useful example of a ROS service could be a service that converts measurements in metres to measurements in imperial feet. The request message would contain the measurement in metres, and the response would contain the measurement in imperial feet plus a boolean value indicating the conversion was successful.  We would create the file hrwros_msgs/srv/ConvertMetresToFeet.srv:

One important quality of services is that they are blocking: They stop the execution of program flow until the response has been received. This is useful for sequential behaviours. It also makes it desirable to have quickly executable computations for the service callback, so that the program is blocked for the least amount of time. There is also no going back on a service call: Once a request has been made, it will be processed until a response is sent. It can’t be interrupted.

Creative Commons License
Hello (Real) World with ROS - Robot Operating System by TU Delft OpenCourseWare is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://online-learning.tudelft.nl/courses/hello-real-world-with-ros-robot-operating-systems//.
Back to top
[sg_popup id=6]