ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ROS does not provide any guarantees about request latency, scheduling delay, processing time or response latency when using services (or topics for that matter). For two nodes running on the same computer these delays are typically between a few milliseconds and a few hundred milliseconds.

Unlike topics, services are synchronous and the client must wait for the transport delay in both the request and the response.

Service clients can be persistent or non-persistent. Persistent clients only have to establish the TCP session once; non-persistent clients create a new TCP session for every request. Setting up the TCP session can add latency, but it increases the client's robustness to changes in the server's address (such as when the server node is stopped and restarted).

With those facts about services in mind, I can help you find answers to some of your questions:

  • Is it a good idea to put a ROS service client in my robot hardware code?
    • This depends on your requirements and how you plan to use the service client. If you are using services in the feedback loop they may work if your system has a lot of inertial or a slow time-constant, but they're clearly not appropriate for systems that need to run at 1kHz or more. If you're just using services for occasional updates and with a good threading model they're probably fine in any system.
  • Will it increase the time-delay of the hardware node and make my robot unable to work correctly?
    • This is completely dependent on how you write you code.
  • Does PR2 robot use ROS service in its hardware node?
    • The PR2 uses services, topics, non-blocking queues, and a few other real-time software techniques in the node that runs the real-time control loops. The PR2 needs to run the control loop at 1kHz, so it also runs the real-time thread with increased priority on a linux kernel with the rt-preempt patches. The combination of these tools is far more important than their presence.
  • When should I use ROS service compared with ROS messages?
    • This has been asked and answered many times before: http://answers.ros.org/question/11834/when-should-i-use-topics-vs-services-vs-actionlib-actions-vs-dynamic_reconfigure/