Skip to content

Shutdown ​

SUMMARY

Shutdown releases the robot: it disconnects the active backend, stops the control loop and stops publishing. It is idempotent and also runs automatically at process exit and on SIGINT/SIGTERM.

The Skill ​

python
robot.shutdown()

The Code ​

python
"""
Release the robot: disconnect, stop the control loop, and stop publishing.

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

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

import argparse

from loguru import logger

from telekinesis.synapse.robots.manipulators import universal_robots


def main(ip: str | None, prim_path: str | None) -> None:
    """Connect the robot, then release it with a single shutdown() call."""

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

    #===================== Connect Robot ==========================================
    if ip:
        robot.connect(ip=ip)
    elif prim_path:
        robot.connect(simulation_prim_path=prim_path)
    logger.info(f"Connected to real hardware: {robot.is_connected()}")

    # ==================== Run Skill ============================================
    # Disconnects from whichever backend is active, so no disconnect() call is needed
    robot.shutdown()
    logger.success(f"Robot shut down. Connected to real hardware: {robot.is_connected()}")


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Release the robot with shutdown()")
    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 shutdown.py
bash
python shutdown.py --prim_path /World/ur10e
bash
python shutdown.py --ip 192.168.1.100

For all options:

bash
python shutdown.py --help

Parameter Configuration ​

This skill takes no input parameters.

Returns ​

TypeDescription
NoneThe robot is released and no longer usable.

How to Tune the Parameters ​

This skill takes no parameters. Call it in a finally block after Connect and Disconnect so an interrupted script still releases the robot. A robot cannot be used after shutdown.

Where to Use the Skill ​

  • Script cleanup - Release the robot at the end of every example or program.
  • Long-running processes - Free a robot while the process keeps running.

When Not to Use the Skill ​

  • You want to reconnect later - use disconnect() only; a shut-down robot is not usable.