18 from moveit_msgs.msg
import Grasp
19 from trajectory_msgs.msg
import JointTrajectoryPoint
22 'FFJ1',
'FFJ2',
'FFJ3',
'FFJ4',
23 'LFJ1',
'LFJ2',
'LFJ3',
'LFJ4',
'LFJ5',
24 'MFJ1',
'MFJ2',
'MFJ3',
'MFJ4',
25 'RFJ1',
'RFJ2',
'RFJ3',
'RFJ4',
26 'THJ1',
'THJ2',
'THJ3',
'THJ4',
'THJ5',
29 _sr_joint_names_j0 = [
30 'LFJ0',
'LFJ3',
'LFJ4',
'LFJ5',
31 'RFJ0',
'RFJ3',
'RFJ4',
32 'MFJ0',
'MFJ3',
'MFJ4',
33 'FFJ0',
'FFJ3',
'FFJ4',
34 'THJ1',
'THJ2',
'THJ3',
'THJ4',
'THJ5',
40 Convert joints targets using J1 and J2 to J0, which the controllers use. 41 Useful if using joint_states to get grasp joint positions. 43 for finger
in [
'FFJ',
'LFJ',
'MFJ',
'RFJ']:
44 if finger+
'1' in joints
and finger+
'2' in joints:
45 joints[finger+
'0'] = joints[finger+
'1'] + joints[finger+
'2']
46 del joints[finger+
'1']
47 del joints[finger+
'2']
50 def mk_grasp(joints, pre_joints=None, fix_j0=False):
52 Generate a moveit_msgs/Grasp from a set of joint angles given as a dict 53 of joint_name -> position. 55 if pre_joints
is None:
58 sr_joint_names = _sr_joint_names
62 sr_joint_names = _sr_joint_names_j0
63 now = rospy.Time.now()
65 grasp.grasp_quality = 0.001
66 grasp.grasp_pose.header.frame_id =
"forearm" 67 grasp.grasp_pose.header.stamp = now
68 grasp.grasp_pose.pose.position.x = 0.01
69 grasp.grasp_pose.pose.position.y = -0.045
70 grasp.grasp_pose.pose.position.z = 0.321
71 grasp.grasp_pose.pose.orientation.x = 0
72 grasp.grasp_pose.pose.orientation.y = 0
73 grasp.grasp_pose.pose.orientation.z = 0
74 grasp.grasp_pose.pose.orientation.w = 0
76 grasp.pre_grasp_posture.header.stamp = now
77 grasp.pre_grasp_posture.joint_names = sr_joint_names
78 jtp = JointTrajectoryPoint()
79 for jname
in sr_joint_names:
80 if jname
in pre_joints:
81 jtp.positions.append(pre_joints[jname])
83 jtp.positions.append(0.0)
84 grasp.pre_grasp_posture.points.append(jtp)
86 grasp.grasp_posture.header.stamp = now
87 grasp.grasp_posture.joint_names = sr_joint_names
88 jtp = JointTrajectoryPoint()
89 for jname
in sr_joint_names:
91 jtp.positions.append(joints[jname])
93 jtp.positions.append(0.0)
94 grasp.grasp_posture.points.append(jtp)
def mk_grasp(joints, pre_joints=None, fix_j0=False)