def start_proxies():
parser = argparse.ArgumentParser()
parser.add_argument('url', help='The url address of robot cloud.')
parser.add_argument('--services', '--srv', nargs='+', help='Services provided by ROSBridge server')
parser.add_argument('--published_topics', '--pub', nargs='+', help='Topics published to ROSBridge server')
parser.add_argument('--subscribed_topics', '--sub', nargs='+', help='Topics subscribed from ROSBrdge server')
parser.add_argument('--actions', nargs='+', help='Actions provided by ROSBridge server')
parser.add_argument('-q', '--queue_size', type=int, default=1000, help='ROS message queue size on each topic')
parser.add_argument('-t', '--test', action='store_true', default=False, help='Use if server and client are using the same ROS master for testing. Client service and topic names will have _ws appended.')
parser.add_argument('-i', '--image_id', help='Unique image id on the robot cloud.', default="")
args = parser.parse_args(rospy.myargv()[1:])
if not args.url.startswith('http'):
args.url = 'http://' + args.url
httpurl = args.url + '/getinstance/' + args.image_id
try:
req = urllib2.Request(httpurl)
url_and_containerid = urllib2.urlopen(req).read()
wsurl = url_and_containerid.split(" ")[0]
containerid = url_and_containerid.split(" ")[1]
except Exception, e:
rospy.logerr('Failed to get websocket address for image %s from %s. Reason: %s', args.image_id, httpurl, str(e))
return
flask_url = args.url + '/ping/' + str(containerid)
print "&&&&&"+flask_url+"%%%%%%"
proxy = keep_container_live(flask_url)
proxy.start()
rospy.init_node('cloud_proxy', anonymous=True)
for topic_name in args.subscribed_topics:
proxy = SubscribedTopicProxy(topic_name, wsurl, args.queue_size, args.test)
proxy.start()
for topic_name in args.published_topics:
proxy = PublishedTopicProxy(topic_name, wsurl, args.test)
proxy.start()
if args.services != None:
for service_name in args.services:
proxy = CallServiceProxy(service_name, wsurl, args.test)
proxy.start()
rospy.spin()
评论列表
文章目录