What is a ROS 2 service?
You discovered the concept of ROS 2 services in Chapter 3, in the Services section, where you ran your first service server and client to get an intuition of how they work. You also became familiar with the ros2
command-line tool for handling services from the Terminal.
From here, I will start from scratch again and explain what services are, using a real-life analogy. We will build an example, step by step, and then recap the most important points.
A server and a client
To start, I will use an online weather service as an analogy.
This online weather service can tell us the local weather after we send our location. To get the weather report for your city, you will need to interact with this service. You can use your computer to send a web request with the URL provided by the service.
What’s going to happen? First, your computer will send a request to the weather service. The request contains your location. The service will receive the...