Services
Services are another method of communication for nodes in the ROS graph. Services are based on a call-and-response model versus the publisher-subscriber model of topics. While topics allow nodes to subscribe to data streams and get continual updates, services only provide data when they are specifically called by a client.
With ROS 2 services, one or many “client” nodes can make requests to a “server” node and wait for its response. These make services great for performing on-demand tasks – like performing on-the-fly computations or simple one-time tasks.
Example (optional)
Two integer add via services here. Only the Python section is relevant.