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

This is tough.

If there's a specific operation where you want to reduce the latency, you should measure the latency at each step of the process and work to reduce the largest sources of latency first.

In the case of a ROS service call taking too long, my gut tells me the largest source of latency would be the service connection setup.

I suggest you collect timestamps at the following points, to see where the latency is:

  • Immediately before the service client is created
  • Immediately before you make the service call
  • Within the service call, collect the following timestamps and return them as part of the service result:
    • Beginning of service callback
    • Immediately before you send data over USB (if this differs significantly from the beginning)
    • Immediately after you send data over USB
    • If you're expecting data back over USB, a timestamp after you get data back over USB
    • Immediately before your service callbacks returns
  • Immediately after the service call returns in the client

From those timestamps, you should be able to see how long it takes to set up the service client, how long it takes for the service call to get from the client to the server, how long your USB transaction takes, and how long it takes to get the result back.

Once you have that data, that will show whether the underlying issue is setup latency, scheduling latency in the server, USB latency, or something else.