39 import geometry_msgs.msg
43 from moveit_commander
import MoveGroupCommander
45 import nextage_rtm_playpattern
as nxtpp
50 Create a array of limb joint angles for the each waypoints 51 from data of the end effector postions and postures 55 @param limb : limb to create a pattern, right arm 'rarm' or left arm 'larm' 56 @type pos_list : [[float,float,float],[float,float,float],...] 57 @param pos_list : Array of end effector positions (x,y,z) [m] 58 @type rpy_list : [[float,float,float],[float,float,float],...] 59 @param rpy_list : Array of end effector postures (r,p,y) [m] 60 @type tm_list : [float,float,...] 61 @param tm_list : Array of motion time lengths of the each pose [s] 63 @rtype : RobotTrajectory, float 64 @return : Plan of limb waypoints motion and fraction of the path achieved as described by the waypoints 66 wpose = geometry_msgs.msg.Pose()
69 for pos, rpy, tm
in zip(pos_list, rpy_list, tm_list):
70 quaternion = tf.transformations.quaternion_from_euler(rpy[0], rpy[1], rpy[2])
71 wpose.position.x = pos[0]
72 wpose.position.y = pos[1]
73 wpose.position.z = pos[2]
74 wpose.orientation.x = quaternion[0]
75 wpose.orientation.y = quaternion[1]
76 wpose.orientation.z = quaternion[2]
77 wpose.orientation.w = quaternion[3]
78 waypoints.append(copy.deepcopy(wpose))
80 (pln, frc) = limb.compute_cartesian_path(
88 if __name__ ==
'__main__':
90 Main sequence for moving at waypoints 93 rospy.init_node(
'commander_example', anonymous=
True)
95 limb_name =
"left_arm" 96 group = MoveGroupCommander(limb_name)
98 rarm_initial_pose = group.get_current_pose().pose
99 rospy.loginfo(
"Got Initial Pose \n{}".format(rarm_initial_pose))
101 pose_target = geometry_msgs.msg.Pose()
102 pose_target = copy.deepcopy(rarm_initial_pose)
109 rect_xyzs = nxtpp.rectangularPositions(dp_a=[0.25, 0.0, 0.1], dp_b=[0.45, 0.2, 0.1])
110 rect_rpys = nxtpp.samePostureRPY([-3.073437, -1.569023, 3.073247], len(rect_xyzs))
111 rect_time = nxtpp.equalTimeList(10.0, len(rect_xyzs))
114 circ_xyzs = nxtpp.circularPositions(center=[0.35, 0.1, 0.1], radius=0.1 ,steps=12)
115 circ_rpys = nxtpp.samePostureRPY([-3.073437, -1.569023, 3.073247], len(circ_xyzs))
116 circ_time = nxtpp.equalTimeList(10.0, len(circ_xyzs))
123 positions_arm = rect_xyzs + circ_xyzs
124 rpys_arm = rect_rpys + circ_rpys
125 time_list = rect_time + circ_time
127 print(
'Limb: %s' % limb_name)
128 print(
'Positions (%d): %s' % (len(positions_arm), positions_arm))
129 print(
'RPY Pattern (%d): %s' % (len(rpys_arm), rpys_arm))
130 print(
'Time List (%d): %s' % (len(time_list), time_list))
133 rospy.loginfo(
"Planing Waypoints")
137 rospy.loginfo(
"Waiting while the plan is visualized on RViz")
141 rospy.loginfo(
"Execute!!")
143 rospy.loginfo(
"Executiion Done")
147 rospy.loginfo(
"Move to Initial Pose")
148 pose_target = copy.deepcopy(rarm_initial_pose)
149 rospy.loginfo(
"set target to {}".format(pose_target))
150 group.set_pose_target(pose_target)
def setTargetPoseSequenceMoveIt(limb, pos_list, rpy_list, tm_list)