39 Command-line interface for receiving and interpreting the status of a 2F gripper. 41 This serves as an example for receiving messages from the 'Robotiq2FGripperRobotInput' topic using the 'Robotiq2FGripper_robot_input' msg type and interpreting the corresponding status of the 2F gripper. 44 import roslib; roslib.load_manifest(
'robotiq_2f_gripper_control')
46 from std_msgs.msg
import String
47 from robotiq_2f_gripper_control.msg
import _Robotiq2FGripper_robot_input
as inputMsg
50 """Print the status string generated by the statusInterpreter function.""" 55 """Initialize the node and subscribe to the Robotiq2FGripperRobotInput topic.""" 57 rospy.init_node(
'Robotiq2FGripperStatusListener')
58 rospy.Subscriber(
"Robotiq2FGripperRobotInput", inputMsg.Robotiq2FGripper_robot_input, printStatus)
62 """Generate a string according to the current value of the status variables.""" 64 output =
'\n-----\n2F gripper status interpreter\n-----\n' 67 output +=
'gACT = ' + str(status.gACT) +
': ' 69 output +=
'Gripper reset\n' 71 output +=
'Gripper activation\n' 74 output +=
'gGTO = ' + str(status.gGTO) +
': ' 76 output +=
'Standby (or performing activation/automatic release)\n' 78 output +=
'Go to Position Request\n' 81 output +=
'gSTA = ' + str(status.gSTA) +
': ' 83 output +=
'Gripper is in reset ( or automatic release ) state. see Fault Status if Gripper is activated\n' 85 output +=
'Activation in progress\n' 87 output +=
'Not used\n' 89 output +=
'Activation is completed\n' 92 output +=
'gOBJ = ' + str(status.gOBJ) +
': ' 94 output +=
'Fingers are in motion (only meaningful if gGTO = 1)\n' 96 output +=
'Fingers have stopped due to a contact while opening\n' 98 output +=
'Fingers have stopped due to a contact while closing \n' 100 output +=
'Fingers are at requested position\n' 103 output +=
'gFLT = ' + str(status.gFLT) +
': ' 104 if(status.gFLT == 0x00):
105 output +=
'No Fault\n' 106 if(status.gFLT == 0x05):
107 output +=
'Priority Fault: Action delayed, initialization must be completed prior to action\n' 108 if(status.gFLT == 0x07):
109 output +=
'Priority Fault: The activation bit must be set prior to action\n' 110 if(status.gFLT == 0x09):
111 output +=
'Minor Fault: The communication chip is not ready (may be booting)\n' 112 if(status.gFLT == 0x0B):
113 output +=
'Minor Fault: Automatic release in progress\n' 114 if(status.gFLT == 0x0E):
115 output +=
'Major Fault: Overcurrent protection triggered\n' 116 if(status.gFLT == 0x0F):
117 output +=
'Major Fault: Automatic release completed\n' 120 output +=
'gPR = ' + str(status.gPR) +
': ' 121 output +=
'Echo of the requested position for the Gripper: ' + str(status.gPR) +
'/255\n' 124 output +=
'gPO = ' + str(status.gPO) +
': ' 125 output +=
'Position of Fingers: ' + str(status.gPO) +
'/255\n' 128 output +=
'gCU = ' + str(status.gCU) +
': ' 129 output +=
'Current of Fingers: ' + str(status.gCU * 10) +
' mA\n' 133 if __name__ ==
'__main__':
def Robotiq2FGripperStatusListener()
def statusInterpreter(status)