3 import xml.etree.ElementTree
7 from general_ros
import *
8 from tmux
import restartPanes
13 f = file(fileLoc,
"r") 22 homeDir = os.path.expanduser(
"~")
23 logDir = homeDir +
"/log/" 25 folders = filter(
lambda x: os.path.isdir(logDir + x), os.listdir(logDir))
27 foldersTime = map(
lambda folder: (os.stat(logDir + folder)[stat.ST_MTIME], logDir + folder), folders)
30 logFolders = map(
lambda x: x[1], foldersTime)
44 rmFile(logFolder +
"/OBJ.bag.active")
45 rmFile(logFolder +
"/OBJ.bag")
46 rmFile(logFolder +
"/ism.log")
47 rmFile(logFolder +
"/world_model.log")
53 for subfolder
in os.listdir(folder):
54 if os.path.isdir(folder +
"/" + subfolder):
56 results.append(folder +
"/" + subfolder)
62 return os.path.isfile(folder +
"/state_machine.log")
68 writeDatabase(recognizer_prediction_ism_path +
"/param/scene_recognition.yaml", cfg)
71 print(
"restarting...")
76 et = xml.etree.ElementTree.parse(file)
77 rosparams = et.findall(
".//rosparam")
78 rosparams = filter(
lambda x :
"world_description" in x.attrib[
"file"], rosparams)
79 assert(len(rosparams) == 1)
80 rosparams[0].attrib[
"file"] = cfg[
"world_description"]
85 dataMap[
"dbfilename"] = cfg[
"database"]
90 dataMap[
"config_file_path"] = cfg[
"fake_recognizer_objs"]
96 dataMap = yaml.load(f)
102 if flow_style
is True:
103 yaml.dump(dataMap, f)
105 yaml.dump(dataMap, f, default_flow_style=
False)
114 worldModelPane = (5, 1)
115 vizServerPane = (6, 0)
117 initialSearchmanagerPane = (8, 0)
119 ptuDriverPane = (10, 0)
120 ptuControllerPane = (10, 1)
121 ptuControllerCliPane = (10, 2)
122 ptuRefreshFrustumPane = (10, 3)
123 fakeRecognizerPane = (11, 0)
130 initialSearchmanagerPane,
166 (-0.685, -0.54, 275),
167 (-0.956, -0.56, 290),
203 cfg_story1_missing_knife = {
204 "world_description" :
"$(find asr_world_model)/rsc/world_descriptions/world_description.yaml",
205 "database" : resources_for_active_scene_recognition_path +
"/scene_recordings/story_1.sqlite",
206 "fake_recognizer_objs" :
"./config/story_1.xml",
207 "startPositions" : [(positions[0][0], orientations[0])]
210 cfg_story1_schrank = {
211 "world_description" :
"$(find asr_world_model)/rsc/world_descriptions/world_description.yaml",
212 "database" : resources_for_active_scene_recognition_path +
"/scene_recordings/story_1.sqlite",
213 "fake_recognizer_objs" :
"./config/story_1_schrank.xml",
214 "startPositions" : [(positions[4][0], orientations[0])]
219 "world_description" :
"$(find asr_world_model)/rsc/world_descriptions/world_description.yaml",
220 "database" : resources_for_active_scene_recognition_path +
"/scene_recordings/story_1.sqlite",
221 "fake_recognizer_objs" :
"./config/story_2_tisch.xml" 226 "world_description" :
"$(find asr_world_model)/rsc/world_descriptions/world_description_25th_may.yaml",
227 "database" : resources_for_active_scene_recognition_path +
"/scene_recordings/scene_25th_may.sqlite",
228 "fake_recognizer_objs" :
"./config/scene_25th_may.xml",
229 "startPositions" : [(positions[2][5], orientations[0])]
233 cfg_story1_missing_knife,
242 for file
in os.listdir(folder):
243 if os.path.isfile(folder +
"/" + file):
244 if file.endswith(
"sqlite"):
245 cfg[
"database"] = os.path.abspath(folder +
"/" + file)
246 constellation_indices = re.findall(
"recognition_(.*)_constellation.*xml", file)
247 constellation_idx = int(constellation_indices[0])
if len(constellation_indices) > 0
else -1
248 if constellation_idx > highest_idx:
249 highest_idx = constellation_idx
250 cfg[
"world_description"] =
"$(find world_model)/rsc/world_descriptions/world_description.yaml" 251 cfg[
"fake_recognizer_objs"] = os.path.abspath(folder +
"/" +
"recognition_" + str(highest_idx) +
"_constellation_0.xml")
255 f = open(folder +
"/state_machine.log",
"r") 257 result = re.findall("Initial robot state:\r$\n^(.*\r$\n^.*\r$\n^.*\r$\n^.*\r$\n^.*)\r", content, re.M)
260 robot_state_str = result[0]
261 rows = robot_state_str.split(
"\r\n")
264 key = row.split(
":")[0].strip()
265 value = float(row.split(
":")[1].strip())
266 robot_state_map[key] = value
267 pos = (robot_state_map[
"x"], robot_state_map[
"y"], degrees(robot_state_map[
"rotation"]))
268 orientation = (robot_state_map[
"pan"], robot_state_map[
"tilt"])
269 return (pos, orientation)
275 dataMap =
getYaml(fake_object_recognition_path +
"/param/params.yaml")
277 if cfg[
"fake_recognizer_objs"] == dataMap[
"config_file_path"]:
def restartPanes(windowAndPanes)
def setConfig(cfg, restart=True)
def getLogSubFolders(folder)
def writeDatabase(file, cfg)
def getStartPosition(folder)
def setPositionAndOrientation(positionAndOrientation)
def reduceLogSize(logFolder)
def saveYaml(file, dataMap, flow_style=False)
def writeFakeRecognizer(file, cfg)
def writeWorldLaunchFile(file, cfg)