load_tool.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 
00003 import sys
00004 import numpy as np
00005 
00006 import roslib
00007 roslib.load_manifest('hrl_pr2_arms')
00008 roslib.load_manifest('smach_ros')
00009 roslib.load_manifest('actionlib')
00010 import rospy
00011 
00012 import smach
00013 from smach_ros import SimpleActionState, ServiceState, IntrospectionServer
00014 import actionlib
00015 import tf
00016 import tf.transformations as tf_trans
00017 from std_msgs.msg import Bool, Float32
00018 from std_srvs.srv import Empty
00019 from geometry_msgs.msg import PoseStamped, Vector3
00020 from actionlib_msgs.msg import GoalStatus
00021 from pr2_controllers_msgs.msg import Pr2GripperCommandAction, Pr2GripperCommandGoal
00022 
00023 from hrl_generic_arms.pose_converter import PoseConverter
00024 from hrl_pr2_arms.pr2_arm import create_pr2_arm
00025 from hrl_pr2_arms.pr2_arm_hybrid import PR2ArmHybridForce
00026 
00027 def main():
00028     rospy.init_node("load_tool")
00029 
00030     from optparse import OptionParser
00031     p = OptionParser()
00032     p.add_option('-w', '--wait', dest="wait", default=6,
00033                  help="Set wait time.")
00034     p.add_option('-r', '--relax', dest="relax", default=False,
00035                  action="store_true", help="Set the gripper torque to 0.")
00036     p.add_option('-t', '--tighten', dest="tighten", default=False,
00037                  action="store_true", help="Set the gripper torque to 30.")
00038     (opts, args) = p.parse_args()
00039 
00040     g_client = actionlib.SimpleActionClient('l_gripper_controller/gripper_action', Pr2GripperCommandAction)
00041     g_client.wait_for_server()
00042 
00043     g_goal = Pr2GripperCommandGoal()
00044 
00045     if opts.relax:
00046         g_goal.command.position = 0
00047         g_goal.command.max_effort = 0
00048         g_client.send_goal(g_goal)
00049         #g_client.wait_for_result()
00050         return
00051 
00052     if opts.tighten:
00053         g_goal.command.position = 0
00054         g_goal.command.max_effort = 30
00055         g_client.send_goal(g_goal)
00056         g_client.wait_for_result()
00057         return
00058         
00059 
00060     g_goal.command.position = 1
00061     g_goal.command.max_effort = -1
00062     g_client.send_goal(g_goal)
00063     g_client.wait_for_result()
00064 
00065     rospy.sleep(float(opts.wait))
00066 
00067     g_goal.command.position = 0
00068     g_goal.command.max_effort = 30
00069     g_client.send_goal(g_goal)
00070     g_client.wait_for_result()
00071 
00072 if __name__ == "__main__":
00073     main()


hrl_phri_2011
Author(s): Kelsey Hawkins
autogenerated on Wed Nov 27 2013 12:22:40