8  Services

Important

You are reading the work-in-progress edition of ROS 2 : Mea Via et Mea Disciplina. This chapter is currently a dumping ground for ideas, and we don’t recommend reading it. The complete version will be available here soon. Stay tuned!

ROS2, services are a way for nodes to request a specific operation from another node and receive a response. Services are similar to topics, but instead of sending and receiving messages, nodes send requests and receive responses.

Services are defined using a service description file that specifies the name of the service, the types of the request and response messages, and any necessary parameters or options. The service definition is used to generate code that can be used by nodes to implement or use the service.

When a node wants to use a service, it sends a request message to the node that provides the service. The service provider receives the request message, performs the requested operation, and sends a response message back to the requester. Once the response is received, the requester can continue with its operation.

Services are typically used for operations that require a direct response, such as configuring a sensor, performing a calculation, or sending a command to a robot. Unlike topics, services are synchronous, meaning that the requester will block until it receives a response from the service provider.

In ROS2, services are an important part of building distributed robotic systems, as they allow nodes to request specific operations from other nodes and receive a response. By using services, nodes can communicate in a decoupled manner and perform complex operations without needing to know anything about each other’s internal workings.

In summary, services in ROS2 are a way for nodes to request a specific operation from another node and receive a response. Services are defined using a service description file and are used for operations that require a direct response. Services are an important part of building distributed robotic systems, as they allow nodes to communicate in a decoupled manner and perform complex operations without needing to know anything about each other’s internal workings.