Go to the documentation of this file.00001
00002
00003 import os, sys, string, time, getopt
00004 import urllib
00005 import roslib
00006
00007 import config
00008
00009 def grabTopics(hdf, topics):
00010 topics = topics + ["/power_state", "/power_board_state", "/app_status"]
00011 topicList = []
00012 for topic in topics: topicList.append("topic=%s" % topic)
00013 topics = string.join(topicList, "&")
00014
00015 url = "http://localhost:%s/ros/receive?since=0&nowait=1&%s" % (config.gROSBridgePort, topics)
00016 try:
00017 fp = urllib.urlopen(url)
00018 body = fp.read()
00019 fp.close()
00020
00021 hdf.setValue("CGI.cur.messages", body)
00022 except:
00023 pass
00024
00025 def list_apps():
00026 import subprocess
00027 import glob
00028
00029 apps = []
00030 cmd = ["rospack", "depends-on", "webui"]
00031 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
00032 while 1:
00033 line = p.stdout.readline()
00034 if not line: break
00035 pkg = line.strip()
00036
00037 path = roslib.packages.get_pkg_dir(pkg)
00038 files = glob.glob(os.path.join(path, "*.app"))
00039 for app in files:
00040 apps.append(app)
00041 return apps
00042
00043 def set_tabs(hdf, tabs):
00044 i = 0
00045 for tab in tabs:
00046 hdf.setValue("CGI.cur.tabs.%d" % i, tab)
00047 i += 1
00048
00049 def hdf_array(hdf, array, prefix):
00050 i = 0
00051 for element in array:
00052 hdf.setValue("%s.%s" % (prefix, i), element)
00053 i += 1
00054