proxy.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:Cloudroid 作者: cyberdb 项目源码 文件源码
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 ""
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号