How to make a service request inside a callback function
Hey there,
I am new to ROS trying to get some code running on a robot. Therefore I went to some tutorials on the web and have a brief understanding of the ROS concept.
The task I am dealing with right now is as follows: given two nodes (AGENT and ROBOT) I want the robot to detect some objects which are defined by the AGENT-node in a single frame. So the AGENT sends a service-request (detect-object) to the ROBOT-node. So far so good the problem occurs now: The callback function executed inside the ROBOT-node needs to know which objects to detect and therefore sends a service request back to the AGENT-node asking for the object-list. (I know the detect-object.srv could forward the object-list but since it is not my framework I have to deal with the services as they are:/) The problem is (as far as I understand) that the first servic-request blocks the second... I found some comments on ros::AsyncSpinner but it is still not clear to me how to use this :/ So question 1): Is the process calling a service request inside a service request a good idea? question 2): If 1):yes is ros::AsyncSpinner the right choice? If 1): no what is a good idea then? question 3): if ros::AsyncSpinner is the right choice, could you please give a short explaination how to use it properly?
Thx a lot for your comments!
When agent node sends a service request, you can pass the object list (can be obtained by calling that specific service and including it in the service request to the robot node). If you cannot modify either services, can make a third that includes both in the request to the robot node.
Passing the object list via this request seems the most convenient one! however, the services should stay fixed. Could you please go more into detail about the third service? Apart from this, would it be possible to send a service request inside a callback and how?
From the second service being called, is the object-list part of the service request message? Otherwise you would have to be modifying the service callback function which is not keeping the service fixed. Are you able to share any of either services so I can understand what is actually going on?