How to inspect service and make a service call
In this article, we will walk through the process of service inspection and present an example of making service call.
The first step is to list available services on the network
The second command list both service name and the request type.
Suppose we have a service called /add_entity
. The next step is to find out the reques type of this service. This can be done using the following command:
The output of this command is the service request type. Suppose the output is entity_management/srv/AddEntity
. The next step is to find out the details of this type. This can be done using the following command:
The interface show
command produces the details of the type. For example,
To summarize, we have collected the following information:
service name
/add_entity
service request type
entity_management/srv/AddEntity
service response type
bool
fields in the request type
name, model_filepath, location, theta
The remaining question is how can we make a service call? The command to use is ros2 service call <service_name> <service_type>
. Here is an example:
The space in the command is significant, especially the one following the colon (:) that comes after the field name.
©2023 - 2024 all rights reserved
Last updated