go_initial.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Software License Agreement (BSD License)
4 #
5 # Copyright (c) 2015, Tokyo Opensource Robotics Kyokai Association (TORK)
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
11 #
12 # * Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # * Redistributions in binary form must reproduce the above
15 # copyright notice, this list of conditions and the following
16 # disclaimer in the documentation and/or other materials provided
17 # with the distribution.
18 # * Neither the name of Tokyo Opensource Robotics Kyokai Association. nor the
19 # names of its contributors may be used to endorse or promote products
20 # derived from this software without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # POSSIBILITY OF SUCH DAMAGE.
34 
35 import rospy
36 import actionlib
37 from control_msgs.msg import FollowJointTrajectoryAction, FollowJointTrajectoryGoal
38 from trajectory_msgs.msg import JointTrajectoryPoint
39 
40 rospy.init_node('send_motion')
41 r_client = actionlib.SimpleActionClient('/rarm_controller/follow_joint_trajectory_action', FollowJointTrajectoryAction)
42 l_client = actionlib.SimpleActionClient('/larm_controller/follow_joint_trajectory_action', FollowJointTrajectoryAction)
43 h_client = actionlib.SimpleActionClient('/head_controller/follow_joint_trajectory_action', FollowJointTrajectoryAction)
44 c_client = actionlib.SimpleActionClient('/torso_controller/follow_joint_trajectory_action', FollowJointTrajectoryAction)
45 r_client.wait_for_server()
46 l_client.wait_for_server()
47 h_client.wait_for_server()
48 c_client.wait_for_server()
49 
50 # gen msg
51 r_msg = FollowJointTrajectoryGoal()
52 r_msg.trajectory.header.stamp = rospy.Time.now() + rospy.Duration(0.2)
53 r_msg.trajectory.joint_names = ['RARM_JOINT0', 'RARM_JOINT1', 'RARM_JOINT2', 'RARM_JOINT3', 'RARM_JOINT4', 'RARM_JOINT5']
54 r_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-2.1,0,0,0], time_from_start = rospy.Duration(0.1)))
55 r_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-2.1,0,0,0], time_from_start = rospy.Duration(2)))
56 r_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-1.6,0,0,0], time_from_start = rospy.Duration(3)))
57 
58 l_msg = FollowJointTrajectoryGoal()
59 l_msg.trajectory.header.stamp = rospy.Time.now() + rospy.Duration(0.2)
60 l_msg.trajectory.joint_names = ['LARM_JOINT0', 'LARM_JOINT1', 'LARM_JOINT2', 'LARM_JOINT3', 'LARM_JOINT4', 'LARM_JOINT5']
61 l_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-2.1,0,0,0], time_from_start = rospy.Duration(0.1)))
62 l_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-2.1,0,0,0], time_from_start = rospy.Duration(2)))
63 l_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-1.6,0,0,0], time_from_start = rospy.Duration(3)))
64 
65 # send to robot arm
66 r_client.send_goal(r_msg)
67 l_client.send_goal(l_msg)
68 
69 r_client.wait_for_result()
70 l_client.wait_for_result()
71 
72 # head
73 h_msg = FollowJointTrajectoryGoal()
74 h_msg.trajectory.header.stamp = rospy.Time.now() + rospy.Duration(0.2)
75 h_msg.trajectory.joint_names = ['HEAD_JOINT0', 'HEAD_JOINT1']
76 h_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 1.0, 0.0], time_from_start = rospy.Duration(1)))
77 h_msg.trajectory.points.append(JointTrajectoryPoint(positions=[-1.0,-0.2], time_from_start = rospy.Duration(2)))
78 h_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 0.0, 0.2], time_from_start = rospy.Duration(3)))
79 h_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 0.0, 0.0], time_from_start = rospy.Duration(4)))
80 
81 h_client.send_goal(h_msg)
82 h_client.wait_for_result()
83 
84 # chest
85 c_msg = FollowJointTrajectoryGoal()
86 c_msg.trajectory.header.stamp = rospy.Time.now() + rospy.Duration(0.2)
87 c_msg.trajectory.joint_names = ['CHEST_JOINT0']
88 c_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 1.0], time_from_start = rospy.Duration(1)))
89 c_msg.trajectory.points.append(JointTrajectoryPoint(positions=[-1.0], time_from_start = rospy.Duration(2)))
90 c_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 0.0], time_from_start = rospy.Duration(3)))
91 
92 c_client.send_goal(c_msg)
93 c_client.wait_for_result()
94 
95 rospy.loginfo("done")
96 
97 


nextage_gazebo
Author(s): Kei Okada , Isaac I. Y. Saito
autogenerated on Wed Jun 17 2020 04:15:16