grasp_preprogrammed.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # Software License Agreement (BSD License)
00003 #
00004 # Copyright (c) 2008, Willow Garage, Inc.
00005 # All rights reserved.
00006 #
00007 # Redistribution and use in source and binary forms, with or without
00008 # modification, are permitted provided that the following conditions
00009 # are met:
00010 #
00011 #  * Redistributions of source code must retain the above copyright
00012 #    notice, this list of conditions and the following disclaimer.
00013 #  * Redistributions in binary form must reproduce the above
00014 #    copyright notice, this list of conditions and the following
00015 #    disclaimer in the documentation and/or other materials provided
00016 #    with the distribution.
00017 #  * Neither the name of the Willow Garage nor the names of its
00018 #    contributors may be used to endorse or promote products derived
00019 #    from this software without specific prior written permission.
00020 #
00021 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 # POSSIBILITY OF SUCH DAMAGE.
00033 #
00034 
00035 ## Gazebo tug arms for navigation
00036 
00037 PKG = 'pr2_gazebo'
00038 NAME = 'grasp_preprogrammed'
00039 
00040 import math
00041 import roslib
00042 roslib.load_manifest(PKG)
00043 
00044 import sys, unittest
00045 import os, os.path, threading, time
00046 import rospy, rostest
00047 
00048 from std_msgs.msg import Float64
00049 from nav_msgs.msg import Odometry
00050 
00051 
00052 CMD_POS_1      =  0.0
00053 CMD_POS_2      =  0.0
00054 CMD_POS_3      =  0.0
00055 CMD_POS_4      =  0.0
00056 CMD_POS_5      =  0.0
00057 CMD_POS_6      =  0.0
00058 CMD_POS_7      =  0.0
00059 LOWER_Z        =  0.1
00060 PAN_RAD        =  0.5
00061 G_OPEN         =  0.058;
00062 G_CLOSE        =  0.0199;
00063 
00064 p3d_received   = False
00065 
00066 def p3dReceived(stuff):
00067     global p3d_received
00068     if not p3d_received:
00069         p3d_received = True
00070 
00071 if __name__ == '__main__':
00072     pub_r_shoulder_pan   = rospy.Publisher("r_shoulder_pan_position_controller/command", Float64)
00073     pub_r_shoulder_lift  = rospy.Publisher("r_shoulder_lift_position_controller/command", Float64)
00074     pub_r_upper_arm_roll = rospy.Publisher("r_upper_arm_roll_position_controller/command", Float64)
00075     pub_r_elbow_flex     = rospy.Publisher("r_elbow_flex_position_controller/command", Float64)
00076     pub_r_forearm_roll   = rospy.Publisher("r_forearm_roll_position_controller/command", Float64)
00077     pub_r_wrist_flex     = rospy.Publisher("r_wrist_flex_position_controller/command", Float64)
00078     pub_r_wrist_roll     = rospy.Publisher("r_wrist_roll_position_controller/command", Float64)
00079     pub_r_gripper        = rospy.Publisher("r_gripper_position_controller/command", Float64)
00080     rospy.Subscriber("r_gripper_palm_pose_ground_truth", Odometry, p3dReceived)
00081     rospy.init_node(NAME, anonymous=True)
00082 
00083 
00084     #sleep for a while
00085     while not p3d_received:
00086       time.sleep(1)
00087 
00088     #open gripper
00089     pub_r_shoulder_pan   .publish(Float64(CMD_POS_1))
00090     pub_r_shoulder_lift  .publish(Float64(CMD_POS_2))
00091     pub_r_upper_arm_roll .publish(Float64(CMD_POS_3))
00092     pub_r_elbow_flex     .publish(Float64(CMD_POS_4))
00093     pub_r_forearm_roll   .publish(Float64(CMD_POS_5))
00094     pub_r_wrist_flex     .publish(Float64(CMD_POS_6))
00095     pub_r_wrist_roll     .publish(Float64(CMD_POS_7))
00096     pub_r_gripper        .publish(Float64(G_OPEN))
00097     time.sleep(8)
00098 
00099     #lower arm
00100     pub_r_shoulder_pan   .publish(Float64(CMD_POS_1))
00101     pub_r_shoulder_lift  .publish(Float64(CMD_POS_2+LOWER_Z))
00102     pub_r_upper_arm_roll .publish(Float64(CMD_POS_3))
00103     pub_r_elbow_flex     .publish(Float64(CMD_POS_4))
00104     pub_r_forearm_roll   .publish(Float64(CMD_POS_5))
00105     pub_r_wrist_flex     .publish(Float64(CMD_POS_6))
00106     pub_r_wrist_roll     .publish(Float64(CMD_POS_7))
00107     pub_r_gripper.publish(Float64(G_OPEN))
00108     time.sleep(2)
00109 
00110     #close gripper
00111     pub_r_shoulder_pan   .publish(Float64(CMD_POS_1))
00112     pub_r_shoulder_lift  .publish(Float64(CMD_POS_2+LOWER_Z))
00113     pub_r_upper_arm_roll .publish(Float64(CMD_POS_3))
00114     pub_r_elbow_flex     .publish(Float64(CMD_POS_4))
00115     pub_r_forearm_roll   .publish(Float64(CMD_POS_5))
00116     pub_r_wrist_flex     .publish(Float64(CMD_POS_6))
00117     pub_r_wrist_roll     .publish(Float64(CMD_POS_7))
00118     pub_r_gripper.publish(Float64(G_CLOSE))
00119     time.sleep(8)
00120 
00121     #raise arm
00122     pub_r_shoulder_pan   .publish(Float64(CMD_POS_1))
00123     pub_r_shoulder_lift  .publish(Float64(CMD_POS_2))
00124     pub_r_upper_arm_roll .publish(Float64(CMD_POS_3))
00125     pub_r_elbow_flex     .publish(Float64(CMD_POS_4))
00126     pub_r_forearm_roll   .publish(Float64(CMD_POS_5))
00127     pub_r_wrist_flex     .publish(Float64(CMD_POS_6))
00128     pub_r_wrist_roll     .publish(Float64(CMD_POS_7))
00129     pub_r_gripper.publish(Float64(G_CLOSE))
00130     time.sleep(20)
00131 
00132     #pan arm
00133     pub_r_shoulder_pan   .publish(Float64(CMD_POS_1+PAN_RAD))
00134     pub_r_shoulder_lift  .publish(Float64(CMD_POS_2))
00135     pub_r_upper_arm_roll .publish(Float64(CMD_POS_3))
00136     pub_r_elbow_flex     .publish(Float64(CMD_POS_4))
00137     pub_r_forearm_roll   .publish(Float64(CMD_POS_5))
00138     pub_r_wrist_flex     .publish(Float64(CMD_POS_6))
00139     pub_r_wrist_roll     .publish(Float64(CMD_POS_7))
00140     pub_r_gripper.publish(Float64(G_CLOSE))
00141     time.sleep(10)
00142 
00143     #lower arm
00144     pub_r_shoulder_pan   .publish(Float64(CMD_POS_1+PAN_RAD))
00145     pub_r_shoulder_lift  .publish(Float64(CMD_POS_2+LOWER_Z))
00146     pub_r_upper_arm_roll .publish(Float64(CMD_POS_3))
00147     pub_r_elbow_flex     .publish(Float64(CMD_POS_4))
00148     pub_r_forearm_roll   .publish(Float64(CMD_POS_5))
00149     pub_r_wrist_flex     .publish(Float64(CMD_POS_6))
00150     pub_r_wrist_roll     .publish(Float64(CMD_POS_7))
00151     pub_r_gripper.publish(Float64(G_CLOSE))
00152     time.sleep(8)
00153 
00154     #open gripper
00155     pub_r_shoulder_pan   .publish(Float64(CMD_POS_1+PAN_RAD))
00156     pub_r_shoulder_lift  .publish(Float64(CMD_POS_2+LOWER_Z))
00157     pub_r_upper_arm_roll .publish(Float64(CMD_POS_3))
00158     pub_r_elbow_flex     .publish(Float64(CMD_POS_4))
00159     pub_r_forearm_roll   .publish(Float64(CMD_POS_5))
00160     pub_r_wrist_flex     .publish(Float64(CMD_POS_6))
00161     pub_r_wrist_roll     .publish(Float64(CMD_POS_7))
00162     pub_r_gripper.publish(Float64(G_OPEN))
00163     time.sleep(8)
00164 
00165     #raise arm
00166     pub_r_shoulder_pan   .publish(Float64(CMD_POS_1+PAN_RAD))
00167     pub_r_shoulder_lift  .publish(Float64(CMD_POS_2))
00168     pub_r_upper_arm_roll .publish(Float64(CMD_POS_3))
00169     pub_r_elbow_flex     .publish(Float64(CMD_POS_4))
00170     pub_r_forearm_roll   .publish(Float64(CMD_POS_5))
00171     pub_r_wrist_flex     .publish(Float64(CMD_POS_6))
00172     pub_r_wrist_roll     .publish(Float64(CMD_POS_7))
00173     pub_r_gripper.publish(Float64(G_OPEN))
00174     time.sleep(10)
00175 
00176     #return arm
00177     pub_r_shoulder_pan   .publish(Float64(CMD_POS_1))
00178     pub_r_shoulder_lift  .publish(Float64(CMD_POS_2))
00179     pub_r_upper_arm_roll .publish(Float64(CMD_POS_3))
00180     pub_r_elbow_flex     .publish(Float64(CMD_POS_4))
00181     pub_r_forearm_roll   .publish(Float64(CMD_POS_5))
00182     pub_r_wrist_flex     .publish(Float64(CMD_POS_6))
00183     pub_r_wrist_roll     .publish(Float64(CMD_POS_7))
00184     pub_r_gripper.publish(Float64(G_CLOSE))
00185 


pr2_gazebo_wg
Author(s): John Hsu
autogenerated on Mon Jan 6 2014 12:05:36