33 from trajectory_msgs.msg
import JointTrajectory, JointTrajectoryPoint
34 from sr_robot_commander.sr_robot_commander
import SrRobotCommander
36 rospy.init_node(
"right_hand_manipulator_plan_quality", anonymous=
True)
38 robot_commander = SrRobotCommander(name=
"right_arm_and_manipulator")
39 robot_commander.set_max_velocity_scaling_factor(0.4)
43 arm_manipulator_home_joints_goal = {
'ra_shoulder_pan_joint': 0.00,
'ra_elbow_joint': 2.00,
44 'ra_shoulder_lift_joint': -1.25,
'ra_wrist_1_joint': -0.733,
45 'ra_wrist_2_joint': 1.5708,
'ra_wrist_3_joint': 0.00,
46 'rh_WRJ1': 0.0,
'rh_WRJ2': 0.0}
48 example_goal_1 = [1.18773740212, 0.175152574887,
49 1.00722873872, -0.509149713327,
50 0.504302807033, -0.490693581737,
53 example_goal_2 = [1.03497881882, 0.174190990124,
54 1.00916719803, -0.510952874905,
55 0.510169511476, -0.4888330603,
58 example_goal_3 = [1.18972252888, 0.174200052352,
59 1.12320616864, -0.516434824527,
60 0.516354718344, -0.483015844727,
67 rospy.loginfo(
"Planning to move arm and manipulator to joint states\n" + str(arm_manipulator_home_joints_goal) +
"\n")
68 plan = robot_commander.plan_to_joint_value_target(arm_manipulator_home_joints_goal)
69 plan_quality = robot_commander.evaluate_given_plan(plan)
70 eval_plan_quality = robot_commander.evaluate_plan_quality(plan_quality)
72 if eval_plan_quality !=
'good':
73 rospy.logfatal(
"Plan quality to the home position is poor! " +
74 "For safety please refer to the hand and arm documentation " +
75 "for where to start the arm " +
76 "to ensure no unexpected movements during plan and execute.")
77 sys.exit(
"Exiting script to allow for the arm to be manually moved to better start position ...")
79 raw_input(
"Press Enter to execute plan...")
80 robot_commander.execute_plan(plan)
82 rospy.loginfo(
"Planning the move to the first pose:\n" + str(example_goal_1) +
"\n")
83 plan2 = robot_commander.plan_to_pose_target(example_goal_1)
84 plan_quality = robot_commander.evaluate_given_plan(plan2)
85 eval_plan_quality = robot_commander.evaluate_plan_quality(plan_quality)
87 raw_input(
"Press Enter to execute plan...")
88 robot_commander.execute_plan(plan2)
91 rospy.loginfo(
"Planning the move to the second pose:\n" + str(example_goal_1) +
"\n")
92 plan3 = robot_commander.plan_to_pose_target(example_goal_2)
93 plan_quality = robot_commander.evaluate_given_plan(plan3)
94 eval_plan_quality = robot_commander.evaluate_plan_quality(plan_quality)
96 raw_input(
"Press Enter to execute plan...")
97 robot_commander.execute_plan(plan3)
100 rospy.loginfo(
"Planning the move to the third pose:\n" + str(example_goal_1) +
"\n")
101 plan4 = robot_commander.plan_to_pose_target(example_goal_3)
102 plan_quality = robot_commander.evaluate_given_plan(plan4)
103 eval_plan_quality = robot_commander.evaluate_plan_quality(plan_quality)
105 raw_input(
"Press Enter to execute plan...")
106 robot_commander.execute_plan(plan4)