go_initial.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Software License Agreement (BSD License)
00004 #
00005 # Copyright (c) 2015, Tokyo Opensource Robotics Kyokai Association (TORK)
00006 # All rights reserved.
00007 #
00008 # Redistribution and use in source and binary forms, with or without
00009 # modification, are permitted provided that the following conditions
00010 # are met:
00011 #
00012 #  * Redistributions of source code must retain the above copyright
00013 #    notice, this list of conditions and the following disclaimer.
00014 #  * Redistributions in binary form must reproduce the above
00015 #    copyright notice, this list of conditions and the following
00016 #    disclaimer in the documentation and/or other materials provided
00017 #    with the distribution.
00018 #  * Neither the name of Tokyo Opensource Robotics Kyokai Association. nor the
00019 #    names of its contributors may be used to endorse or promote products
00020 #    derived from this software without specific prior written permission.
00021 #
00022 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 # POSSIBILITY OF SUCH DAMAGE.
00034 
00035 import rospy
00036 import actionlib
00037 from control_msgs.msg import FollowJointTrajectoryAction, FollowJointTrajectoryGoal
00038 from trajectory_msgs.msg import JointTrajectoryPoint
00039 
00040 rospy.init_node('send_motion')
00041 r_client = actionlib.SimpleActionClient('/rarm_controller/follow_joint_trajectory_action', FollowJointTrajectoryAction)
00042 l_client = actionlib.SimpleActionClient('/larm_controller/follow_joint_trajectory_action', FollowJointTrajectoryAction)
00043 h_client = actionlib.SimpleActionClient('/head_controller/follow_joint_trajectory_action', FollowJointTrajectoryAction)
00044 c_client = actionlib.SimpleActionClient('/torso_controller/follow_joint_trajectory_action', FollowJointTrajectoryAction)
00045 r_client.wait_for_server()
00046 l_client.wait_for_server()
00047 h_client.wait_for_server()
00048 c_client.wait_for_server()
00049 
00050 # gen msg
00051 r_msg = FollowJointTrajectoryGoal()
00052 r_msg.trajectory.header.stamp = rospy.Time.now() + rospy.Duration(0.2)
00053 r_msg.trajectory.joint_names = ['RARM_JOINT0', 'RARM_JOINT1', 'RARM_JOINT2', 'RARM_JOINT3', 'RARM_JOINT4', 'RARM_JOINT5']
00054 r_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-2.1,0,0,0], time_from_start = rospy.Duration(0.1)))
00055 r_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-2.1,0,0,0], time_from_start = rospy.Duration(2)))
00056 r_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-1.6,0,0,0], time_from_start = rospy.Duration(3)))
00057 
00058 l_msg = FollowJointTrajectoryGoal()
00059 l_msg.trajectory.header.stamp = rospy.Time.now() + rospy.Duration(0.2)
00060 l_msg.trajectory.joint_names = ['LARM_JOINT0', 'LARM_JOINT1', 'LARM_JOINT2', 'LARM_JOINT3', 'LARM_JOINT4', 'LARM_JOINT5']
00061 l_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-2.1,0,0,0], time_from_start = rospy.Duration(0.1)))
00062 l_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-2.1,0,0,0], time_from_start = rospy.Duration(2)))
00063 l_msg.trajectory.points.append(JointTrajectoryPoint(positions=[0,0,-1.6,0,0,0], time_from_start = rospy.Duration(3)))
00064 
00065 # send to robot arm
00066 r_client.send_goal(r_msg)
00067 l_client.send_goal(l_msg)
00068 
00069 r_client.wait_for_result()
00070 l_client.wait_for_result()
00071 
00072 # head
00073 h_msg = FollowJointTrajectoryGoal()
00074 h_msg.trajectory.header.stamp = rospy.Time.now() + rospy.Duration(0.2)
00075 h_msg.trajectory.joint_names = ['HEAD_JOINT0', 'HEAD_JOINT1']
00076 h_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 1.0, 0.0], time_from_start = rospy.Duration(1)))
00077 h_msg.trajectory.points.append(JointTrajectoryPoint(positions=[-1.0,-0.2], time_from_start = rospy.Duration(2)))
00078 h_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 0.0, 0.2], time_from_start = rospy.Duration(3)))
00079 h_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 0.0, 0.0], time_from_start = rospy.Duration(4)))
00080 
00081 h_client.send_goal(h_msg)
00082 h_client.wait_for_result()
00083 
00084 # chest
00085 c_msg = FollowJointTrajectoryGoal()
00086 c_msg.trajectory.header.stamp = rospy.Time.now() + rospy.Duration(0.2)
00087 c_msg.trajectory.joint_names = ['CHEST_JOINT0']
00088 c_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 1.0], time_from_start = rospy.Duration(1)))
00089 c_msg.trajectory.points.append(JointTrajectoryPoint(positions=[-1.0], time_from_start = rospy.Duration(2)))
00090 c_msg.trajectory.points.append(JointTrajectoryPoint(positions=[ 0.0], time_from_start = rospy.Duration(3)))
00091 
00092 c_client.send_goal(c_msg)
00093 c_client.wait_for_result()
00094 
00095 rospy.loginfo("done")
00096 
00097 


nextage_gazebo
Author(s): Kei Okada , Isaac I. Y. Saito
autogenerated on Wed May 15 2019 04:46:54