Skip to content

Tray

Represents a tray container with a unique identifier, 6-DOF pose, dimensions, slot count, and an optional list of Part instances. The number of parts must not exceed num_slots. This datatype is used for tray-based workflows within the Telekinesis ecosystem.

Field

Required

FieldTypeDescription
idintUnique identifier for the tray (int).
poseArrayLike6-element pose vector [x, y, z, rx, ry, rz] in degrees; shape (6,), dtype float32.
x_dimfloatX dimension of the tray (float).
y_dimfloatY dimension of the tray (float).
z_dimfloatZ dimension of the tray (float).
num_slotsintNumber of slots in the tray, must be ≥ 0 (int).

Optional

FieldTypeDescription
partslist[Part]List of Part instances in the tray. Default []. Length must not exceed num_slots.

Example

python
from datatypes import datatypes
from datatypes.datatypes import PartState
from loguru import logger

# ------------------------------------------------
# 1. Create Tray instance
# ------------------------------------------------
parts = [
    datatypes.Part(
        id=1,
        pose=[10, 20, 30, 0, 0, 0],
        x_dim=5.0,
        y_dim=5.0,
        z_dim=2.0,
        state=PartState.VISIBLE,
    ),
    datatypes.Part(
        id=2,
        pose=[40, 50, 60, 0, 0, 90],
        state=PartState.OCCLUDED,
    ),
]
tray = datatypes.Tray(
    id=10,
    pose=[500.0, 300.0, 100.0, 0.0, 0.0, 0.0],
    x_dim=100.0,
    y_dim=80.0,
    z_dim=15.0,
    num_slots=4,
    parts=parts,
)

# ------------------------------------------------
# 2. Access data via to_dict
# ------------------------------------------------
tray_dict = tray.to_dict()
logger.info("Tray to_dict id={}", tray_dict["id"])
logger.info("Tray to_dict pose={}", tray_dict["pose"])
logger.info("Tray to_dict x_dim={}", tray_dict["x_dim"])
logger.info("Tray to_dict y_dim={}", tray_dict["y_dim"])
logger.info("Tray to_dict z_dim={}", tray_dict["z_dim"])
logger.info("Tray to_dict num_slots={}", tray_dict["num_slots"])
logger.info("Tray to_dict num_parts={}", len(tray_dict["parts"]))

# ------------------------------------------------
# 3. Empty Tray (no parts)
# ------------------------------------------------
empty_tray = datatypes.Tray(
    id=11,
    pose=[0, 0, 0, 0, 0, 0],
    x_dim=50.0,
    y_dim=40.0,
    z_dim=10.0,
    num_slots=0,
)
empty_dict = empty_tray.to_dict()
logger.info("Empty Tray to_dict id={}", empty_dict["id"])
logger.info("Empty Tray to_dict num_parts={}", len(empty_dict["parts"]))