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

Service called by many nodes at the same time

asked 2022-02-16 20:59:52 -0600

Kevin1719 gravatar image

I have a service that returns available stations for robots when their batteries are low. The station is 'busy' if there was already a robot in there or there is a robot is going to that station. Everything was fine until 2 robots at low battery state at a time, then they called the service simultaneously and then the service returned a station as a destination point for both robots. What i have gone wrong? What should I do to avoid this conflict?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-02-17 02:30:01 -0600

Kevin1719 gravatar image

In my service server, where I find available stations, I called another service to assign goal destination to robots, so when the 'station' service is called, it calls the 'assign' service and then return to receive the queued request, at this time, the previous 'assign' service doesn't finish yet, so it will not return the goal as a 'busy' station, that's why I have the conflict. In order to do this, I added a element called 'success' in my 'goal' service, so that if this service is done, 'success' is set to True, and the 'station' service will have to wait for this condition to happens to returns a response.

edit flag offensive delete link more
2

answered 2022-02-17 01:53:31 -0600

abhishek47 gravatar image

then the service returned a station as a destination point for both robots. What i have gone wrong? What should I do to avoid this conflict?

This doesn't seem to be a ROS issue. In general, when a service is requested "simultaneously", the requests are queued.

station is 'busy' if there was already a robot in there or there is a robot is going to that station [...] service returned a station as a destination point for both robots.

From the wording it sounds like the same available-station was returned as a response to both robots. To fix this conflict, I'd look into how the service server updates its record of available stations. If I had to hazard a guess, a station that is sent back as a response is not immediately transitioned to "busy", and then when the next request comes through the same station is sent back.

edit flag offensive delete link more

Comments

So if the requests are queued, the service server will receives the first request and returns a response, then receives the next request and returns the second response. Thank you so much, I have solve the problem!

Kevin1719 gravatar image Kevin1719  ( 2022-02-17 02:23:50 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2022-02-16 20:59:52 -0600

Seen: 150 times

Last updated: Feb 17 '22