How to call several action servers from the same action client at the same time

asked 2022-06-04 18:59:04 -0500

xaru8145 gravatar image

Hi all,

I have a system that is running an action client that communicates to 3 different action servers. I am using ROS1 melodic and cpp. Sending an action from the client to the 3 servers would look like this.

if (ac1.isServerConnected())
            ac1.sendGoal(goal, &doneCb, &activeCb, &feedbackCb);
if (ac2.isServerConnected())
            ac2.sendGoal(goal, &doneCb, &activeCb, &feedbackCb);
if (ac3.isServerConnected())
            ac3.sendGoal(goal, &doneCb, &activeCb, &feedbackCb);

I have a mutex guard on each doneCb, activeCb and feedbackCb to avoif them to be triggered at the same time in case the 3 servers finish at the same time. Also, the way to send the goal is sequential so the 3 servers will not start at the same time. I need them to be synchronized and be called at the same time, maybe by multi-threading.

But this would not be done by opening 3 continuous threads since when the actions from the 3 servers finish, the threads can be closed and re-opened when 3 new actions come in.

Thanks in advance for reading.

edit retag flag offensive close merge delete