Gripper Connection and Disconnection
SUMMARY
Gripper Connection and Disconnection manages the gripper session lifecycle for reliable runtime communication.
This skill ensures robust setup and teardown of gripper communication channels before and after task execution.
UNITS
timeout_ms in milliseconds (Robotiq only, default 5000). Port numbers are unitless integers. simulation_prim_path is a USD path string.
The Skill
python
# Connect
gripper.connect(ip=gripper_ip, protocol="URCAP", timeout_ms=2000)
# Or connect to the matching articulation in a running Isaac Sim stage
gripper.connect(simulation_prim_path=prim_path)
# Disconnect
gripper.disconnect()The Code
Safety first!
A real robot will faithfully do whatever you ask of it - so please take a moment to clear the workspace, keep an E-Stop within reach, and be ready to disconnect.
Operating real hardware is at your own risk.
python
"""
Demonstrates connecting and disconnecting a parallel gripper.
Supports OnRobot and Robotiq grippers, and Isaac Sim.
Usage:
python connection_and_disconnection.py --ip <GRIPPER_IP>
python connection_and_disconnection.py --prim_path <PRIM_PATH>
Note:
Experimental gripper support for Isaac Sim: Robotiq 2F85 (USD-based simulation only); Schunk EGP and
PZN+ are.
"""
import argparse
from loguru import logger
from telekinesis.synapse.tools.parallel_grippers import onrobot
def main(ip: str | None,
protocol: str,
prim_path: str | None) -> None:
"""Connects to an OnRobot gripper over real hardware or Isaac Sim, then disconnects."""
#===================== Create Gripper ======================================
gripper = onrobot.OnRobotRG6()
try:
#===================== Connect Gripper =================================
if prim_path:
gripper.connect(simulation_prim_path=prim_path)
else:
gripper.connect(ip=ip, protocol=protocol)
except (ConnectionError, OSError) as e:
logger.error(f"Error occurred: {e}")
finally:
gripper.disconnect()
if __name__ == "__main__":
p = argparse.ArgumentParser(description="OnRobot gripper connect/disconnect")
p.add_argument("--protocol",
choices=["MODBUS_TCP"],
default="MODBUS_TCP")
p.add_argument("--ip", default=None, help="IP for OnRobot Gripper")
p.add_argument("--prim_path", type=str, default=None,
help='Isaac Sim gripper prim path, e.g. "/World/onrobot_rg6"')
args = p.parse_args()
main(ip=args.ip,
protocol=args.protocol,
prim_path=args.prim_path)Running the Example
bash
python connection_and_disconnection.py --ip 192.168.1.100bash
python connection_and_disconnection.py --prim_path /World/onrobot_rg6For all options:
bash
python connection_and_disconnection.py --helpParameter Configuration
Connect
Robotiq 2F-85
| Parameter | Type | Default | Description |
|---|---|---|---|
ip | str | None | IP address of the gripper. |
protocol | str | "URCAP" | "URCAP" (via a UR controller) or "MODBUS_RTU" (direct USB connection). |
timeout_ms | int | 5000 | Connection timeout in milliseconds. Range: 1-120000. |
verbose | bool | False | If True, enables verbose backend logging. |
simulation_prim_path | str | None | USD path of the gripper in a running Isaac Sim stage, e.g. /World/robotiq_2f_85. Ignores every other argument when given. |
OnRobot RG2 / RG6
| Parameter | Type | Default | Description |
|---|---|---|---|
ip | str | "" | IP address of the gripper. |
protocol | str | "MODBUS_TCP" | Only "MODBUS_TCP" is accepted. |
simulation_prim_path | str | None | USD path of the gripper in a running Isaac Sim stage, e.g. /World/onrobot_rg6. Ignores every other argument when given. |
Disconnect
This skill takes no input parameters.
Returns
Connect
This skill returns nothing (None).
Disconnect
This skill returns nothing (None).
Raises
Connect
Robotiq 2F-85
| Exception | Condition |
|---|---|
TypeError | An argument (ip, serial_port, protocol, timeout_ms) does not match its expected type |
ValueError | protocol is not "URCAP" or "MODBUS_RTU", timeout_ms is outside [1, 120000], or the address required by the selected protocol (ip for URCAP, serial_port for MODBUS_RTU) is missing |
RuntimeError | The backend connection fails |
OnRobot RG2 / RG6
| Exception | Condition |
|---|---|
TypeError | An argument (ip, protocol, timeout_ms) does not match its expected type |
ValueError | ip is empty, protocol is not "MODBUS_TCP", or timeout_ms is outside [1, 120000] |
RuntimeError | The gripper model is not set (e.g. OnRobot instantiated directly instead of OnRobotRG2/OnRobotRG6), or the connection to the gripper fails |
Disconnect
| Exception | Condition |
|---|---|
RuntimeError | The gripper is not connected |
Where to Use the Skill
- Session setup - Call
connectonce at the start of every script before issuing any gripper commands - Session teardown - Call
disconnectat the end of every script to release the gripper session - Error recovery - Re-connect after a communication fault to restore the control session
When Not to Use the Skill
Do not call connect or disconnect when:
- The gripper is already connected -
connecton an active session overwrites the existing session; disconnect first if reconnecting intentionally - Inside a tight control loop - establishing a session has latency; connect once at startup and reuse it throughout execution