35 from trajectory_msgs.msg
import JointTrajectory, JointTrajectoryPoint
36 from sr_robot_commander.sr_robot_commander
import SrRobotCommander
37 from sr_robot_commander.sr_arm_commander
import SrArmCommander
38 from sr_robot_commander.sr_hand_commander
import SrHandCommander
39 import geometry_msgs.msg
41 rospy.init_node(
"hand_arm_waypoints", anonymous=
True)
46 hand_commander = SrHandCommander(name=
"right_hand")
47 arm_commander = SrArmCommander(name=
"right_arm")
49 robot_commander = SrRobotCommander(name=
"right_arm_and_hand")
50 arm_commander.set_max_velocity_scaling_factor(0.1)
54 arm_home_joints_goal = {
'ra_shoulder_pan_joint': 0.00,
'ra_elbow_joint': 2.00,
55 'ra_shoulder_lift_joint': -1.25,
'ra_wrist_1_joint': -0.733,
56 'ra_wrist_2_joint': 1.5708,
'ra_wrist_3_joint': 0.00}
58 arm_hand_home_joints_goal = {
'ra_shoulder_pan_joint': 0.00,
'ra_elbow_joint': 2.00,
59 'ra_shoulder_lift_joint': -1.25,
'ra_wrist_1_joint': -0.733,
60 'ra_wrist_2_joint': 1.5708,
'ra_wrist_3_joint': 0.00,
61 'rh_THJ1': 0.52,
'rh_THJ2': 0.61,
'rh_THJ3': 0.0,
'rh_THJ4': 1.20,
62 'rh_THJ5': 0.17,
'rh_FFJ1': 1.5707,
'rh_FFJ2': 1.5707,
'rh_FFJ3': 1.5707,
63 'rh_FFJ4': 0.0,
'rh_MFJ1': 1.5707,
'rh_MFJ2': 1.5707,
'rh_MFJ3': 1.5707,
64 'rh_MFJ4': 0.0,
'rh_RFJ1': 1.5707,
'rh_RFJ2': 1.5707,
'rh_RFJ3': 1.5707,
65 'rh_RFJ4': 0.0,
'rh_LFJ1': 1.5707,
'rh_LFJ2': 1.5707,
'rh_LFJ3': 1.5707,
66 'rh_LFJ4': 0.0,
'rh_LFJ5': 0.0,
'rh_WRJ1': 0.0,
'rh_WRJ2': 0.0}
68 example_goal_1 = [0.9, 0.16, 0.95, -0.99, 8.27, -0.0, 1.4]
74 arm_to_home_plan = arm_commander.plan_to_joint_value_target(arm_home_joints_goal)
75 arm_to_home_plan_quality = arm_commander.evaluate_given_plan(arm_to_home_plan)
76 eval_arm_home_plan_quality = arm_commander.evaluate_plan_quality(arm_to_home_plan_quality)
78 if eval_arm_home_plan_quality !=
'good':
79 rospy.logfatal(
"Plan quality to the home position is poor! " +
80 "For safety please refer to the hand and arm documentation " +
81 "for where to start the arm " +
82 "to ensure no unexpected movements during plan and execute.")
83 sys.exit(
"Exiting script to allow for the arm to be manually moved to better start position ...")
86 rospy.loginfo(
"Planning and moving arm to home joint states\n" + str(arm_home_joints_goal) +
"\n")
87 arm_commander.execute_plan(arm_to_home_plan)
91 raw_input(
"Press Enter to continue...")
92 rospy.loginfo(
"Planning the move to the pose:\n" + str(example_goal_1) +
"\n")
93 arm_commander.plan_to_pose_target(example_goal_1)
94 rospy.loginfo(
"Finished planning, moving the arm now.")
95 arm_commander.execute()
98 raw_input(
"Press Enter to continue...")
99 rospy.loginfo(
"Following trajectory defined by waypoints")
103 initial_pose = arm_commander.get_current_pose()
109 wpose = geometry_msgs.msg.Pose()
110 wpose.position.x = initial_pose.position.x
111 wpose.position.y = initial_pose.position.y - 0.10
112 wpose.position.z = initial_pose.position.z
113 wpose.orientation = initial_pose.orientation
114 waypoints.append(wpose)
116 wpose = geometry_msgs.msg.Pose()
117 wpose.position.x = initial_pose.position.x - 0.10
118 wpose.position.y = initial_pose.position.y
119 wpose.position.z = initial_pose.position.z + 0.1
120 wpose.orientation = initial_pose.orientation
121 waypoints.append(wpose)
123 waypoints.append(initial_pose)
125 arm_commander.plan_to_waypoints_target(waypoints, eef_step=0.02)
126 arm_commander.execute()
131 raw_input(
"Press Enter to continue...")
132 rospy.loginfo(
"Moving arm to joint states\n" + str(arm_hand_home_joints_goal) +
"\n")
133 robot_commander.move_to_joint_value_target_unsafe(arm_hand_home_joints_goal, 6.0,
True)