call
Call ROS or ROS 2 service server and receive a response
Syntax
Description
sends
a default service request message and waits for a service response
= call(serviceclient
)response
.
The default service request message is an empty message of type serviceclient.ServiceType
.
specifies
a service request message, response
= call(serviceclient
,requestmsg
)requestmsg
, to be
sent to the service.
[
returns a response
,status
,statustext
] = call(___)status
indicating whether a
response
has been received successfully, and a
statustext
that captures additional information about the
status
, using any of the arguments from the previous
syntaxes. If the call fails, the status
will be
false
with an empty default response
message, and this function will not display an error.
Examples
Input Arguments
Output Arguments
Tips
ROS 2 service servers cannot communicate errors in callback execution directly to clients. In such situations, the servers only return the default response without any indication of failure. Hence, it is recommended to use try-catch blocks within the callback function, and set specific fields in the response message to communicate the success/failure of the callback execution on the server side.