liveBook · Manning

Client-server architecture

As explained in Robotics for Programmers

The client-server model organizes communication so that clients request services and servers provide them.

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

How Robotics for Programmers covers it

How deep it goes
Explains RPC flow, communication cardinality, blocking behavior, and asynchronous Python implementation, but not middleware internals.
Examples
Uses a ROS 2 SetBool service, Python server and client nodes, command-line invocation, and the RQt Service Caller plugin.
What it assumes
Assumes familiarity with ROS nodes and Python-like function calls while distinguishing network RPCs from in-process calls.
What you can do after
Build it from scratch as a ROS 2 service server or client using typed requests, callbacks, asynchronous calls, and command-line testing.
How it connects
Connects remote procedure calls with ROS services, nodes, topics, actions, parameters, and publish-subscribe communication.

Also explained in

Compare how 8 books explain client-server architecture →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Robotics for Programmers. The section links point to the parts of the book it draws on.