34 import roslib; roslib.load_manifest(
'pr2_calibration_launch')
38 import capture_executive.capture_exec
40 from calibration_msgs.msg
import RobotMeasurement
44 print(
"Starting executive...")
47 rospy.init_node(
"pr2_capture_executive_node")
49 samples_dir = rospy.myargv()[1]
50 config_dir = rospy.myargv()[2]
52 executive = capture_executive.capture_exec.CaptureExecutive(config_dir)
55 left_sample_names = [x
for x
in os.listdir(samples_dir +
"/left/")
if ".yaml" in x]
56 right_sample_names = []
58 right_sample_names = [x
for x
in os.listdir(samples_dir +
"/right/")
if ".yaml" in x]
59 far_sample_names = [x
for x
in os.listdir(samples_dir +
"/far/")
if ".yaml" in x]
61 left_sample_names.sort()
62 right_sample_names.sort()
63 far_sample_names.sort()
65 print(
"Left Samples: \n - %s" %
"\n - ".join(left_sample_names))
66 print(
"Right Samples: \n - %s" %
"\n - ".join(right_sample_names))
67 print(
"Far Samples: \n - %s" %
"\n - ".join(far_sample_names))
69 pub = rospy.Publisher(
"robot_measurement", RobotMeasurement)
72 left_success_count = 0
74 right_success_count = 0
80 keep_collecting =
True 82 while not rospy.is_shutdown()
and keep_collecting:
83 print(
"Choose L,R, or F")
85 if string.upper(resp) ==
"L":
86 print(
"Choose sample index")
88 cur_sample_path = samples_dir +
"/left/" + left_sample_names[int(resp)]
89 elif string.upper(resp) ==
"R": 90 print("Choose sample index")
92 cur_sample_path = samples_dir +
"/right/" + right_sample_names[int(resp)]
93 elif string.upper(resp) ==
"F":
94 cur_sample_path = samples_dir +
"/far/" + far_sample_names[0]
95 elif string.upper(resp) ==
"":
96 print(
"Repeating Previous Command")
98 print(
"Unknown input. Exiting")
101 print(
"On sample [%s]" % cur_sample_path)
102 cur_config = yaml.load(open(cur_sample_path))
104 print(
"Choose Timeout")
105 timeout = input(
"> ")
109 m_robot = executive.capture(cur_config, rospy.Duration(float(timeout)))
111 print(
"--------------- Failed To Capture a Far Sample -----------------")
113 print(
"++++++++++++++ Successfully Captured a Far Sample ++++++++++++++")