2 import roslib; roslib.load_manifest(
'pr2_motor_diagnostic_tool')
5 from pr2_mechanism_msgs.srv
import LoadController, UnloadController, SwitchController, SwitchControllerRequest, ListControllers
6 from std_msgs.msg
import Float64
7 from sensor_msgs.msg
import Joy
13 load_controller = rospy.ServiceProxy(
'pr2_controller_manager/load_controller', LoadController)
14 unload_controller = rospy.ServiceProxy(
'pr2_controller_manager/unload_controller',UnloadController)
15 switch_controller = rospy.ServiceProxy(
'pr2_controller_manager/switch_controller',SwitchController)
16 list_controllers = rospy.ServiceProxy(
'pr2_controller_manager/list_controllers',ListControllers)
22 r_arm_actuators = [
'r_wrist_r_motor',
'r_wrist_l_motor',
'r_forearm_roll_motor',
'r_upper_arm_roll_motor',
'r_elbow_flex_motor',
'r_shoulder_lift_motor',
'r_shoulder_pan_motor']
23 l_arm_actuators = [
'l_wrist_r_motor',
'l_wrist_l_motor',
'l_forearm_roll_motor',
'l_upper_arm_roll_motor',
'l_elbow_flex_motor',
'l_shoulder_lift_motor',
'l_shoulder_pan_motor']
24 head_actuators = [
'head_pan_motor',
'head_tilt_motor']
39 rospy.set_param(
'diagnostic_controller/type',
'pr2_motor_diagnostic_controller/DiagnosticControllerPlugin')
40 rospy.set_param(
'diag_actuator_name',str(actuator_name))
44 rospy.loginfo(
"loaded controller dianostic_controller")
46 rospy.loginfo(
"Running diagnostic controller")
48 raise RuntimeError(
"Couldn't load contorller")
52 get_data = rospy.ServiceProxy(
'diagnostic_controller/get_diagnostic_data',DiagnosticData)
53 rospy.loginfo(
"getting data for %s, wait 2 seconds",actuator_name)
55 foo = DiagnosticDataRequest();
57 stream = file(str(actuator_name) +
"_results" +
'.yaml',
'w')
61 rospy.loginfo(
"stopped diagnostic_controller")
64 rospy.loginfo(
"unload diagnostic_controller")
71 if (data.buttons[14] == 1):
74 if (data.buttons[13] == 1):
78 rospy.init_node(
'get_data', anonymous=
True)
79 rospy.Subscriber(
"joy", Joy, callback)
80 parser = argparse.ArgumentParser(
"script to get data for Pr2 arms for diagnostic analysis")
81 parser.add_argument(
"parts", help=
"Specifiy left, right or both for the arms you want to get diagnostic data for and head for the head.")
82 args = parser.parse_args()
84 if (args.parts ==
'left'):
85 actuator_list = l_arm_actuators
86 elif (args.parts ==
'right'):
87 actuator_list = r_arm_actuators
88 elif (args.parts ==
'both'):
89 actuator_list = r_arm_actuators + l_arm_actuators
90 elif (args.parts ==
'head'):
93 print "Bad arguments, exiting" 99 for actuator_name
in actuator_list:
100 print "Press X to start or for next joint" 103 print "start moving %s for about 5 seconds" %(actuator_name)
105 print "press circle when your done" 110 if __name__ ==
'__main__':
114 except rospy.ROSInterruptException:
pass def start_diag_controller(actuator_name)
def get_diag_data(actuator_name)