def get_remote_service_info(service_name, url):
while True:
try:
ws = websocket.create_connection(url)
break
except Exception, e:
rospy.loginfo('Create connection to Rosbridge server %s failed, retrying. Reason: %s', url, str(e))
time.sleep(2)
try:
# get topic type
ws.send(json.dumps({
'op': 'call_service',
'service': '/rosapi/service_type',
'args': [service_name]
}))
x = json.loads(ws.recv())
assert x['service'] == '/rosapi/service_type'
ws.close()
if x['result']:
return x['values']['type']
else:
return ""
except Exception, e:
rospy.logerr('Get the type of service %s from Rosbridge server %s failed. Reason: %s', service_name, url, str(e))
ws.close()
return ""
评论列表
文章目录