scene_synthesizer.procedural_assets.ShelfAsset

class scene_synthesizer.procedural_assets.ShelfAsset(*args, **kwargs)

A shelf asset consisting of an optional back board, N equally spaced shelf boards, and side posts or boards.

For example, to create the shelf of the MotionBenchMaker paper, Fig. 6 (first column), do:

from scene_synthesizer import procedural_assets as pa
pa.ShelfAsset(
    width=0.8,
    depth=0.8,
    height=1.8,
    num_boards=5,
    num_side_columns=float("inf"),
    bottom_board=False,
    cylindrical_columns=False,
    num_vertical_boards=0,
).scene().colorize().show()
../_images/shelf_closed_asset.png

To create the shelf of the MotionBenchMaker paper, Fig. 6 (second column), do:

from scene_synthesizer import procedural_assets as pa
pa.ShelfAsset(
    width=0.8,
    depth=0.8,
    height=1.8,
    num_boards=5,
    num_side_columns=2,
    bottom_board=False,
    cylindrical_columns=True,
    num_vertical_boards=1,
).scene().colorize().show()
../_images/shelf_open_asset.png

To create the cubby of the MotionBenchMaker paper, Fig. 6 (fourth column), do:

from scene_synthesizer import procedural_assets as pa
pa.ShelfAsset(
    width=0.7,
    depth=0.7,
    height=0.35,
    num_boards=2,
    num_side_columns=float("inf"),
    bottom_board=True,
    cylindrical_columns=False,
    num_vertical_boards=0,
).scene().colorize().show()
../_images/shelf_cubby_asset.png
Parameters:
  • width (float) – Width of shelf.

  • depth (float) – Depth of shelf.

  • height (float) – Height of shelf.

  • num_boards (int) – Number of boards, equally spaced between 0.0 (depending on bottom_board) and height.

  • board_thickness (float) – Thickness of each board. Defaults to 0.03.

  • backboard_thickness (float, optional) – Thickness of back board. If zero no back board is added. Defaults to 0.0.

  • num_vertical_boards (int, optional) – Number of vertical boards that divide each shelf equally. Defaults to 0.

  • num_side_columns (int or float('inf'), optional) – Number of columns on each side. If float(‘inf’) a side board is added. Defaults to 2.

  • column_thickness (float, optional). Radius or side length of side columns (depending on cylindrical_columns)

  • bottom_board (bool, optional) – Whether to start with the shelf boards at the bottom level. Defaults to True.

  • cylindrical_columns (bool, optional) – Cylindrical or box-shaped side columns. Defaults to True.

  • **kwargs – Arguments will be delegated to constructor of TrimeshSceneAsset.

as_trimesh_scene(namespace='object', use_collision_geometry=True)
compute_stable_poses(convexify=False, center_mass=None, sigma=0.0, n_samples=1, threshold=0.0, tolerance_zero_extent=1e-6, use_collision_geometry=True)

Wrapper for trimesh.poses.compute_stable_poses function.

Parameters:
  • convexify (bool, optional) – Whether to use the convex hull of the object.

  • center_mass ((3,) float, optional) – The object center of mass. If None, this method assumes uniform density and watertightness and computes a center of mass explicitly. Defaults to None.

  • sigma (float, optional) – The covariance for the multivariate gaussian used to sample center of mass locations. Defaults to 0.0.

  • n_samples (int, optional) – The number of samples of the center of mass location. Defaults to 1.

  • threshold (float, optional) – The probability value at which to threshold returned stable poses. Defaults to 0.0.

  • tolerance_zero_extent (float, optional) – The threshold for considering a dimension to have zero length. In this case, trimesh.poses.compute_stable_poses gets caught in an infinite loop. We avoid this by specifying the stable poses to be along zero-length dimensions. Defaults to 1e-6.

  • use_collision_geometry (bool, optional) – Whether to use the collision geometry or visual geometry to calculate stable poses. Defaults to True.

Returns:

The homogeneous matrices that transform the object to rest in a stable pose. probs ((n,) float): Probability in (0, 1) for each pose

Return type:

transforms ((n, 4, 4) float)

get_bounds(query=None, frame=None, use_collision_geometry=None)

Return bounds of asset defined through nodes selected by query.

Parameters:
  • query (list[str] or str) – A list, string, or regular expression referring to a subset of all geometry of this asset. None means entire asset. Defaults to None.

  • frame (str, optional) – The reference frame to use. None means asset’s base frame is used. Defaults to None.

  • use_collision_geometry (bool, optional) – Whether to use collision geometry, visual geometry or both (if None). Defaults to None.

Returns:

A 2x3 matrix of minimum and maximum coordinates for each dimension.

Return type:

np.ndarray

get_center_mass(query=None, frame=None, use_collision_geometry=None)

Return center of mass for subscene defined through nodes selected by query.

Parameters:
  • query (list[str] or str) – A list, string, or regular expression referring to a subset of all geometry of this asset. None means entire asset. Defaults to None.

  • frame (str, optional) – The reference frame to use. None means asset’s base frame is used. Defaults to None.

  • use_collision_geometry (bool, optional) – Whether to use collision geometry, visual geometry or both (if None). Defaults to None.

Returns:

A 3-vector describing the center of mass of the queried subscene.

Return type:

np.ndarray

get_centroid(query=None, frame=None, use_collision_geometry=None)

Return centroid for asset defined through nodes selected by query.

Parameters:
  • query (list[str] or str) – A list, string, or regular expression referring to a subset of all geometry of this asset. None means entire asset. Defaults to None.

  • frame (str, optional) – The reference frame to use. None means asset’s base frame is used. Defaults to None.

  • use_collision_geometry (bool, optional) – Whether to use collision geometry, visual geometry or both (if None). Defaults to None.

Returns:

A 3-vector describing the centroid of the queried subscene.

Return type:

np.ndarray

get_extents(query=None, frame=None, use_collision_geometry=None)

Return extents of asset defined through nodes selected by query.

Parameters:
  • query (list[str] or str) – A list, string, or regular expression referring to a subset of all geometry of this asset. None means entire asset. Defaults to None.

  • frame (str, optional) – The reference frame to use. None means asset’s base frame is used. Defaults to None.

  • use_collision_geometry (bool, optional) – Whether to use collision geometry, visual geometry or both (if None). Defaults to None.

Returns:

A 3-vector describing the extents of each dimension.

Return type:

np.ndarray

get_reference_frame(xyz, query=None, frame=None, use_collision_geometry=None)

Return reference frame for subscene defined through nodes selected by query.

Parameters:
  • xyz (tuple[str]) – A 3-tuple/list of [‘top’, ‘center’, ‘bottom’, ‘com’, ‘centroid’]

  • query (list[str] or str) – A list, string, or regular expression referring to a subset of all geometry of this asset. None means entire asset. Defaults to None.

  • frame (str, optional) – The reference frame to use. None means scene’s base frame is used. Defaults to None.

  • use_collision_geometry (bool, optional) – Whether to use collision geometry, visual geometry or both (if None). Defaults to None.

Raises:

ValueError – Unknown reference string.

Returns:

A 4x4 homogenous matrix.

Return type:

np.ndarray

mesh(use_collision_geometry=False)

Return a trimesh.Trimesh object of the asset.

Parameters:

use_collision_geometry (bool, optional) – Whether to use the collision or visual geometry or both. Defaults to False.

Returns:

A trimesh mesh.

Return type:

trimesh.Trimesh

sample_stable_pose(seed=None, **kwargs)

Return a stable pose according to their likelihood.

Returns:

homogeneous 4x4 matrix seed (int, numpy.random._generator.Generator, optional): A seed or random number generator. Defaults to None which creates a new default random number generator.

Return type:

np.ndarray

scene(obj_id='object', **kwargs)

Return a scene consisting of only this asset.

Parameters:
  • obj_id (str, optional) – Name of object in scene. Defaults to ‘object’.

  • **kwargs – Additional keyword arguments that will be piped to the add_object method.

Returns:

A scene

Return type:

scene.Scene

show(use_collision_geometry=False, layers=None)

Display the asset via the trimesh scene viewer.

Parameters:
  • use_collision_geometry (bool, optional) – Which geometry to show: visual or collision geometry. Defaults to False.

  • layers (list[str], optional) – Filter to show only certain layers, e.g. ‘visual’ or ‘collision’. Defaults to None, showing everything.