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

how to make two calls parallel?

asked 2012-10-29 20:44:40 -0600

in my code, i need to call two services. they are independent;;
do something after both of them get responses

with the above pseudo code, it seems that the two calls are executed sequentially, i.e., client2 will not execute until client1 gives a response. since the two services are provided by two nodes, i hope that there is a kind of non-blocking mode. i.e., after client1 calls the service, it goes directly to the next line to let client2 call service2. how can i fulfill this?


edit retag flag offensive close merge delete


I don't know if there is any non-blocking service call in ROS, but in case there is not... how about launching the service calls in separate threads?

Martin Peris gravatar image Martin Peris  ( 2012-10-29 21:02:06 -0600 )edit

thanks man. multi-threads makes me headache :-( maybe i could give openmp a try

yangyangcv gravatar image yangyangcv  ( 2012-10-29 22:41:39 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2012-10-29 22:18:06 -0600

Lorenz gravatar image

updated 2012-10-29 23:06:49 -0600

ROS does not have a non blocking mode for services and it should not need one. The reason is that services should never be used for long running processes. In such cases actions are much better. See here for a discussion.

edit flag offensive delete link more


thanks. but the link you gave just links to this page. could you check the link again?

yangyangcv gravatar image yangyangcv  ( 2012-10-29 22:38:07 -0600 )edit

Updated. Sorry. Seems like it was a bug in the answers site.

Lorenz gravatar image Lorenz  ( 2012-10-29 23:07:27 -0600 )edit

And what if you are not in control of the implementation, let's say a robot where only service calls are available?

machinekoder gravatar image machinekoder  ( 2019-10-03 08:16:41 -0600 )edit

answered 2016-08-29 14:31:25 -0600

jbohren gravatar image

You can use this wrapper for non-blocking service calls in Python:

edit flag offensive delete link more

Question Tools


Asked: 2012-10-29 20:44:40 -0600

Seen: 2,735 times

Last updated: Aug 29 '16