Skip to content

Connect ​

SUMMARY

Connect opens a connection to the camera hardware so frames can be acquired. It initializes the underlying vendor SDK, opens the device, allocates buffers or starts the pipeline, and registers any BabyROS nodes the camera class exposes.

Always pair it with Disconnect inside a try / finally block so the device is freed even if an exception is raised.

All subsequent operations on the camera require an active connection.

Available on: All cameras.

The Skill ​

python
camera.connect()

The device to open is addressed through the arguments of connect, not the constructor. IDS and RealSense need a serial_number:

python
camera.connect(serial_number="244222074143")

To use a simulated camera in a running Isaac Sim stage instead of a device, pass the camera's USD prim path:

python
camera.connect(simulation_prim_path="/World/camera")

The Code ​

python
from loguru import logger
from telekinesis.medulla.cameras import webcam

camera = webcam.Webcam(name="my_webcam_camera")
try:
    camera.connect(camera_id=0)
except Exception as e:
    logger.error(f"Unable to connect to the camera. {type(e).__name__}: {e}")
finally:
    camera.disconnect()
python
from loguru import logger
from telekinesis.medulla.cameras import ids

camera = ids.IDSU336L0CX(name="my_ids_camera")
try:
    camera.connect(serial_number="4108615854")
except Exception as e:
    logger.error(f"Unable to connect to the camera. {type(e).__name__}: {e}")
finally:
    camera.disconnect()
python
from loguru import logger
from telekinesis.medulla.cameras import realsense

camera = realsense.RealSenseD435I(name="my_realsense_camera")
try:
    camera.connect(serial_number="244222074143")
except Exception as e:
    logger.error(f"Unable to connect to the camera. {type(e).__name__}: {e}")
finally:
    camera.disconnect()
python
from loguru import logger
from telekinesis.medulla.cameras import zivid

camera = zivid.Zivid2M70(name="my_zivid_camera")
try:
    camera.connect()
except Exception as e:
    logger.error(f"Unable to connect to the camera. {type(e).__name__}: {e}")
finally:
    camera.disconnect()

The Explanation of the Code ​

connect performs the vendor-specific initialization needed before any frame can be acquired:

  • IDS — opens the device by serial_number through the IDS Peak library and allocates the acquisition buffers needed to receive frames from the sensor. A serial_number is required for a device connection.
  • Webcam — opens the device via OpenCV's VideoCapture using the integer camera_id reported by the OS (0 for the first camera) and verifies that frames can be read.
  • RealSense — selects the device by serial_number (required for a device connection) and prepares the depth scale, alignment, and point cloud helpers. The pipeline itself starts lazily on the first capture, so stream profiles can still be configured with set_parameter("stream_profile", ...) between connect and the first capture.
  • Zivid — initializes the Zivid SDK application and connects to the camera with the given serial_number, or to the first available Zivid camera when none is given. Default capture settings are created with a single 3D acquisition and a single 2D colour acquisition. Use load_settings after connecting to apply a configuration exported from Zivid Studio.

WARNING

Make sure to disconnect from the camera with disconnect() at the end of your script to avoid a freezing terminal when the script finishes.

Parameter Configuration ​

ParameterTypeDefaultDescription
camera_idint0Webcam only. OpenCV camera index of the webcam to open. Ignored when connecting to a simulated camera.
serial_numberstr | NoneNoneIDS, RealSense, Zivid. Serial number of the device to open. Required for IDS and RealSense unless simulation_prim_path is given; Zivid uses the first available camera when omitted.
ip_addrstr | IPv4Address | NoneNoneSensoPart only. IP address of the camera. Required unless simulation_prim_path is given.
portint2006SensoPart only. TCP port on the camera.
timeoutfloat5.0SensoPart only. Socket timeout in seconds for the connection and frame reads.
simulation_prim_pathstr | NoneNoneAll cameras. USD path of a camera in the open Isaac Sim stage, e.g. "/World/camera". When given, the camera reads that simulated camera instead of a device, and device parameters are not available. Requires Isaac Sim running with the telekinesis.isaacsim.bridge extension enabled, cameras enabled, and the timeline playing.

The constructor takes only name and verbose; RealSense additionally takes warmup_frames (default 30), the number of frames discarded when automatic image controls are enabled, to let auto-exposure and auto-white-balance converge. Set it to 0 to skip.

Returns ​

TypeDescription
Noneconnect() has no return value on any camera.

Raises ​

ExceptionCondition
RuntimeErrorThe camera is already connected.
RuntimeErrorThe device could not be found or opened: no device matches the requested serial number (IDS, RealSense), OpenCV could not open camera_id (Webcam), or the Zivid SDK failed to connect (Zivid).
ValueErrorIDS, RealSense: neither serial_number nor simulation_prim_path was given.

A camera can be connected only once: after disconnect it cannot be connected again, so create a new camera instance to reconnect.

Where to Use the Skill ​

Connect is the first call against any Medulla camera. Pair it with Disconnect inside a try / finally block so resources are released regardless of how the script exits. See Capture Color Image for the full pattern in practice.