Skip to content

Connection and Disconnection

SUMMARY

Connection and Disconnection manages the robot-controller session lifecycle for reliable runtime communication.

This skill ensures robust setup and teardown of robot communication channels before and after task execution.

SUPPORTED ROBOTS

Currently supported only on Universal Robots.

UNITS

ip is an IPv4 string. No quantitative units returned.

The Skill

python

# Connect to the robot controller at the specified IP address
robot.connect(ip=robot_ip)

# Disconnect from the robot controller to cleanly release the session
robot.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.

Wrap the connection in a try/except block to handle network or configuration failures gracefully.

python
"""
Connection and disconnection example for the Synapse SDK.

Connection and disconnection are to real robot hardware. Currently supported only
for Universal Robots.

Usage:
    python connection_and_disconnection.py --ip <ROBOT_IP>
"""

import argparse
import time
from loguru import logger

from telekinesis.synapse.robots.manipulators import universal_robots


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

    # Create the robot instance
    robot = universal_robots.UniversalRobotsUR10E()

    # Connect to the robot with given ip
    robot.connect(ip=ip)
    logger.success(f"Connected to UR10e at {ip}.")

    # Sleep for a bit
    time.sleep(2)

    # Disconnect from the robot
    robot.disconnect()
    logger.success("Disconnected.")


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Connection Synapse example")
    parser.add_argument("--ip", type=str, required=True, help="UR robot IP address")
    args = parser.parse_args()

    main(ip=args.ip)

The Explanation of the Code

connect opens the communication session between Synapse and the robot controller. connect must be called before any motion or query commands to ensure a valid session.

disconnect closes the session for communication with the robot controller. Always call disconnect at the end of your script to cleanly release the session and allow other processes to connect.

IP address. Pass the IP address of the robot controller as a string. The robot must be powered on, reachable on the network, and configured to allow remote control before calling connect.

Error handling. connect raises a RuntimeError if the connection attempt fails - for example due to an incorrect IP address, a network routing issue, or the robot not being in remote-control mode. Wrapping the call in a try/except block (as in Example 2) is recommended in production code.

How to Tune the Parameters

Connect

ParameterTypeDefaultDescription
ipstr-IP address of the robot controller. Must be reachable from the host machine.

Disconnect

No parameters.

TIP

Always call disconnect after task execution to cleanly release the controller session. Leaving sessions open can prevent other processes from connecting.

WARNING

connect will raise a RuntimeError if the robot is not powered on, the IP address is wrong, or remote control is not enabled on the teach pendant. Verify all three before calling.

Where to Use the Skill

  • Session setup - Call connect once at the start of every script before issuing any motion or query commands
  • Session teardown - Call disconnect at the end of every script to release the controller session
  • Error recovery - Re-connect after a communication fault to restore the control session without restarting the process

When Not to Use the Skill

Do not call connect or disconnect when:

  • The robot is already connected - calling connect again on an active session will overwrite the existing communication channels; disconnect first if reconnecting intentionally
  • Inside a tight control loop - establishing a session has latency; connect once at startup and reuse the session throughout execution