Skip to content

sim2bot.Robot.cameras

cameras(timeout: float = 2.0) -> list[dict]

Return the global scene cameras available for subscription.

Parameters:

  • timeout (float, default: 2.0 ) –

    Discovery timeout in seconds when the scene is not cached.

Returns:

  • list[dict]

    Camera dictionaries containing an id, label, kind, stream

  • list[dict]

    defaults, and mount metadata. Mount kind may be world, robot,

  • list[dict]

    object, or sensor.

Raises:

  • RuntimeError

    If discovery is needed and the client is not connected.

  • ConnectionClosed

    If the WebSocket closes during discovery.

  • OSError

    If the selected transport cannot send a discovery request.

Notes

Camera IDs are global scene resources. A world-mounted overhead camera can observe several robots and is not addressed with robot=.

Source code in sim2bot/client.py
def cameras(self, timeout: float = 2.0) -> list[dict]:
    """Return the global scene cameras available for subscription.

    Args:
        timeout: Discovery timeout in seconds when the scene is not cached.

    Returns:
        Camera dictionaries containing an ``id``, label, kind, stream
        defaults, and mount metadata. Mount kind may be ``world``, ``robot``,
        ``object``, or ``sensor``.

    Raises:
        RuntimeError: If discovery is needed and the client is not connected.
        ConnectionClosed: If the WebSocket closes during discovery.
        OSError: If the selected transport cannot send a discovery request.

    Notes:
        Camera IDs are global scene resources. A world-mounted overhead camera
        can observe several robots and is not addressed with ``robot=``.
    """
    if self._scene is None:
        self.describe(timeout)
    return list((self._scene or {}).get("cameras", []))

Practical examples

Examples use objects discovered from the current scene rather than hard-coded robot metadata.

Find world-mounted cameras

world_cameras = [
    camera for camera in sim.cameras()
    if camera["mount"]["kind"] == "world"
]
print(world_cameras)

Find a camera mounted on one robot

camera = next(
    item for item in sim.cameras()
    if item["mount"].get("robotId") == arm.id
)
print(camera["id"], camera["label"])

Guidance

Usage tip

Treat the camera ID as global. Mount metadata explains attachment but does not make the stream belong to a robot command index.

Common error

Do not invent IDs such as model:0; select the exact ID returned by discovery.


See also