Skip to content

Weld Gun Connection and Disconnection

SUMMARY

Weld Gun Connection and Disconnection manages the welding gun's Isaac Sim session lifecycle for reliable runtime communication.

This skill ensures robust setup and teardown of the simulated gun's control channel before and after a weld sequence.

UNITS

simulation_prim_path is a USD path string. There is no ip / protocol variant - the gun is exclusively modelled for Isaac Sim.

The Skill

python
gun.connect(simulation_prim_path="/World/spot_welding_gun")

gun.disconnect()

The Code

python
"""
Demonstrates connecting to and disconnecting from a simulated spot-welding gun.

Usage:
    python connection_and_disconnection.py --prim_path <PRIM_PATH>
"""

import argparse
from loguru import logger

from telekinesis.synapse.tools import welding_gun


def main(prim_path: str) -> None:
    """Connects to a simulated spot-welding gun, then disconnects."""

    #===================== Create Gun ======================================
    gun = welding_gun.SpotWeldingGun()

    try:
        #===================== Connect Gun =================================
        gun.connect(simulation_prim_path=prim_path)
        logger.success(f"is_connected: {gun.is_connected}")
    finally:
        gun.disconnect()


if __name__ == "__main__":
    p = argparse.ArgumentParser(description="Spot-welding gun connect/disconnect")
    p.add_argument("--prim_path", type=str, default="/World/spot_welding_gun",
                   help='Isaac Sim gun prim path, e.g. "/World/spot_welding_gun"')
    args = p.parse_args()

    main(prim_path=args.prim_path)

Running the Example

bash
python connection_and_disconnection.py --prim_path /World/spot_welding_gun

For all options:

bash
python connection_and_disconnection.py --help

Parameter Configuration

Connect

ParameterTypeDefaultDescription
simulation_prim_pathstr-USD path of the articulated welding gun, e.g. /World/spot_welding_gun. Loaded from the gun's USD asset if no prim exists there yet.

Disconnect

This skill takes no input parameters.

Returns

Neither connect nor disconnect return a value (None).

Raises

Connect

ExceptionCondition
TypeErrorsimulation_prim_path is not a string
ValueErrorsimulation_prim_path is empty
RuntimeErrorThe gun is already connected, or the Isaac Sim bridge rejects the gun

Disconnect

ExceptionCondition
RuntimeErrorThe gun is not connected

Where to Use the Skill

  • Session setup - Call connect once at the start of every script before issuing any weld commands
  • Session teardown - Call disconnect at the end of every script to release the gun's control session and hide any visible sparks

When Not to Use the Skill

Do not call connect or disconnect when:

  • The gun is already connected - connect on an active session raises; disconnect first if reconnecting intentionally
  • The prim path is not yet decided - pick the target prim path up front, since connecting loads the gun's USD asset there if nothing exists yet