0
$\begingroup$

Rosanswers logo

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?


Originally posted by Kevin1719 on ROS Answers with karma: 58 on 2022-02-16

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by abhishek47 with karma: 228 on 2022-02-17

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by Kevin1719 on 2022-02-17:
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!

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by Kevin1719 with karma: 58 on 2022-02-17

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.