Connection and Disconnection (CNC)
SUMMARY
Connect links a CNCMachine instance to a door prim in the open Isaac Sim stage, together with the open and closed positions the door travels between. Disconnect releases that connection. All operations on the door other than connecting require an active connection, so always pair the two inside a try / finally block.
Available on: IsaacSim CNC.
The Skill
python
machine.connect(simulation_prim_path="/World/cnc_machine/E_body_1/door",
open_position=(-0.687, -0.053, 1.208),
closed_position=(-0.219, -0.053, 1.208))
machine.disconnect()The Code
python
"""
Demonstrates connecting to and disconnecting from a CNC machine's door in a
running Isaac Sim stage.
Supports Isaac Sim only.
Usage:
python connection_and_disconnection.py --prim_path <PRIM_PATH>
python connection_and_disconnection.py --prim_path <PRIM_PATH> --load_usd
Note:
Open Isaac Sim and add a CNC machine whose door is its own prim before
running this, or pass --load_usd to add one to the open stage -- this
keeps whatever is already in the stage. Both positions are relative to
the door prim's parent: select the door prim, slide it fully open and
fully closed in the stage, and read the position off Property >
Transform each time. Where that transform is shown as a matrix, the
first three values of the bottom row are its x, y and z.
"""
import argparse
from loguru import logger
from telekinesis.medulla.machines import isaacsim
def main(prim_path: str,
open_position: list[float],
closed_position: list[float],
load_usd: bool) -> None:
"""Connects to a CNC machine's door, then disconnects."""
if load_usd:
# ===================== Load Demo Scene (Optional) ===========================
from telekinesis import datatypes, isaacsim_client
client = isaacsim_client.IsaacSimClient(
api_key="",
base_url="http://127.0.0.1:8766",
websocket_base_url="ws://127.0.0.1:8766",
)
asset = datatypes.USD.from_url(
"https://assets.telekinesis.ai/usd/machines/cnc_machine.zip"
)
client.stage.add_to_scene(uri=asset.path.as_posix(),
prim_path="/World/cnc_machine")
# ===================== Create Machine =======================================
machine = isaacsim.CNCMachine(name="my_simulated_cnc_machine")
try:
# ==================== Run Skill ============================================
machine.connect(simulation_prim_path=prim_path,
open_position=open_position,
closed_position=closed_position)
logger.success(f"Connected: {machine.is_connected}.")
except (ConnectionError, RuntimeError) as e:
logger.error(f"Error occurred: {e}")
finally:
machine.disconnect()
if __name__ == "__main__":
p = argparse.ArgumentParser(
description="Connect to and disconnect from a CNC machine's door in Isaac Sim")
p.add_argument("--prim_path", type=str, default="/World/cnc_machine/E_body_1/door",
help='Isaac Sim CNC machine door prim path, e.g. '
'"/World/cnc_machine/E_body_1/door"')
p.add_argument("--open_position", type=float, nargs=3,
default=[-0.68654, -0.05313, 1.208], metavar=("X", "Y", "Z"),
help="Door position in meters, relative to the door "
"prim's parent, at which it stands open")
p.add_argument("--closed_position", type=float, nargs=3,
default=[-0.2193, -0.05313, 1.208], metavar=("X", "Y", "Z"),
help="Door position in meters, relative to the door "
"prim's parent, at which it stands closed")
p.add_argument("--load_usd", action=argparse.BooleanOptionalAction, default=False,
help="Add the bundled demo CNC machine to the open stage "
"at /World/cnc_machine before connecting. Use this "
"if you don't already have one in the stage.")
args = p.parse_args()
main(prim_path=args.prim_path,
open_position=args.open_position,
closed_position=args.closed_position,
load_usd=args.load_usd)Running the Example
bash
python connection_and_disconnection.py --prim_path /World/cnc_machine/E_body_1/doorTo load the bundled demo CNC machine into the stage first:
bash
python connection_and_disconnection.py --load_usdFor all options:
bash
python connection_and_disconnection.py --helpParameter Configuration
connect
| Parameter | Type | Default | Description |
|---|---|---|---|
simulation_prim_path | str | required | USD path of the door prim of a CNC machine in the open Isaac Sim stage, e.g. "/World/cnc_machine/E_body_1/door". |
open_position | Sequence[float] | required | Position (x, y, z) in meters, relative to the door prim's parent, at which the door stands open. |
closed_position | Sequence[float] | required | Position (x, y, z) in meters, relative to the door prim's parent, at which the door stands closed. |
disconnect
Takes no parameters.
Returns
| Method | Type | Description |
|---|---|---|
connect | None | Returns nothing. |
disconnect | None | Returns nothing. |
Raises
| Method | Exception | Condition |
|---|---|---|
connect | RuntimeError | The machine is already connected, or the connection fails (Isaac Sim not running with the telekinesis.isaacsim.bridge extension enabled, or the prim missing from the stage). |
connect | TypeError | simulation_prim_path is empty or not a string. |
connect | ValueError | Either position is not three coordinates. |
disconnect | (none) | Calling on a machine that is not connected logs a warning instead of raising. |
Where to Use the Skill
Connect is the first call against a CNCMachine, and Disconnect the last. Use Open and Close Door in between to drive the door.

