Client-server architecture organizes communication around a requester and a provider. In ROS, a client makes a remote procedure call to a server, which processes parameters and returns a value. The call resembles a function call, but crosses a network boundary. section 4.6
A ROS service typically works as follows:
- The client creates a request and sends it to a named server. section 4.6
- The server runs its callback, handles the client in isolation, and constructs a response. section 4.6
- The client waits for or asynchronously receives the return value, making services suitable for sporadic operations that require confirmation. section 4.6
- Unlike topics, which support many publishers and subscribers for streaming data, services generally form an N:1 relationship between clients and one server. section 4.6
A ROS 2 Boolean service
A Python server registers a SetBool service named my_set_bool_service, sets response.success and response.message, and spins as a ROS node. A client creates a matching request and calls it asynchronously; the command ros2 service call /my_set_bool_service std_srvs/srv/SetBool 'data: true' returns a success response. section 4.6
ros2 interface show std_srvs/srv/SetBool
Inspect the SetBool service interface to see its request field and response fields before implementing either side. section 4.6







