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.

UNITS

ip is an IPv4 string, simulation_prim_path is a USD path string. No quantitative units returned.

The Skill

python

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

# Or connect to the matching articulation in a running Isaac Sim stage
robot.connect(simulation_prim_path=prim_path)

# Disconnect from the robot controller to cleanly release the session
robot.disconnect()
Virtual

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
"""
Connects to a UR10e, waits briefly, then cleanly disconnects.

Supports Universal Robots (UR), Epson, and Isaac Sim.

Usage:
    python connection_and_disconnection.py [--ip <ROBOT_IP>] [--prim_path <PRIM_PATH>]
"""

import argparse
import time

from loguru import logger

from telekinesis.synapse.robots.manipulators import universal_robots


def main(ip: str | None, prim_path: str | None) -> None:
    """Connect to a UR10e over real hardware or Isaac Sim, then cleanly disconnect."""

    #===================== Create Robot ==========================================
    robot = universal_robots.UniversalRobotsUR10E(name='UR10e')

    # ==================== Visualization (Optional) ================================
    robot.visualize_rerun()

    try:
        # ==================== Run Skill ============================================
        if ip:
            robot.connect(ip=ip)
            logger.success(f"Connected to UR10e at {ip}.")
        elif prim_path:
            robot.connect(simulation_prim_path=prim_path)
            logger.success(f"Connected to UR10e at {prim_path}.")

        time.sleep(2)
    except (ConnectionError, OSError) as e:
        logger.error(f"Error occurred: {e}")
    finally:
        robot.disconnect()
        robot.shutdown()
        logger.success("Disconnected.")


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Connection Synapse example")
    parser.add_argument("--ip", type=str, default=None,
                         help="UR robot IP address for real hardware, e.g. 192.168.1.100")
    parser.add_argument("--prim_path", type=str, default=None,
                         help='Isaac Sim articulation prim path, e.g. "/World/ur10e"')
    args = parser.parse_args()

    main(ip=args.ip, prim_path=args.prim_path)

Running the Example

bash
python connection_and_disconnection.py --prim_path /World/ur10e
bash
python connection_and_disconnection.py --ip 192.168.1.100

For all options:

bash
python connection_and_disconnection.py --help

Parameter Configuration

connect

ParameterTypeDefaultDescription
ipstrNoneIP address of the robot controller. Must be reachable from the host machine.
simulation_prim_pathstrNoneUSD path of the robot's articulation in a running Isaac Sim stage, e.g. /World/ur10e. Requires the telekinesis.isaacsim.bridge extension enabled and the timeline playing.

disconnect

This skill takes no input parameters.

Returns

connect

TypeDescription
NoneReturns after the communication session with the robot controller is opened.

disconnect

TypeDescription
NoneReturns after the communication session with the robot controller is released.

Raises

connect

ExceptionCondition
RuntimeErrorThe connection attempt fails - for example an incorrect IP address, a network routing issue, or the robot not being in remote-control mode

disconnect

disconnect does not raise - a communication fault while releasing the session is logged, not propagated, so it always returns the robot to offline mode.

How to Tune the Parameters

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.

Simulation prim path. Pass simulation_prim_path instead of ip to connect to the matching articulation in a running Isaac Sim stage. Exactly one of the two should be given.

Always call disconnect after task execution to cleanly release the controller session - leaving sessions open can prevent other processes from connecting. Wrap connect in a try/except RuntimeError block (as in the example above) so a failed connection attempt - robot not powered on, wrong IP address, or remote control not enabled on the teach pendant - is handled gracefully rather than crashing the script.

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