4 parallel_gripper_controller.py - controls a gripper built of two servos 5 Copyright (c) 2011 Vanadium Labs LLC. All right reserved. 7 Redistribution and use in source and binary forms, with or without 8 modification, are permitted provided that the following conditions are met: 9 * Redistributions of source code must retain the above copyright 10 notice, this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright 12 notice, this list of conditions and the following disclaimer in the 13 documentation and/or other materials provided with the distribution. 14 * Neither the name of Vanadium Labs LLC nor the names of its 15 contributors may be used to endorse or promote products derived 16 from this software without specific prior written permission. 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND 19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 DISCLAIMED. IN NO EVENT SHALL VANADIUM LABS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 import rospy, actionlib
33 from control_msgs.msg
import GripperCommandAction
34 from std_msgs.msg
import Float64
38 """ A simple controller that operates two opposing servos to 39 open/close to a particular size opening. """ 41 rospy.init_node(
'gripper_controller')
42 rospy.logwarn(
"parallel_gripper_action_controller.py is deprecated and will be removed in ROS Indigo, please use gripper_controller")
47 self.
pad_width = rospy.get_param(
'~pad_width', 0.01)
52 self.
center_l = rospy.get_param(
'~center_left', 0.0)
53 self.
center_r = rospy.get_param(
'~center_right', 0.0)
54 self.
invert_l = rospy.get_param(
'~invert_left',
False)
55 self.
invert_r = rospy.get_param(
'~invert_right',
False)
58 self.
l_pub = rospy.Publisher(
'l_gripper_joint/command', Float64, queue_size=5)
59 self.
r_pub = rospy.Publisher(
'r_gripper_joint/command', Float64, queue_size=5)
67 """ Take an input command of width to open gripper. """ 68 rospy.loginfo(
'Gripper controller action goal recieved:%f' % goal.command.position)
69 command = goal.command.position
88 self.l_pub.publish(lmsg)
89 self.r_pub.publish(rmsg)
91 self.server.set_succeeded()
92 rospy.loginfo(
'Gripper Controller: Done.')
94 if __name__==
'__main__':
97 except rospy.ROSInterruptException:
98 rospy.loginfo(
'Hasta la Vista...')