How to handle exceptions in the user-defined-callback in service-server and how to inform service-client about the failed-service-call in ros2 rclcpp ?
I am facing an issue in ros2 rclcpp services. I have a service-server in one machine and service-client in other machine. Now if the service-server callback throws any exception, how service-client will be informed that some issue occurred and the service call failed.
I cannot send a default response and I cannot add any extra field also in the response in my case. Please help me if there is any way to handle it in rclcpp apis and framework .
Earlier I was working on ros1(roscpp) and ros1 service-server-callback returns a bool(we can return true if success and false if fails). In service-client accordingly we can get true/false from call(). If call() returns false, that means service-call failed. How can I do similar things in ros2 rclcpp ?
Please help me on this. Thanks in advance :)
I'd like to know how to do this too (in Python). Is the best solution to include an
is_ok
boolean field in the service response?@SmallJoeMan I think it is currently the most elegant solution... (Most of ROS2 services use the name
success
for the boolean field)