SModelStatusListener.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Software License Agreement (BSD License)
00004 #
00005 # Copyright (c) 2012, Robotiq, Inc.
00006 # All rights reserved.
00007 #
00008 # Redistribution and use in source and binary forms, with or without
00009 # modification, are permitted provided that the following conditions
00010 # are met:
00011 #
00012 #  * Redistributions of source code must retain the above copyright
00013 #    notice, this list of conditions and the following disclaimer.
00014 #  * Redistributions in binary form must reproduce the above
00015 #    copyright notice, this list of conditions and the following
00016 #    disclaimer in the documentation and/or other materials provided
00017 #    with the distribution.
00018 #  * Neither the name of Robotiq, Inc. nor the names of its
00019 #    contributors may be used to endorse or promote products derived
00020 #    from this software without specific prior written permission.
00021 #
00022 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 # POSSIBILITY OF SUCH DAMAGE.
00034 #
00035 # Copyright (c) 2012, Robotiq, Inc.
00036 # Revision $Id$
00037 
00038 """@package docstring
00039 Command-line interface for receiving and interpreting the status of a S-Model gripper.
00040 
00041 This serves as an example for receiving messages from the 'SModelRobotInput' topic using the 'SModel_robot_input' msg type and interpreting the corresponding status of the S-Model gripper.
00042 """
00043 
00044 import roslib; roslib.load_manifest('robotiq_s_model_control')
00045 import rospy
00046 from std_msgs.msg import String
00047 from robotiq_s_model_control.msg import _SModel_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 SModelStatusListener():
00055     """Initialize the node and subscribe to the SModelRobotInput topic."""
00056 
00057     rospy.init_node('SModelStatusListener')
00058     rospy.Subscriber("SModelRobotInput", inputMsg.SModel_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-----\nS-Model status interpreter\n-----\n'
00065 
00066     #gACT
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     #gMOD
00074     output += 'gMOD = ' + str(status.gMOD) + ': '
00075     if(status.gMOD == 0):
00076         output += 'Basic Mode\n'
00077     if(status.gMOD == 1):
00078         output += 'Pinch Mode\n'
00079     if(status.gMOD == 2):
00080         output += 'Wide Mode\n'
00081     if(status.gMOD == 3):
00082         output += 'Scissor Mode\n'
00083 
00084     #gGTO
00085     output += 'gGTO = ' + str(status.gGTO) + ': '
00086     if(status.gGTO == 0):
00087         output += 'Stopped (or performing activation/grasping mode change/automatic release)\n'
00088     if(status.gGTO == 1):
00089         output += 'Go to Position Request\n'
00090 
00091     #gIMC
00092     output += 'gIMC = ' + str(status.gIMC) + ': '
00093     if(status.gIMC == 0):
00094         output += 'Gripper is in reset (or automatic release) state. see Fault Status if Gripper is activated\n'
00095     if(status.gIMC == 1):
00096         output += 'Activation in progress\n'
00097     if(status.gIMC == 2):
00098         output += 'Mode change in progress\n'
00099     if(status.gIMC == 3):
00100         output += 'Activation and mode change are completed\n'
00101 
00102     #gSTA
00103     output += 'gSTA = ' + str(status.gSTA) + ': '
00104     if(status.gSTA == 0):
00105         output += 'Gripper is in motion towards requested position (only meaningful if gGTO = 1)\n'
00106     if(status.gSTA == 1):
00107         output += 'Gripper is stopped. One or two fingers stopped before requested position\n'
00108     if(status.gSTA == 2):
00109         output += 'Gripper is stopped. All fingers stopped before requested position\n'
00110     if(status.gSTA == 3):
00111         output += 'Gripper is stopped. All fingers reached requested position\n'
00112 
00113     #gDTA
00114     output += 'gDTA = ' + str(status.gDTA) + ': '
00115     if(status.gDTA == 0):
00116         output += 'Finger A is in motion (only meaningful if gGTO = 1)\n'
00117     if(status.gDTA == 1):
00118         output += 'Finger A has stopped due to a contact while opening\n'
00119     if(status.gDTA == 2):
00120         output += 'Finger A has stopped due to a contact while closing\n'
00121     if(status.gDTA == 3):
00122         output += 'Finger A is at requested position\n'
00123        
00124     #gDTB
00125     output += 'gDTB = ' + str(status.gDTB) + ': '
00126     if(status.gDTB == 0):
00127         output += 'Finger B is in motion (only meaningful if gGTO = 1)\n'
00128     if(status.gDTB == 1):
00129         output += 'Finger B has stopped due to a contact while opening\n'
00130     if(status.gDTB == 2):
00131         output += 'Finger B has stopped due to a contact while closing\n'
00132     if(status.gDTB == 3):
00133         output += 'Finger B is at requested position\n'
00134 
00135     #gDTC
00136     output += 'gDTC = ' + str(status.gDTC) + ': '
00137     if(status.gDTC == 0):
00138         output += 'Finger C is in motion (only meaningful if gGTO = 1)\n'
00139     if(status.gDTC == 1):
00140         output += 'Finger C has stopped due to a contact while opening\n'
00141     if(status.gDTC == 2):
00142         output += 'Finger C has stopped due to a contact while closing\n'
00143     if(status.gDTC == 3):
00144         output += 'Finger C is at requested position\n'
00145 
00146     #gDTS
00147     output += 'gDTS = ' + str(status.gDTS) + ': '
00148     if(status.gDTS == 0):
00149         output += 'Scissor is in motion (only meaningful if gGTO = 1)\n'
00150     if(status.gDTS == 1):
00151         output += 'Scissor has stopped due to a contact while opening\n'
00152     if(status.gDTS == 2):
00153         output += 'Scissor has stopped due to a contact while closing\n'
00154     if(status.gDTS == 3):
00155         output += 'Scissor is at requested position\n'
00156 
00157     #gFLT
00158     output += 'gFLT = ' + str(status.gFLT) + ': '
00159     if(status.gFLT == 0x00):
00160         output += 'No Fault\n'
00161     if(status.gFLT == 0x05):
00162         output += 'Priority Fault: Action delayed, activation (reactivation) must be completed prior to action\n'
00163     if(status.gFLT == 0x06):
00164         output += 'Priority Fault: Action delayed, mode change must be completed prior to action\n'
00165     if(status.gFLT == 0x07):
00166         output += 'Priority Fault: The activation bit must be set prior to action\n'
00167     if(status.gFLT == 0x09):
00168         output += 'Minor Fault: The communication chip is not ready\n'
00169     if(status.gFLT == 0x0A):
00170         output += 'Minor Fault: Changing mode fault, interferences detected on Scissor (for less than 20 sec)\n'
00171     if(status.gFLT == 0x0B):
00172         output += 'Minor Fault: Automatic release in progress\n'
00173     if(status.gFLT == 0x0D):
00174         output += 'Major Fault: Activation fault, verify that no interference or other error occured\n'
00175     if(status.gFLT == 0x0E):
00176         output += 'Major Fault: Changing mode fault, interferences detected on Scissor (for more than 20 sec)\n'
00177     if(status.gFLT == 0x0F):
00178         output += 'Major Fault: Automatic release completed. Reset and activation is required\n'
00179 
00180     #gPRA
00181     output += 'gPRA = ' + str(status.gPRA) + ': '
00182     output += 'Echo of the requested position for the Gripper (or finger A in individual mode): ' + str(status.gPRA) + '/255\n'
00183 
00184     #gPOA
00185     output += 'gPOA = ' + str(status.gPOA) + ': '
00186     output += 'Position of Finger A: ' + str(status.gPOA) + '/255\n'
00187 
00188     #gCUA
00189     output += 'gCUA = ' + str(status.gCUA) + ': '
00190     output += 'Current of Finger A: ' + str(status.gCUA * 10) + ' mA\n'
00191 
00192     #gPRB
00193     output += 'gPRB = ' + str(status.gPRB) + ': '
00194     output += 'Echo of the requested position for finger B: ' + str(status.gPRB) + '/255\n'
00195 
00196     #gPOB
00197     output += 'gPOB = ' + str(status.gPOB) + ': '
00198     output += 'Position of Finger B: ' + str(status.gPOB) + '/255\n'
00199 
00200     #gCUB
00201     output += 'gCUB = ' + str(status.gCUB) + ': '
00202     output += 'Current of Finger B: ' + str(status.gCUB * 10) + ' mA\n'
00203 
00204     #gPRC
00205     output += 'gPRC = ' + str(status.gPRC) + ': '
00206     output += 'Echo of the requested position for finger C: ' + str(status.gPRC) + '/255\n'
00207 
00208     #gPOC
00209     output += 'gPOC = ' + str(status.gPOC) + ': '
00210     output += 'Position of Finger C: ' + str(status.gPOC) + '/255\n'
00211 
00212     #gCUC
00213     output += 'gCUC = ' + str(status.gCUC) + ': '
00214     output += 'Current of Finger C: ' + str(status.gCUC * 10) + ' mA\n'
00215 
00216     #gPRS
00217     output += 'gPRS = ' + str(status.gPRS) + ': '
00218     output += 'Echo of the requested position for the scissor axis: ' + str(status.gPRS) + '/255\n'
00219 
00220     #gPOS
00221     output += 'gPOS = ' + str(status.gPOS) + ': '
00222     output += 'Position of the scissor axis: ' + str(status.gPOS) + '/255\n'
00223 
00224     #gCUS
00225     output += 'gCUS = ' + str(status.gCUS) + ': '
00226     output += 'Current of the scissor axis: ' + str(status.gCUS * 10) + ' mA\n'        
00227 
00228     return output
00229     
00230 if __name__ == '__main__':
00231     SModelStatusListener()


robotiq_s_model_control
Author(s): Nicolas Lauzier (Robotiq inc.)
autogenerated on Thu Aug 27 2015 14:44:26