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
camera.connect()The device to open is addressed through the arguments of connect, not the constructor. IDS and RealSense need a serial_number:
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:
camera.connect(simulation_prim_path="/World/camera")The Code
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()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()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()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_numberthrough the IDS Peak library and allocates the acquisition buffers needed to receive frames from the sensor. Aserial_numberis required for a device connection. - Webcam — opens the device via OpenCV's
VideoCaptureusing the integercamera_idreported by the OS (0for 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 withset_parameter("stream_profile", ...)betweenconnectand 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. Useload_settingsafter 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
| Parameter | Type | Default | Description |
|---|---|---|---|
camera_id | int | 0 | Webcam only. OpenCV camera index of the webcam to open. Ignored when connecting to a simulated camera. |
serial_number | str | None | None | IDS, 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_addr | str | IPv4Address | None | None | SensoPart only. IP address of the camera. Required unless simulation_prim_path is given. |
port | int | 2006 | SensoPart only. TCP port on the camera. |
timeout | float | 5.0 | SensoPart only. Socket timeout in seconds for the connection and frame reads. |
simulation_prim_path | str | None | None | All 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
| Type | Description |
|---|---|
None | connect() has no return value on any camera. |
Raises
| Exception | Condition |
|---|---|
RuntimeError | The camera is already connected. |
RuntimeError | The 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). |
ValueError | IDS, 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.