[ROS2] service failure feedback to client

asked 2021-05-05 21:19:16 -0600

LanceChen gravatar image

In ROS1, a service client would receive a false value when it either failed to call the service server, or there was some error such as invalid input. For example, the cpp api was specified like this.

bool callback(MReq& request, MRes& response);

However, in ROS2, the callback api returns a void, and there does not seem to be a way to indicate to the service client that the service is unavailable or failed. Several questions have been raised by other users on how to do this: here on ros answers, on ros discourse, and there is a open issue.

Just wondering whether the removal of the return value was a design decision and if so, what the reasoning behind it was. What would be the best way to replicate this functionality, or an alternative way of using services in line with the current implementation.

edit retag flag offensive close merge delete


in python you can use cli.service_is_ready() But I see that this function sometimes needs to be called repeatedly until it returns true.

highmax1234 gravatar image highmax1234  ( 2021-05-11 15:46:15 -0600 )edit

Calling service_is_ready would detect if the service node has crashed, but I'm also interested in the case where invalid input is given to the service, and so cannot properly handle the request.

LanceChen gravatar image LanceChen  ( 2021-05-11 18:52:17 -0600 )edit