17 from time
import sleep
22 from string_util
import *
32 from general_ros
import *
33 from configuration
import *
35 from personal_stuff
import *
36 from asr_world_model.srv
import GetMissingObjectList
37 from asr_msgs.msg
import AsrObject
40 readline.parse_and_bind(
"tab: complete")
44 rospy.init_node(
"general_configuration", anonymous =
True)
47 ObjectDetectorsManager = imp.load_source(
"ObjectDetectorsManager", scene_exploration_path +
"/src/common/object_detectors_manager.py").
ObjectDetectorsManager()
50 global detectedObjects
53 global detectedObjects
54 if data.type
not in detectedObjects:
55 detectedObjects[data.type] = 1
57 detectedObjects[data.type] += 1
60 global detectedObjects
62 if type(recognizers)
is not list:
63 recognizers = [recognizers]
64 if len(recognizers) == 0:
65 rospy.wait_for_service(
"/env/asr_world_model/get_missing_object_list", timeout=5)
66 get_missing_object_list = rospy.ServiceProxy(
"/env/asr_world_model/get_missing_object_list", GetMissingObjectList)
67 missing_pbd_typeAndId = get_missing_object_list().missingObjects
68 print(missing_pbd_typeAndId)
69 for obj
in missing_pbd_typeAndId:
70 recognizers.append(str(obj.type))
71 ObjectDetectorsManager.start_recognizers(recognizers)
72 future = time.time() + waitTime
73 sub = rospy.Subscriber(
"/stereo/objects", AsrObject, detection_callback)
74 while (time.time() < future):
78 ObjectDetectorsManager.stop_recognizers(recognizers)
79 return detectedObjects
83 subprocess.call(
"tmux new-session -d", shell=
True)
84 subprocess.call(
"tmux send-keys \"roscd asr_resources_for_active_scene_recognition/launch/\" C-m", shell=
True)
85 subprocess.call(
"tmux send-keys \"./start_modules_sim.sh\" C-m", shell=
True)
93 processNames = [
"gzserver",
"roslaunch",
"asr_world_model",
"rosout",
"visualization",
"rp_ism_node",
"roscore",
"move_base",
"asr_mild_base_fake_driving",
"state_publisher",
"grid_action_server",
"asr_object_database",
"asr_fake_object_recognition",
"asr_flir_ptu_driver",
"PTUController",
"map_server",
"asr_next_best_view",
"next_best_view_robot_model",
"rosbag",
"record",
"rviz",
"static_transform_publisher",
"rosmaster",
"gdb"]
94 for proc
in psutil.process_iter():
95 if proc.name
in processNames
or (
"python" in proc.name
and proc.pid != os.getpid()):
96 print(
"terminating " + proc.name)
108 return result !=
False 117 content =
getFile(logdir +
"/state_machine.log")
124 curPane.send_keys(
"", enter=
True)
127 result = re.findall(
".*State machine terminating '.*(?:SEARCH|SCENE_RECOGNITION).*':'(.*)':'.*", smLog)
128 return result[0]
if type(result) == list
and len(result) > 0
else False 131 result = re.findall(
".*State machine terminating '.*(?:SEARCH|SCENE_RECOGNITION).*':'(.*)':'.*",
getFile(logDir +
"/state_machine.log"))
132 return result[0]
if type(result) == list
and len(result) > 0
else False 145 startAll(positions[0][0], orientations[0])
def getLogSMResults(logdir)
def restartPanes(windowAndPanes)
def terminateAllModules()
def startRecognition(recognizers=[], waitTime=2)
def getSMResultFromFileContent(smLog)
def detection_callback(data)
def getTmuxOut(windowNameOrId, paneId)
def terminatePanes(windowAndPanes)
def setBase(x, y, rotation)
def waitForAllModules(silence=False)
def selectWindow(windowNameOrId)
def getLastLinesFrom(str, pos)
def startAll(basePos, ptuPos)