### Install pyRobotiqGripper with all dependencies Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/installation.md Use this command to install the pyRobotiqGripper package along with all optional dependencies, which are required for the joystick CLI and history/data helper methods. The python command may need to be adjusted to python3 depending on your system. ```bash python3 -m pip install "pyRobotiqGripper[all]" ``` -------------------------------- ### RobotiqGripper Connection and Setup Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Methods for establishing, closing, and resetting the connection to the Robotiq gripper. ```APIDOC ## RobotiqGripper Setup Methods ### RobotiqGripper.connect() Connect to the gripper. If the connection is already established, do nothing. ### RobotiqGripper.disconnect() Disconnect from the gripper. If the connection is already closed, do nothing. ### RobotiqGripper.reset() Reset the gripper (clear previous activation and calibration if any). ``` -------------------------------- ### Complete Gripper Usage Example Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt A comprehensive Python script demonstrating typical workflow: connecting, activating, calibrating, performing basic open/close, moving to specific positions, attempting to grasp an object, and disconnecting. Ensure the gripper is connected and powered on before running. ```python import pyrobotiqgripper as rq import time # Initialize gripper with auto-detection gripper = rq.RobotiqGripper() gripper.connect() # Activate (gripper will calibrate itself) print("Activating gripper...") gripper.activate() # Set up millimeter calibration for 2F85 gripper print("Calibrating for millimeter control...") gripper.calibrate_mm(closemm=0, openmm=85) # Basic operations print("Testing basic operations...") gripper.open() time.sleep(0.5) gripper.close() time.sleep(0.5) # Move to specific positions print("Moving to 50mm opening...") gripper.move_mm(positionmm=50) print(f"Position: {gripper.position_mm():.1f} mm") # Grasp object test print("Attempting to grasp object...") gripper.close(speed=100, force=150) status = gripper.status() if status['gOBJ'] == 2: print("Object detected while closing!") print(f"Gripped at position: {gripper.position_mm():.1f} mm") else: print("No object detected, gripper fully closed") # Display final status gripper.printStatus() # Cleanup gripper.open() gripper.disconnect() print("Done!") ``` -------------------------------- ### RobotiqGripper Initialization and Control Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Functions for starting, stopping, opening, and closing the Robotiq gripper. ```APIDOC ## RobotiqGripper.start(refreshStatus=True) ### Description Starts the gripper motion. The GTO bit is set to 1, and the gripper will move to the position command if it is not already there. ### Method POST (or similar, depending on underlying implementation) ### Endpoint /api/gripper/start ### Parameters #### Query Parameters - **refreshStatus** (bool) - Optional - Whether to refresh the gripper status before the start process. Setting this to False can make the start process faster if you are sure the gripper status is up to date. ### Request Example ```json { "refreshStatus": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "started" } ``` ## RobotiqGripper.stop() ### Description Stops the gripper's movement. The GTO bit is set to 0, but the position command is not changed. The gripper will stop at its current position and hold it. ### Method POST (or similar, depending on underlying implementation) ### Endpoint /api/gripper/stop ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "stopped" } ``` ## RobotiqGripper.open(speed=255, force=255, wait=True, readStatus=True, refreshStatus=False) ### Description Opens the gripper to the specified speed and force. ### Method POST (or similar, depending on underlying implementation) ### Endpoint /api/gripper/open ### Parameters #### Query Parameters - **speed** (int) - Optional - Gripper speed between 0 and 255. Defaults to 255. - **force** (int) - Optional - Gripper force between 0 and 255. Defaults to 255. - **wait** (bool) - Optional - If True, the function waits until the gripper reaches the requested position or detects an object. Defaults to True. - **readStatus** (bool) - Optional - If True, the gripper status is read after sending the command. Defaults to True. - **refreshStatus** (bool) - Optional - If True, the gripper status is refreshed before sending the command. Defaults to False. ### Request Example ```json { "speed": 200, "force": 200, "wait": true, "readStatus": true, "refreshStatus": false } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "opened" } ``` ## RobotiqGripper.close(speed=255, force=255, wait=True, readStatus=True, refreshStatus=False) ### Description Closes the gripper to the specified speed and force. ### Method POST (or similar, depending on underlying implementation) ### Endpoint /api/gripper/close ### Parameters #### Query Parameters - **speed** (int) - Optional - Gripper speed between 0 and 255. Defaults to 255. - **force** (int) - Optional - Gripper force between 0 and 255. Defaults to 255. - **wait** (bool) - Optional - If True, the function waits until the gripper reaches the requested position or detects an object. Defaults to True. - **readStatus** (bool) - Optional - If True, the gripper status is read after sending the command. Defaults to True. - **refreshStatus** (bool) - Optional - If True, the gripper status is refreshed before sending the command. Defaults to False. ### Request Example ```json { "speed": 200, "force": 200, "wait": true, "readStatus": true, "refreshStatus": false } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "closed" } ``` ``` -------------------------------- ### RobotiqGripper.history() Example Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Combines command and status histories into a single, aligned pandas DataFrame. This provides a comprehensive view of gripper operations. ```python # Returns: # A DataFrame containing the merged history with columns for # time, commands, and status values. # Return type: pd.DataFrame ``` -------------------------------- ### RobotiqGripper.isStarted Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Checks if the gripper has been started. This is a simple status check. ```APIDOC ## RobotiqGripper.isStarted ### Description Check whether the gripper is started. ### Method GET (or equivalent function call) ### Endpoint N/A (This is a method call, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python is_started = grip.isStarted() ``` ### Response #### Success Response (200) - **return_value** (bool) - True if started, False otherwise. #### Response Example ```json { "return_value": true } ``` ``` -------------------------------- ### Check Gripper Start Status Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Checks if the gripper has been started. This is a simple boolean check. ```python is_started = grip.isStarted() ``` -------------------------------- ### RobotiqGripper.commandHistory() Example Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Retrieves the command history of the gripper as a pandas DataFrame. This is useful for debugging and analyzing past commands sent to the gripper. ```python # Returns: A DataFrame containing the command history with columns for # time and various command registers (rARD, rATR, etc.). # Return type: pd.DataFrame ``` -------------------------------- ### Joystick-Controlled Real-time Gripper Movement Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Example demonstrating real-time gripper control using a joystick with Pygame. Maps joystick axis input to gripper position. ```python import pygame import time import pyrobotiqgripper as rq grip = rq.RobotiqGripper() pygame.init() pygame.joystick.init() js = pygame.joystick.Joystick(0) js.init() while True: pygame.event.pump() requested_pos=int((js.get_axis(0) + 1) * 255 / 2) grip.realtimemove(requested_pos) ``` -------------------------------- ### RobotiqGripper.statusHistory() Example Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Retrieves the status history of the gripper as a pandas DataFrame. This method is helpful for tracking the gripper's state over time. ```python # Returns: # A DataFrame containing the status history with columns for # time and various status registers (gOBJ, gSTA, etc.). # Return type: pd.DataFrame ``` -------------------------------- ### RobotiqGripper Activation Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Activates the gripper, preparing it for operation. Can optionally reset and start motion immediately. ```APIDOC ## RobotiqGripper Activation ### RobotiqGripper.activate(reset=True, start=True, refreshStatus=True) Activate the gripper if it is not already active. * **Parameters:** * **reset** (bool) – Whether to reset the gripper before activation. Default is True. * **start** (bool) – Whether to start the gripper motion immediately after activation (gGTO set to 1). Default is True. * **refreshStatus** (bool) – Whether to refresh the gripper status before the activation process. Default is True. ``` -------------------------------- ### Joystick CLI Help Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/advanced_usage.md View available options for the `pyrobotiqgripper-joystick` CLI by running the command with the `--help` flag. ```bash pyrobotiqgripper-joystick --help ``` -------------------------------- ### Initialize RobotiqGripper (UR Robot TCP) Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/README.rst Create a RobotiqGripper object for a gripper connected to a UR robot's IP address using RTU_VIA_TCP connection type. Replace with the robot's actual IP. ```python import pyrobotiqgripper as rq #Create a Robotiq gripper object. gripper = rq.RobotiqGripper(connection_type="RTU_VIA_TCP", tcp_host=) ``` -------------------------------- ### Activate Gripper Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Initialize the gripper by calling the activate() method. This performs a full open/close cycle for calibration. Ensure no obstructions. Activation can be delayed or reset. ```python import pyrobotiqgripper as rq gripper = rq.RobotiqGripper() gripper.connect() # Full activation with reset and auto-start gripper.activate() ``` ```python # Activate without resetting previous state gripper.activate(reset=False) ``` ```python # Activate without starting motion immediately gripper.activate(start=False) ``` ```python # Check activation status if gripper.isActivated(): print("Gripper is activated and ready") ``` ```python # Start gripper motion after delayed activation gripper.start() ``` -------------------------------- ### Launch Joystick CLI Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/advanced_usage.md Run the `pyrobotiqgripper-joystick` command to control the gripper with a joystick, gamepad, or mouse. Assumes USB connection for the gripper and a connected joystick. ```bash pyrobotiqgripper-joystick ``` -------------------------------- ### Create Robotiq Gripper Object (UR Robot Connection) Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/connection.md Instantiate a RobotiqGripper object for connection via a UR robot. Specify the connection type as 'RTU_VIA_TCP' and provide the UR robot's IP address. ```python from pyrobotiqgripper import RobotiqGripper #Create a Robotiq gripper object. gripper = RobotiqGripper(connection_type="RTU_VIA_TCP", tcp_host=) ``` -------------------------------- ### Create RobotiqGripper Instance Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Instantiate the RobotiqGripper class. Supports auto-detection of USB ports or manual configuration for serial and TCP connections. Debug logging can be enabled. ```python import pyrobotiqgripper as rq # Auto-detect USB connection (default RTU mode) gripper = rq.RobotiqGripper() ``` ```python # Manual COM port specification (Windows) gripper = rq.RobotiqGripper(com_port="COM3") ``` ```python # Manual COM port specification (Linux) gripper = rq.RobotiqGripper(com_port="/dev/ttyUSB0") ``` ```python # Connect to gripper via UR robot with RS485 URCap (RTU over TCP) gripper = rq.RobotiqGripper( connection_type=rq.GRIPPER_MODE_RTU_VIA_TCP, tcp_host="192.168.1.100", tcp_port=54321 ) ``` ```python # Enable debug logging for Modbus communication gripper = rq.RobotiqGripper(debug=True) ``` -------------------------------- ### Connect and Control Gripper Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/basic_usage.md Connect to the gripper, activate it, set its calibration range, and perform basic open, close, and move operations. Use position() for bit-based feedback and positionmm() for millimeter-based feedback. ```python gripper.connect() gripper.activate() gripper.calibrate_mm(closemm=0, openmm=40) gripper.open() gripper.close() gripper.move(100) position_in_bit = gripper.position() print(position_in_bit) gripper.move_mm(25) position_in_mm = gripper.positionmm() print(position_in_mm) ``` -------------------------------- ### Joystick CLI Tool Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Control the gripper using a joystick, gamepad, or mouse via the command-line tool. Basic joystick control can be initiated with a single command, automatically detecting the gripper and joystick. ```bash # Basic joystick control (auto-detect gripper and joystick) pyrobotiqgripper-joystick ``` -------------------------------- ### RobotiqGripper Methods Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md This section details methods for retrieving gripper command and status history. ```APIDOC ## RobotiqGripper.commandHistory() ### Description Return the gripper command history as a pandas DataFrame. ### Method `commandHistory` ### Endpoint N/A (Method within a class) ### Parameters None ### Request Example None ### Response #### Success Response - **DataFrame** (pd.DataFrame) - A DataFrame containing the command history with columns for time and various command registers (rARD, rATR, etc.). ### Response Example ```python # Example DataFrame structure # import pandas as pd # pd.DataFrame({'time': [...], 'rARD': [...], ...}) ``` ## RobotiqGripper.statusHistory() ### Description Return the gripper status history as a pandas DataFrame. ### Method `statusHistory` ### Endpoint N/A (Method within a class) ### Parameters None ### Request Example None ### Response #### Success Response - **DataFrame** (pd.DataFrame) - A DataFrame containing the status history with columns for time and various status registers (gOBJ, gSTA, etc.). ### Response Example ```python # Example DataFrame structure # import pandas as pd # pd.DataFrame({'time': [...], 'gOBJ': [...], ...}) ``` ## RobotiqGripper.history() ### Description Return the merged command and status history as a pandas DataFrame. This method combines the command history and status history into a single DataFrame with all timestamps aligned. ### Method `history` ### Endpoint N/A (Method within a class) ### Parameters None ### Request Example None ### Response #### Success Response - **DataFrame** (pd.DataFrame) - A DataFrame containing the merged history with columns for time, commands, and status values. ### Response Example ```python # Example DataFrame structure # import pandas as pd # pd.DataFrame({'time': [...], 'rARD': [...], 'gOBJ': [...], ...}) ``` ``` -------------------------------- ### Move Gripper and Print Status Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Demonstrates basic gripper control by moving it to a position and then printing its current status. Ensure the gripper is properly initialized before use. ```python >>> grip.move(100) >>> grip.print_status() ``` -------------------------------- ### Create Robotiq Gripper Object (Auto-Detect Port) Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/connection.md Instantiate a RobotiqGripper object. The serial port is automatically detected. Ensure the gripper is connected via USB to RS485 converter. ```python import pyrobotiqgripper as rq #Create a Robotiq gripper object. gripper = rq.RobotiqGripper() ``` -------------------------------- ### Create Robotiq Gripper Object (Specify Port) Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/connection.md Instantiate a RobotiqGripper object, manually specifying the serial port. This is useful if auto-detection fails or for clarity. Requires the gripper to be connected via USB to RS485 converter. ```python import pyrobotiqgripper as rq #Create a Robotiq gripper object and specify the serial port name. gripper = rq.RobotiqGripper(com_port="COM3") ``` -------------------------------- ### Connection Management Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Manage the gripper connection lifecycle using `connect()`, `disconnect()`, and `reset()`. `reset()` clears activation and calibration, requiring `activate()` to be called afterward. ```python import pyrobotiqgripper as rq gripper = rq.RobotiqGripper() # Connect to gripper (auto-called in constructor) gripper.connect() # Reset gripper (clears activation and calibration) gripper.reset() # Re-activate after reset gripper.activate() # Disconnect when done gripper.disconnect() # Reconnect if needed gripper.connect() ``` -------------------------------- ### Initialize and Control Gripper (RTU over TCP) Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md This snippet shows how to connect to and control a Robotiq gripper when it's connected to a UR robot via the RS485 URCAP, using Modbus RTU over TCP. Specify the correct TCP host IP address. ```python import pyrobotiqgripper as rq gripper = rq.RobotiqGripper(connection_type=rq.GRIPPER_MODE_RTU_VIA_TCP,tcp_host="192.168.1.100") gripper.connect() gripper.activate() gripper.start() gripper.open() ``` -------------------------------- ### Basic Gripper Movements Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Perform basic gripper movements by specifying position in millimeters and optionally speed and force. Use predefined open and closed positions. ```python gripper.move_mm(positionmm=25, speed=100, force=200) ``` ```python position_mm = gripper.position_mm() print(f"Current position: {position_mm:.2f} mm") ``` ```python gripper.move_mm(positionmm=85) ``` ```python gripper.move_mm(positionmm=5) ``` -------------------------------- ### RobotiqGripper Class Initialization Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Initializes the RobotiqGripper class, allowing control of Robotiq grippers. Supports both direct Modbus RTU and Modbus RTU over TCP connections. ```APIDOC ## RobotiqGripper Class ### Description Class used to control Robotiq grippers (2F85, 2F140 or hande). This class provides methods to initialize, open, close, and monitor the gripper. ### Parameters * **com_port** (str) - COM port to which the gripper is connected. Default is "auto". * **device_id** (int) - Address of the gripper, usually 9. Default is 9. * **connection_type** (str) - Type of connection to the gripper. Supported values are "RTU" and "RTU_VIA_TCP". Default is "RTU". * **tcp_host** (str) - Host IP address for TCP connection. Default is "127.0.0.1". * **tcp_port** (int) - Port number for TCP connection. Default is 54321. * **debug** (bool) - If True, enable debug logging for Modbus communication. Default is False. ### Request Example ```python import pyrobotiqgripper as rq # Example for direct RTU connection gripper_rtu = rq.RobotiqGripper(connection_type=rq.GRIPPER_MODE_RTU) # Example for RTU over TCP connection gripper_tcp = rq.RobotiqGripper(connection_type=rq.GRIPPER_MODE_RTU_VIA_TCP, tcp_host="192.168.1.100") ``` ``` -------------------------------- ### Real-Time Gripper Control Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Utilize real-time control for smooth, responsive gripper movements. Requires speed calibration. The `realTimeMove` method adjusts speed based on position delta and can handle object detection. ```python import pyrobotiqgripper as rq import time gripper = rq.RobotiqGripper() gripper.connect() gripper.activate() # Speed calibration required for real-time control gripper.calibrate_speed() # Basic real-time move gripper.realTimeMove(requestedPosition=128) # Real-time control loop example target_position = 0 direction = 1 for _ in range(100): gripper.realTimeMove( requestedPosition=target_position, minSpeedPosDelta=5, # Min delta for slow speed maxSpeedPosDelta=100, # Delta for max speed continuousGrip=True, # Keep gripping after detection autoLock=True, # Auto full-grip on object detection minimalMotion=2, # Ignore tiny movements verbose=1 # Print executed commands ) # Oscillate between open and closed target_position += direction * 10 if target_position >= 255: direction = -1 elif target_position <= 0: direction = 1 time.sleep(0.05) ``` ```python import pygame pygame.init() pygame.joystick.init() js = pygame.joystick.Joystick(0) js.init() while True: pygame.event.pump() # Map joystick axis (-1 to 1) to position (0 to 255) requested_pos = int((js.get_axis(0) + 1) * 255 / 2) gripper.realTimeMove(requested_pos) ``` -------------------------------- ### Move Gripper to Position (Millimeters) Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Moves the gripper to a specified opening in millimeters. Requires prior calibration using `calibrate_mm()`. Supports custom speed, force, and wait behavior. ```python grip.move_mm(positionmm=50.5, speed=200, force=250, wait=False) ``` -------------------------------- ### RobotiqGripper Basic Operations Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Provides methods for opening, closing, and moving the gripper to specified positions. ```APIDOC ## RobotiqGripper Basic Operations ### RobotiqGripper.open() Opens the gripper. ### RobotiqGripper.close() Closes the gripper. ### RobotiqGripper.move(position) Moves the gripper to a specified position in bits. * **Parameters:** * **position** (int) - The target position in bits. ### RobotiqGripper.move_mm(position_mm) Moves the gripper to a specified position in millimeters. * **Parameters:** * **position_mm** (float) - The target position in millimeters. ### RobotiqGripper.position() Returns the current gripper position in bits. ### RobotiqGripper.positionmm() Returns the current gripper position in millimeters. ### RobotiqGripper.calibrate_mm(closemm, openmm) Calibrates the gripper with specified closed and open positions in millimeters. * **Parameters:** * **closemm** (float) - The position in mm when the gripper is considered closed. * **openmm** (float) - The position in mm when the gripper is considered open. ### RobotiqGripper.printStatus() Prints the current status information of the gripper to the console. ``` -------------------------------- ### Initialize and Control Gripper (RTU) Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Use this snippet to connect to, activate, and control a Robotiq gripper connected directly via USB/RS485 using Modbus RTU. Ensure the gripper is connected before running. ```python import pyrobotiqgripper as rq gripper = rq.RobotiqGripper(connection_type=rq.GRIPPER_MODE_RTU) gripper.connect() gripper.activate() gripper.start() gripper.open() gripper.close() gripper.move(100) #Move at position 100 in bit print(gripper.position()) #Print gripper position in bit gripper.calibrate_mm(closemm=0,openmm=85) #Calibrate the gripper with 0mm when closed and 85mm when open gripper.move_mm(50) #Move at position 50mm gripper.printStatus() #Print gripper status information in the python terminal print(gripper.positionmm()) #Print gripper position in mm ``` -------------------------------- ### Millimeter-Based Gripper Control Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Utilize move_mm() and position_mm() for gripper control and feedback in millimeters. Requires prior millimeter calibration. ```python import pyrobotiqgripper as rq gripper = rq.RobotiqGripper() gripper.connect() gripper.activate() # Calibrate for millimeter control (required first) gripper.calibrate_mm(closemm=0, openmm=85) # Move to 50mm opening gripper.move_mm(positionmm=50) ``` -------------------------------- ### Constants Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md This section lists the constants available in the pyrobotiqgripper library. ```APIDOC ## Constants ### pyrobotiqgripper.BAUDRATE Default baudrate of the gripper use by Robotiq gripper. ### pyrobotiqgripper.BYTESIZE Byte size use by Robotiq gripper ### pyrobotiqgripper.PARITY Parity use by Robotiq gripper ### pyrobotiqgripper.STOPBITS Stop bits used by Robotiq gripper ### pyrobotiqgripper.TIMEOUT Default timeout use for communication with Robotiq gripper ### pyrobotiqgripper.AUTO_DETECTION Automatically detect the USB port on which the gripper connected. ### pyrobotiqgripper.GRIPPER_MODE_RTU_VIA_TCP Set communication to be RTU via TCP ### pyrobotiqgripper.GRIPPER_MODE_RTU Set communication to be RTU ### pyrobotiqgripper.REGISTER_DIC Dictionary containing all input and output registers for the Robotiq gripper. Each top-level key represents a register group: Input registers (g / k prefix): - gOBJ : Object detection status - 0: Fingers in motion, no object detected - 1: Fingers stopped while opening, object detected - 2: Fingers stopped while closing, object detected - 3: Fingers at requested position, no object detected or lost/dropped - gSTA : - 0: Reset / automatic release - 1: Activation in progress - 3: Activation completed - gGTO : - 0: Stopped / performing activation or release - 1: Go to position requested - gACT : - 0: Gripper reset - 1: Gripper activation - kFLT : Controller fault codes (0–255) - gFLT : Gripper fault codes (0–255, specific faults for indices 0, 5, 7–15) - gPR : Echo of requested positions (0–255) - gPO : Actual positions read from encoders (0–255) - gCU : Instantaneous current from motor drive (0–255, in mA) Output registers (r prefix): - rARD : Automatic release status - 0: Closing auto-release - 1: Opening auto-release - rATR : - 0: Normal - 1: Emergency auto-release - rGTO : - 0: Stop - 1: Go to requested position - rACT : - 0: Deactivate gripper - 1: Activate gripper (must stay on until routine completes) - rPR : Target positions for gripper fingers (0–255) - rSP : Speed of gripper movement (0–255) - rFR : Final gripping force (0–255) This dictionary is mapping integer codes to human-readable descriptions for every register. ``` -------------------------------- ### RobotiqGripper.realTimeMove Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Enables real-time control of the gripper's position. Allows fine-tuning of speed deltas, continuous grip, auto-locking, and motion thresholds. ```APIDOC ## RobotiqGripper.realTimeMove ### Description Move the gripper in real time to the requested position. ### Method POST (or equivalent function call) ### Endpoint N/A (This is a method call, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **requestedPosition** (int) - Required - Target position (0-255). - **minSpeedPosDelta** (int, optional) - Minimum position delta for minimum speed. Defaults to 5. - **maxSpeedPosDelta** (int, optional) - Position delta for maximum speed. Defaults to 100. - **continuousGrip** (bool, optional) - If True, gripper continuously tries to close. Defaults to True. - **autoLock** (bool, optional) - If True, performs full-speed, full-force grip after detection. Defaults to True. - **minimalMotion** (int, optional) - Minimum motion in bits to perform. Defaults to 2. - **verbose** (int, optional) - Verbose level for printing. Defaults to 0. - **objectDetectionDuration** (float, optional) - Duration for object detection. Defaults to 0.5. ### Request Example ```python grip.realTimeMove(requestedPosition=128, minSpeedPosDelta=10, autoLock=False) ``` ### Response #### Success Response (200) None explicitly defined, implies successful execution of the move command. #### Response Example None ``` -------------------------------- ### Real-time Gripper Movement Control Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Moves the gripper in real-time based on requested position changes. Configurable parameters include speed deltas, continuous grip, auto-lock, and minimal motion thresholds. ```python grip.realTimeMove(requestedPosition=150, minSpeedPosDelta=10, maxSpeedPosDelta=80, continuousGrip=False, autoLock=False, minimalMotion=5, verbose=1) ``` -------------------------------- ### Connect via RTU over TCP with Mouse Control Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Configure the joystick CLI to use RTU over TCP for communication, specifying host, port, and joystick ID. Mouse control is enabled by default when no specific joystick is selected. ```bash pyrobotiqgripper-joystick \ --connection-type "RTU_VIA_TCP" \ --tcp-host 10.0.0.153 \ --tcp-port 2000 \ --joystick-id -1 \ --verbose 1 ``` -------------------------------- ### Status Monitoring Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Read and display gripper status, including object detection, activation, and fault information. The `status()` method returns a dictionary, while `printStatus()` provides a formatted output. ```python import pyrobotiqgripper as rq gripper = rq.RobotiqGripper() gripper.connect() gripper.activate() # Get full status as dictionary status = gripper.status() print(f"Object detection: {status['gOBJ']}") print(f"Activation status: {status['gSTA']}") print(f"Go-to status: {status['gGTO']}") print(f"Position: {status['gPO']}") print(f"Current (mA): {status['gCU'] * 10}") # Pretty print status to terminal gripper.printStatus() # Output: # ====================================================================== # GRIPPER STATUS # ====================================================================== # gOBJ : 3 # └─ Fingers are at requested position. No object detected... # gSTA : 3 # └─ Activation is completed. # ... # Read fresh status from gripper gripper.readStatus() # Get last commanded values print(f"Last speed: {gripper.speed()}") print(f"Last force: {gripper.force()}") print(f"Last position command: {gripper.positionCommand()}") # Object detection check detection = gripper.objectDetection() if detection == 0: print("Fingers in motion") elif detection == 1: print("Object detected while opening") elif detection == 2: print("Object detected while closing") elif detection == 3: print("At position, no object") ``` -------------------------------- ### Real-time Gripper Movement Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/advanced_usage.md Use `realTimeMove` for high-frequency, loop-based control. The gripper adjusts speed based on distance to the target for smooth, responsive movement. ```python gripper.realTimeMove(requestedPosition=100) ``` -------------------------------- ### Current Speed, Force, and Status Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Methods to retrieve the last set speed, force, and the current gripper status. ```APIDOC ## RobotiqGripper.speed() ### Description Return the last set speed value. ### Method GET ### Endpoint /RobotiqGripper/speed ### Response #### Success Response (200) - **return_value** (int or None) - The last speed value set (0-255), or None if history is empty. ### Response Example ```json { "return_value": 200 } ``` ## RobotiqGripper.force() ### Description Return the last set force value. ### Method GET ### Endpoint /RobotiqGripper/force ### Response #### Success Response (200) - **return_value** (int | None) - The last force value set (0-255), or None if the history is empty. ### Response Example ```json { "return_value": 180 } ``` ## RobotiqGripper.status(refreshStatus=True) ### Description Return the current gripper status as a dictionary. ### Method GET ### Endpoint /RobotiqGripper/status ### Query Parameters - **refreshStatus** (bool, optional) - Whether to read fresh status from the gripper. Defaults to True. ### Response #### Success Response (200) - **return_value** (dict) - A dictionary containing current status values for all registers. ### Response Example ```json { "return_value": { "gG": 1, "gO": 0, "gP": 100, "gS": 200, "gF": 180 } } ``` ``` -------------------------------- ### Speed and Position Limits Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Methods to retrieve the maximum and minimum gripper speeds in bits per second. ```APIDOC ## RobotiqGripper.gripper_vmax_bits() ### Description Return the maximum gripper speed in bits per second. ### Method GET ### Endpoint /RobotiqGripper/gripper_vmax_bits ### Response #### Success Response (200) - **return_value** (int) - Maximum gripper speed in bits per second. ### Response Example ```json { "return_value": 1000 } ``` ## RobotiqGripper.gripper_vmin_bits() ### Description Return the minimum gripper speed in bits per second. ### Method GET ### Endpoint /RobotiqGripper/gripper_vmin_bits ### Response #### Success Response (200) - **return_value** (int) - Minimum gripper speed in bits per second. ### Response Example ```json { "return_value": 100 } ``` ``` -------------------------------- ### Joystick CLI with RTU over TCP Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/advanced_usage.md Launch the joystick CLI with mouse control, specifying Modbus RTU over TCP connection details. Use `--joystick-id -1` for mouse control and `--verbose 1` for detailed output. ```bash pyrobotiqgripper-joystick --connection-type "RTU_VIA_TCP" --tcp-host 10.0.0.153 --tcp-port 2000 --joystick-id -1 --verbose 1 ``` -------------------------------- ### Basic Gripper Control Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/README.rst Control the Robotiq gripper by activating, calibrating, opening, closing, and moving it. Position, speed, and force range from 0 to 255. ```python gripper.activate() gripper.calibrate(closemm=0, openmm=40) gripper.open() gripper.close() gripper.move(100) position_in_bit = gripper.position() print(position_in_bit) gripper.move_mm(25) position_in_mm = gripper.positionmm() print(position_in_mm) ``` -------------------------------- ### Commanded and Current Positions Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Methods to retrieve the last commanded position and the current gripper position in bits and millimeters. ```APIDOC ## RobotiqGripper.positionCommand() ### Description Return the last commanded position value. ### Method GET ### Endpoint /RobotiqGripper/positionCommand ### Response #### Success Response (200) - **return_value** (int | None) - The last position command value (0-255), or None if the history is empty. ### Response Example ```json { "return_value": 128 } ``` ## RobotiqGripper.position(refreshStatus=True) ### Description Return the current position of the gripper in bits. ### Method GET ### Endpoint /RobotiqGripper/position ### Query Parameters - **refreshStatus** (bool, optional) - Whether to refresh the gripper status before getting the position. Defaults to True. ### Response #### Success Response (200) - **return_value** (int | None) - Current gripper position in bits (0-255), or None if history is empty. ### Response Example ```json { "return_value": 150 } ``` ## RobotiqGripper.position_mm(refreshStatus=True) ### Description Return the current position of the gripper in millimeters. ### Method GET ### Endpoint /RobotiqGripper/position_mm ### Query Parameters - **refreshStatus** (bool, optional) - Whether to refresh the gripper status before getting the position. Defaults to True. ### Response #### Success Response (200) - **return_value** (float) - Current gripper position in millimeters. ### Response Example ```json { "return_value": 25.5 } ``` ``` -------------------------------- ### Calibrate Gripper Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Perform gripper calibration for bit-level, millimeter-level, and speed control. Automatic and manual calibration options are available for different gripper models. ```python import pyrobotiqgripper as rq gripper = rq.RobotiqGripper() gripper.connect() gripper.activate() # Automatic bit calibration (gripper will open and close) gripper.calibrate_bit() ``` ```python # Manual bit calibration with known values gripper.calibrate_bit(openbit=3, closebit=227) ``` ```python # Millimeter calibration for 2F85 gripper (0mm closed, 85mm open) gripper.calibrate_mm(closemm=0, openmm=85) ``` ```python # Millimeter calibration for 2F140 gripper gripper.calibrate_mm(closemm=0, openmm=140) ``` ```python # Speed calibration for real-time control (automatic) gripper.calibrate_speed() ``` ```python # Manual speed calibration with known timing values gripper.calibrate_speed(minSpeedClosingTime=2.5, maxSpeedClosingTime=0.3) ``` ```python # Check calibration status print(f"Bit calibrated: {gripper.is_bit_calibrated()}") print(f"MM calibrated: {gripper.is_mm_calibrated()}") print(f"Speed calibrated: {gripper.is_speed_calibrated()}") ``` -------------------------------- ### Move Gripper to Position (Bits) Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Moves the gripper fingers to a specified position (0-255). Supports custom speed, force, and wait behavior. Ensure the gripper is activated before use. ```python grip.move(position=100, speed=150, force=200, wait=True) ``` -------------------------------- ### Basic Gripper Movement Control Source: https://context7.com/castetsb/pyrobotiqgripper/llms.txt Control gripper movement using open(), close(), and move() methods. Supports custom speed and force settings. Position is defined in bits (0-255). Non-blocking operations and immediate stopping are available. ```python import pyrobotiqgripper as rq gripper = rq.RobotiqGripper() gripper.connect() gripper.activate() # Open gripper at full speed and force (default) gripper.open() ``` ```python # Close gripper at full speed and force gripper.close() ``` ```python # Open with custom speed and force (0-255 range) gripper.open(speed=100, force=50) ``` ```python # Close without waiting for completion gripper.close(wait=False) ``` ```python # Move to specific position (0=open, 255=closed) gripper.move(position=128) # Half closed ``` ```python # Move with custom speed and force gripper.move(position=200, speed=150, force=100) ``` ```python # Move without waiting (non-blocking) gripper.move(position=50, wait=False) ``` ```python # Get current position in bits position = gripper.position() print(f"Current position: {position}/255") ``` ```python # Stop gripper motion immediately gripper.stop() ``` -------------------------------- ### Status Retrieval and Printing Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Methods to retrieve and print the gripper status. ```APIDOC ## RobotiqGripper.readStatus() ### Description Retrieve gripper output register information and save it in the status history. ### Method GET ### Endpoint /RobotiqGripper/readStatus ### Response #### Success Response (200) - **message** (string) - Status retrieved successfully. ### Response Example ```json { "message": "Gripper status updated." } ``` ## RobotiqGripper.printStatus(refreshStatus=True) ### Description Print gripper status info in the Python terminal. ### Method GET ### Endpoint /RobotiqGripper/printStatus ### Query Parameters - **refreshStatus** (bool, optional) - Whether to read fresh status from the gripper before printing. Defaults to False. ### Response #### Success Response (200) - **message** (string) - Gripper status printed to the console. ### Response Example ```json { "message": "Gripper status printed." } ``` ``` -------------------------------- ### RobotiqGripper Calibration Source: https://github.com/castetsb/pyrobotiqgripper/blob/master/docs/api.md Functions for calibrating the gripper's position and speed. ```APIDOC ## RobotiqGripper.calibrate_bit(openbit=None, closebit=None) ### Description Calibrates the maximum and minimum position bit values of the gripper. This function sets the reference positions for the gripper in bits. If no parameters are provided, the gripper will perform a full open followed by a full close to measure the maximum and minimum positions. ### Method POST (or similar, depending on underlying implementation) ### Endpoint /api/gripper/calibrate/bits ### Parameters #### Query Parameters - **openbit** (int) - Optional - Position value in bits when the gripper is open. - **closebit** (int) - Optional - Position value in bits when the gripper is closed. ### Request Example ```json { "openbit": 100, "closebit": 500 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the calibration. #### Response Example ```json { "status": "bit_calibration_complete" } ``` ## RobotiqGripper.calibrate_speed(minSpeedClosingTime=None, maxSpeedClosingTime=None) ### Description Calibrates gripper speed to estimate gripper position over time. If no parameters are provided, the gripper will perform a full-speed closing and a slow-speed closing to evaluate its motion. Bit calibration will also be performed. ### Method POST (or similar, depending on underlying implementation) ### Endpoint /api/gripper/calibrate/speed ### Parameters #### Query Parameters - **minSpeedClosingTime** (float) - Optional - Time in seconds for the gripper to move from fully open to fully closed at minimum speed. - **maxSpeedClosingTime** (float) - Optional - Time in seconds for the gripper to move from fully open to fully closed at maximum speed. ### Request Example ```json { "minSpeedClosingTime": 5.0, "maxSpeedClosingTime": 2.0 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the calibration. #### Response Example ```json { "status": "speed_calibration_complete" } ``` ## RobotiqGripper.calibrate_mm(closemm, openmm) ### Description Calibrates the gripper for millimeter positioning. Once this calibration is done, it is possible to control the gripper using millimeters. ### Method POST (or similar, depending on underlying implementation) ### Endpoint /api/gripper/calibrate/mm ### Parameters #### Query Parameters - **closemm** (float) - Required - Distance between the fingers when the gripper is fully closed. - **openmm** (float) - Required - Distance between the fingers when the gripper is fully open. ### Request Example ```json { "closemm": 10.5, "openmm": 50.0 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the calibration. #### Response Example ```json { "status": "mm_calibration_complete" } ``` ```