Can wait_for_service bring up a service?
I wonder if rosservice list
should show the service which is later used by rospy.wait_for_service
? According to the test below, it is not necessary. Does rospy.wait_for_service
brings up a service if it is not run yet?
Longer explanation: I augmented pr2_controller_manager
with listing the services before and after:
def load_controller(name):
service_list = rosservice.get_service_list()
print('/pr2_controller_manager/load_controller ' + str('/pr2_controller_manager/list_controller_types' in service_list))
rospy.wait_for_service('pr2_controller_manager/load_controller')
s = rospy.ServiceProxy('pr2_controller_manager/load_controller', LoadController)
resp = s.call(LoadControllerRequest(name))
service_list = rosservice.get_service_list()
print('/pr2_controller_manager/load_controller ' + str('/pr2_controller_manager/list_controller_types' in service_list))
if resp.ok:
print "Loaded", name
return True
else:
print "Error when loading", name
return False
Output:
/pr2_controller_manager/load_controller False
...
/pr2_controller_manager/load_controller True
A followup question: I implement my own controller manager in a similar way, however, the code freezes at rospy.wait_for_service()
, which means that service cannot be brought up. How can I debug it?
Not a full answer, but: no,
wait_for_service(..)
does not bring up anything. It just waits. Potentially infinitely long, until a service server gets registered with the master.Ok, so another node starts the service while
wait_for_service(...)
waits for it, right?Unless the node that is waiting for the service server also supplies the service, then yes, another node must start the service server.