What are best practices prior to calling a service?

asked 2021-04-12 03:09:54 -0500

ggg gravatar image

Hi, I have already used services in ROS 1, but it is not clear to me whether I am doing what is best. My concern is that, should the call to the service fail, I want to be sure it is because I improperly called it, not for other reasons. Also, I wish my client never to crash, so I would like to handle all the situations properly. Prior to calling the service, I check that the "exists" and "isValid" method both return true. My questions are:

  • What is the most logical order to perform these tests. I read the C++ API, but it is not clear to me what the exact meaning of these methods is, hence I do not know the proper order to call them.
    • Should the "exists" and "isValid" methods be called in the initialization phase of the client only, or at each execution.
  • Should I use the isPersistent method in the initialization phase of my client, since it seems the isValid method only truly makes sense if the service is not persistent.

I hope my question is clear enough. Thanks for your time.

edit retag flag offensive close merge delete