Ask Your Question
0

how to make two calls parallel?

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

in my code, i need to call two services. they are independent

client1.call(service1);
client2.call(service2);
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?

thanks.

edit retag flag offensive close merge delete

Comments

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 imageMartin Peris ( 2012-10-29 21:02:06 -0500 )edit

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

yangyangcv gravatar imageyangyangcv ( 2012-10-29 22:41:39 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
4

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

Lorenz gravatar image

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

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

Comments

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

yangyangcv gravatar imageyangyangcv ( 2012-10-29 22:38:07 -0500 )edit

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

Lorenz gravatar imageLorenz ( 2012-10-29 23:07:27 -0500 )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 imagemachinekoder ( 2019-10-03 08:16:41 -0500 )edit
0

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

jbohren gravatar image

You can use this wrapper for non-blocking service calls in Python: https://gist.github.com/jbohren/e3324...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 1,187 times

Last updated: Aug 29 '16