35 Svenzva's Revel Gripper action interface 37 Opening and closing are performed at fixed torque rates. 38 The 'target_current' value in the action goal is only used in the event that 39 'target_action' is 'close'. In which case, after the fingers are touching the target object, 40 the 'target_current' torque value is applied. 43 Author: Maxwell Svetlik 45 from __future__
import division
46 from threading
import Thread
51 from std_msgs.msg
import Float64, Int32
52 from svenzva_msgs.msg
import MotorState, MotorStateList, GripperFeedback, GripperResult, GripperAction
56 _feedback = GripperFeedback()
57 _result = GripperResult()
59 def __init__(self, controller_namespace, mx_io):
68 rospy.Subscriber(
"revel/motor_states", MotorStateList, self.
motor_state_cb, queue_size=1)
80 if goal.target_action == goal.OPEN:
81 self._feedback.action =
'opening' 82 elif goal.target_action == goal.CLOSE:
83 self._feedback.action =
'closing' 85 rospy.logerr(
"Unable to perform gripper action due to malformed command. Expecting [open, close], got: %s", goal.target_action)
86 self._result.success =
False 87 self._as.set_aborted(self.
_result)
91 rospy.loginfo(
"Executing gripper action.")
93 if goal.target_action == goal.OPEN:
95 elif goal.target_action == goal.CLOSE:
99 self._feedback.action =
'grasping' 100 self._as.publish_feedback(self.
_feedback)
103 if self._as.is_preempt_requested():
104 self._as.set_preempted()
105 self._result.success =
False 107 self._result.success =
True 108 self._as.set_succeeded(self.
_result)
113 def start(self, open_and_close=False):
128 start = rospy.Time.now()
131 if rospy.Time.now() - start > rospy.Duration(0.25):
135 self.mx_io.set_torque_goal(self.
motor_id, 0)
140 self.mx_io.set_torque_goal(self.
motor_id, force)
143 if self._as.is_preempt_requested():
144 rospy.loginfo(
'Gripper action preempted.')
145 self._as.set_preempted()
150 self.mx_io.set_torque_goal(self.
motor_id, 0)
154 self.mx_io.set_torque_goal(self.
motor_id, force)
157 self.mx_io.set_torque_goal(self.
motor_id,0)
def __init__(self, controller_namespace, mx_io)
def motor_state_cb(self, data)
def open_gripper(self, force)
def gripper_cb(self, goal)
def start(self, open_and_close=False)
def close_gripper(self, force)