Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 """@package docstring
00039 Command-line interface for receiving and interpreting the status of a C-Model gripper.
00040
00041 This serves as an example for receiving messages from the 'CModelRobotInput' topic using the 'CModel_robot_input' msg type and interpreting the corresponding status of the C-Model gripper.
00042 """
00043
00044 import roslib; roslib.load_manifest('robotiq_c_model_control')
00045 import rospy
00046 from std_msgs.msg import String
00047 from robotiq_c_model_control.msg import _CModel_robot_input as inputMsg
00048
00049 def printStatus(status):
00050 """Print the status string generated by the statusInterpreter function."""
00051
00052 print statusInterpreter(status)
00053
00054 def CModelStatusListener():
00055 """Initialize the node and subscribe to the CModelRobotInput topic."""
00056
00057 rospy.init_node('CModelStatusListener')
00058 rospy.Subscriber("CModelRobotInput", inputMsg.CModel_robot_input, printStatus)
00059 rospy.spin()
00060
00061 def statusInterpreter(status):
00062 """Generate a string according to the current value of the status variables."""
00063
00064 output = '\n-----\nC-Model status interpreter\n-----\n'
00065
00066
00067 output += 'gACT = ' + str(status.gACT) + ': '
00068 if(status.gACT == 0):
00069 output += 'Gripper reset\n'
00070 if(status.gACT == 1):
00071 output += 'Gripper activation\n'
00072
00073
00074 output += 'gGTO = ' + str(status.gGTO) + ': '
00075 if(status.gGTO == 0):
00076 output += 'Standby (or performing activation/automatic release)\n'
00077 if(status.gGTO == 1):
00078 output += 'Go to Position Request\n'
00079
00080
00081 output += 'gSTA = ' + str(status.gSTA) + ': '
00082 if(status.gSTA == 0):
00083 output += 'Gripper is in reset ( or automatic release ) state. see Fault Status if Gripper is activated\n'
00084 if(status.gSTA == 1):
00085 output += 'Activation in progress\n'
00086 if(status.gSTA == 2):
00087 output += 'Not used\n'
00088 if(status.gSTA == 3):
00089 output += 'Activation is completed\n'
00090
00091
00092 output += 'gOBJ = ' + str(status.gOBJ) + ': '
00093 if(status.gOBJ == 0):
00094 output += 'Fingers are in motion (only meaningful if gGTO = 1)\n'
00095 if(status.gOBJ == 1):
00096 output += 'Fingers have stopped due to a contact while opening\n'
00097 if(status.gOBJ == 2):
00098 output += 'Fingers have stopped due to a contact while closing \n'
00099 if(status.gOBJ == 3):
00100 output += 'Fingers are at requested position\n'
00101
00102
00103 output += 'gFLT = ' + str(status.gFLT) + ': '
00104 if(status.gFLT == 0x00):
00105 output += 'No Fault\n'
00106 if(status.gFLT == 0x05):
00107 output += 'Priority Fault: Action delayed, initialization must be completed prior to action\n'
00108 if(status.gFLT == 0x07):
00109 output += 'Priority Fault: The activation bit must be set prior to action\n'
00110 if(status.gFLT == 0x09):
00111 output += 'Minor Fault: The communication chip is not ready (may be booting)\n'
00112 if(status.gFLT == 0x0B):
00113 output += 'Minor Fault: Automatic release in progress\n'
00114 if(status.gFLT == 0x0E):
00115 output += 'Major Fault: Overcurrent protection triggered\n'
00116 if(status.gFLT == 0x0F):
00117 output += 'Major Fault: Automatic release completed\n'
00118
00119
00120 output += 'gPR = ' + str(status.gPR) + ': '
00121 output += 'Echo of the requested position for the Gripper: ' + str(status.gPR) + '/255\n'
00122
00123
00124 output += 'gPO = ' + str(status.gPO) + ': '
00125 output += 'Position of Fingers: ' + str(status.gPO) + '/255\n'
00126
00127
00128 output += 'gCU = ' + str(status.gCU) + ': '
00129 output += 'Current of Fingers: ' + str(status.gCU * 10) + ' mA\n'
00130
00131 return output
00132
00133 if __name__ == '__main__':
00134 CModelStatusListener()