Skip to content

Suction Gripper Connection and Disconnection

SUMMARY

Suction Gripper Connection and Disconnection manages the gripper session lifecycle for reliable runtime communication.

This skill ensures robust setup and teardown of the gripper's communication channel before and after task execution.

SUPPORTED GRIPPERS

Available on Piab suction grippers.

The Skill

python
# Connect
gripper.connect(ip=gripper_ip, protocol="URCAP")

# Disconnect
gripper.disconnect()

The Code

Example: Basic Connect and Disconnect

python
"""
Piab connect and disconnect example for the Synapse SDK.

Usage:
    python connect-and-disconnect.py --ip <ROBOT_IP>
"""

import argparse
import time
from loguru import logger

from telekinesis.synapse.tools.suction_grippers import piab


def main(ip: str):
    """Connect to a Piab gripper at `ip` and cleanly disconnect."""

    # Create the gripper
    gripper = piab.PiabPiCobotElectric()
    logger.info(f"Connecting Piab at {ip}...")

    # Connect to the gripper
    gripper.connect(ip=ip, protocol="URCAP")
    logger.success("Connected.")

    # Sleep for a bit
    time.sleep(2.0)

    # Disconnect cleanly
    gripper.disconnect()
    logger.success("Disconnected.")


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Piab gripper connect/disconnect example")
    parser.add_argument("--ip", type=str, required=True, help="UR controller IP address")
    args = parser.parse_args()

    main(ip=args.ip)

The Explanation of the Code

connect opens a session with the Piab URCap XML-RPC service running on the UR controller. The call blocks until the session is ready or raises a ConnectionError if the service cannot be reached. On success, the gripper's vacuum level is initialized to its currently configured value (50% by default).

disconnect closes the session and releases the XML-RPC transport. Raises RuntimeError if called when not connected.

How to Tune the Parameters

Connect

Piab piCOBOT Electric

ParameterTypeDefaultDescription
ipstr-IP address of the Universal Robots controller.
protocolstr"URCAP"Only "URCAP" is currently supported.

Disconnect

No parameters.

TIP

Always call disconnect after task execution to cleanly release the gripper session.

WARNING

connect raises a ConnectionError if the Piab URCap service is unreachable. Verify the URCap is installed and running, and that the controller IP is correct, before calling.

Where to Use the Skill

  • Session setup - Call connect once at the start of every script before issuing any gripper commands
  • Session teardown - Call disconnect at 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 - connect on 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