API
pyRobotiqGripper: Python Driver for Robotiq Grippers via Modbus RTU
pyRobotiqGripper is a Python library designed to facilitate control of Robotiqgrippers using Modbus RTU communication via serial port.
This module provides documentation in two formats:
Docstrings: Embedded within the code for easy access.
Online Documentation: Extensive documentation available at <https://pyrobotiqgripper.readthedocs.io/en/latest/>.
- class pyRobotiqGripper.RobotiqGripper(portname='auto', slaveAddress=9)[source]
Bases:
Instrument
Object control Robotiq grippers (2F85, 2F140 or hande).
Suppose that the gripper is connected via the USB/RS485 adapter to the PC executing this code.
Modbus RTU function code supported by robotiq gripper
Description
Modbus function code
Read registers
4
Write registers
16
Master read & write multiple registers
23
For more information for gripper communication please check gripper manual on Robotiq website. https://robotiq.com/support/2f-85-2f-140
Note
This object cannot be use to control epick, 3F or powerpick.
- activate()[source]
If not already activated, activate the gripper.
Warning
When you execute this function the gripper is going to fully open and close. During this operation the gripper must be able to freely move. Do not place object inside the gripper.
- calibrate(closemm, openmm)[source]
Calibrate the gripper for mm positionning.
Once the calibration is done it is possible to control the gripper in mm.
- Args:
closemm (float): Distance between the fingers when the gripper is fully closed.
openmm (float): Distance between the fingers when the gripper is fully open.
- close(speed=255, force=255)[source]
Close the gripper.
- Args:
speed (int, optional): Gripper speed between 0 and 255. Default is 255.
force (int, optional): Gripper force between 0 and 255. Default is 255.
- getPosition()[source]
Return the position of the gripper in bits
- Returns:
int: Position of the gripper in bits.
- getPositionmm()[source]
Return the position of the gripper in mm.
- Returns:
float: Current gripper position in mm
Note
Calibration is needed to use this function.
Execute the function calibrate at least 1 time before using this function.
- goTo(position, speed=255, force=255)[source]
Go to the position with determined speed and force.
- Args:
position (int): Position of the gripper. Integer between 0 and 255. 0 being the open position and 255 being the close position.
speed (int): Gripper speed between 0 and 255
force (int): Gripper force between 0 and 255
- Returns:
objectDetected (bool): True if object detected
position (int): End position of the gripper in bits
- goTomm(positionmm, speed=255, force=255)[source]
Go to the requested opening expressed in mm
- Args:
positionmm (float): Gripper opening in mm.
speed (int, optional): Gripper speed between 0 and 255. Default is 255.
force (int, optional): Gripper force between 0 and 255. Default is 255.
Note
Calibration is needed to use this function.
Execute the function calibrate at least 1 time before using this function.
- isActivated()[source]
Tells if the gripper is activated
- Returns:
bool: True if the gripper is activated. False otherwise.
- isCalibrated()[source]
Return if the gripper is qualibrated
- Returns:
bool: True if the gripper is calibrated. False otherwise.
- open(speed=255, force=255)[source]
Open the gripper
- Args:
speed (int, optional): Gripper speed between 0 and 255. Default is 255.
force (int, optional): Gripper force between 0 and 255. Default is 255.
- readAll()[source]
Retrieve gripper output register information and save it in the parameter dictionary.
The dictionary keys are as follows:
gOBJ: Object detection status. This built-in feature provides information on possible object pick-up. Ignore if gGTO == 0.
gSTA: Gripper status. Returns the current status and motion of the gripper fingers.
gGTO: Action status. Echo of the rGTO bit (go-to bit).
gACT: Activation status. Echo of the rACT bit (activation bit).
kFLT: See your optional controller manual for input registers and status.
gFLT: Fault status. Returns general error messages useful for troubleshooting. A fault LED (red) is present on the gripper chassis. The LED can be blue, red, or both, and can be solid or blinking.
gPR: Echo of the requested position for the gripper. Value between 0x00 and 0xFF.
gPO: Actual position of the gripper obtained via the encoders. Value between 0x00 and 0xFF.
gCU: The current is read instantaneously from the motor drive. Value between 0x00 and 0xFF. Approximate current equivalent is 10 times the value read in mA.