sr_right_arm_follow_waypoints.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright 2019 Shadow Robot Company Ltd.
3 #
4 # This program is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the Free
6 # Software Foundation version 2 of the License.
7 #
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 # more details.
12 #
13 # You should have received a copy of the GNU General Public License along
14 # with this program. If not, see <http://www.gnu.org/licenses/>.
15 
16 # This example demonstrates some of the functions of the arm commander.
17 # The arm is moved through a sequence of goals generated via different functions in the commander.
18 
19 import rospy
20 from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
21 from sr_robot_commander.sr_arm_commander import SrArmCommander
22 import geometry_msgs.msg
23 
24 
25 rospy.init_node("move_arm_following_waypoint_trajectory", anonymous=True)
26 
27 arm_commander = SrArmCommander(set_ground=True)
28 
29 rospy.sleep(rospy.Duration(1))
30 
31 # Moving arm to initial pose
32 pose_1 = [0.32, 0.27, 1.026, 0.0, 0.0, 0.0, 1.0]
33 
34 print "Moving to initial pose"
35 arm_commander.plan_to_pose_target(pose_1)
36 arm_commander.execute()
37 
38 rospy.sleep(rospy.Duration(2))
39 
40 print "Following trajectory defined by waypoints"
41 waypoints = []
42 
43 # start with the initial position
44 initial_pose = arm_commander.get_current_pose()
45 
46 
47 wpose = geometry_msgs.msg.Pose()
48 wpose.position.x = initial_pose.position.x
49 wpose.position.y = initial_pose.position.y - 0.20
50 wpose.position.z = initial_pose.position.z
51 wpose.orientation = initial_pose.orientation
52 waypoints.append(wpose)
53 
54 wpose = geometry_msgs.msg.Pose()
55 wpose.position.x = initial_pose.position.x
56 wpose.position.y = initial_pose.position.y - 0.20
57 wpose.position.z = initial_pose.position.z - 0.20
58 wpose.orientation = initial_pose.orientation
59 waypoints.append(wpose)
60 
61 wpose = geometry_msgs.msg.Pose()
62 wpose.position.x = initial_pose.position.x
63 wpose.position.y = initial_pose.position.y
64 wpose.position.z = initial_pose.position.z - 0.20
65 wpose.orientation = initial_pose.orientation
66 waypoints.append(wpose)
67 
68 waypoints.append(initial_pose)
69 
70 arm_commander.plan_to_waypoints_target(waypoints, eef_step=0.02)
71 arm_commander.execute()


sr_example
Author(s): Ugo Cupcic
autogenerated on Wed Oct 14 2020 04:05:12