pr2_gripper.py
Go to the documentation of this file.
00001 #/usr/bin/python
00002 
00003 import roslib; roslib.load_manifest('assistive_teleop')
00004 import rospy
00005 
00006 import actionlib
00007 from pr2_controllers_msgs.msg import (Pr2GripperCommandGoal, Pr2GripperCommand,
00008                                       Pr2GripperCommandAction)
00009 
00010 class PR2Gripper():
00011     def __init__(self, arm):
00012         self.arm = arm
00013 
00014         self.def_gripper_ac = actionlib.SimpleActionClient(
00015                          self.arm[0]+"_gripper_controller/gripper_action",
00016                          Pr2GripperCommandAction)
00017         if self.def_gripper_ac.wait_for_server(rospy.Duration(30)):
00018             rospy.loginfo("Found default "+self.arm+"_gripper action")
00019         else:
00020             rospy.logwarn("Cannot find default"+self.arm+"_gripper action")
00021             rospy.logwarn(self.arm+" GRIPPER ACTION NOT FOUND")
00022 
00023     
00024     def grab(self, position=0.0, max_effort=-1.0,  block=False, timeout=20):
00025         """Place-holder for more interesting grab"""           
00026         return self.gripper_action(position, max_effort, block, timeout)
00027 
00028     def release(self, position=0.0, max_effort=-1.0, block=False, timeout=20):
00029         """Place-holder for more interesting release"""           
00030         return self.gripper_action(position, max_effort, block, timeout)
00031 
00032     def gripper_action(self, position, max_effort=-1, 
00033                              block=False, timeout=20.0):
00034        """Send goal to gripper action server"""
00035        self.def_gripper_ac.send_goal(Pr2GripperCommand(position, max_effort))
00036        if block:
00037            return self.def_gripper_ac.wait_for_result(rospy.Duration(timeout))
00038         


assistive_teleop
Author(s): Phillip M. Grice, Advisor: Prof. Charlie Kemp, Lab: The Healthcare Robotoics Lab at Georgia Tech.
autogenerated on Wed Nov 27 2013 11:35:34