39 import moveit_commander
40 import moveit_msgs.msg
41 import geometry_msgs.msg
45 moveit_commander.roscpp_initialize(sys.argv)
49 robot = moveit_commander.RobotCommander()
51 scene = moveit_commander.PlanningSceneInterface()
53 group = moveit_commander.MoveGroupCommander(
"svenzva_arm")
55 display_trajectory_publisher = rospy.Publisher(
56 '/move_group/display_planned_path',
57 moveit_msgs.msg.DisplayTrajectory,
60 while not rospy.is_shutdown():
61 if joy_cmd != geometry_msgs.msg.Twist():
62 cur_pose = group.get_current_pose();
63 quaternion = cur_pose.pose.orientation
64 explicit_quat = [quaternion.x, quaternion.y, quaternion.z, quaternion.w]
65 euler = tf.transformations.euler_from_quaternion(explicit_quat)
66 new_euler = [euler[0] + joy_cmd.angular.x, euler[1] + joy_cmd.angular.y, euler[2] + joy_cmd.angular.z]
68 quat = tf.transformations.quaternion_from_euler(new_euler[0], new_euler[1], new_euler[2])
69 pose_target = geometry_msgs.msg.Pose()
70 pose_target.orientation.x = quat[0]
71 pose_target.orientation.y = quat[1]
72 pose_target.orientation.z = quat[2]
73 pose_target.orientation.w = quat[3]
74 pose_target.position.x = cur_pose.pose.position.x + joy_cmd.linear.x
75 pose_target.position.y = cur_pose.pose.position.y + joy_cmd.linear.y
76 pose_target.position.z = cur_pose.pose.position.z + joy_cmd.linear.z
77 group.set_pose_target(pose_target)
90 ## You can plan a cartesian path directly by specifying a list of waypoints 91 ## for the end-effector to go through. 94 # start with the current pose 95 waypoints.append(group.get_current_pose().pose) 97 # first orient gripper and move forward (+x) 98 wpose = geometry_msgs.msg.Pose() 99 wpose.orientation.w = 1.0 100 wpose.position.x = waypoints[0].position.x + 0.1 101 wpose.position.y = waypoints[0].position.y 102 wpose.position.z = waypoints[0].position.z 103 waypoints.append(copy.deepcopy(wpose)) 106 wpose.position.z -= 0.10 107 waypoints.append(copy.deepcopy(wpose)) 109 # third move to the side 110 wpose.position.y += 0.05 111 waypoints.append(copy.deepcopy(wpose)) 113 ## We want the cartesian path to be interpolated at a resolution of 1 cm 114 ## which is why we will specify 0.01 as the eef_step in cartesian 115 ## translation. We will specify the jump threshold as 0.0, effectively 117 (plan3, fraction) = group.compute_cartesian_path( 118 waypoints, # waypoints to follow 120 0.0) # jump_threshold 122 # Uncomment the line below to execute this plan on a real robot. 123 # group.execute(plan3) 127 moveit_commander.roscpp_shutdown()
133 if __name__==
'__main__':
135 joy_cmd = geometry_msgs.msg.Twist()
136 rospy.init_node(
'collision_aware_cartesian_control', anonymous=
True)
139 rospy.Subscriber(
"/revel/eef_velocity", geometry_msgs.msg.Twist, joy_callback, queue_size=1)
141 except rospy.ROSInterruptException:
def move_group_python_interface_tutorial()