embodichain.lab.sim.shapes#

Overview#

Geometry configuration objects used to build the collision and visual shapes of rigid bodies. ShapeCfg is the common base; MeshCfg, CubeCfg, and SphereCfg describe triangle-mesh, box, and sphere primitives respectively, and LoadOption controls how mesh assets are loaded and decomposed.

Classes

CubeCfg

Configuration parameters for a cube shape.

LoadOption

LoadOption(rebuild_normals: 'bool' = <factory>, rebuild_tangent: 'bool' = <factory>, rebuild_3rdnormal: 'bool' = <factory>, rebuild_3rdtangent: 'bool' = <factory>, smooth: 'float' = <factory>)

MeshCfg

Configuration parameters for a triangle mesh shape.

ShapeCfg

ShapeCfg(shape_type: 'str' = <factory>, visual_material: 'VisualMaterialCfg | None' = <factory>)

SphereCfg

Configuration parameters for a sphere shape.

class embodichain.lab.sim.shapes.ShapeCfg[source]#

Bases: object

ShapeCfg(shape_type: ‘str’ = <factory>, visual_material: ‘VisualMaterialCfg | None’ = <factory>)

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

Attributes:

shape_type

Type of the shape.

visual_material

Configuration parameters for the visual material of the shape.

classmethod from_dict(init_dict)[source]#

Initialize the configuration from a dictionary.

Return type:

ShapeCfg

shape_type: str#

Type of the shape. Must be specified in subclasses.

visual_material: VisualMaterialCfg | None#

Configuration parameters for the visual material of the shape. Defaults to None.

class embodichain.lab.sim.shapes.MeshCfg[source]#

Bases: ShapeCfg

Configuration parameters for a triangle mesh shape.

Attributes:

acd_method

The method used for approximate convex decomposition (ACD) of the mesh.

compute_uv

Whether to compute UV coordinates for the shape.

fpath

File path to the shape mesh file.

load_option

Options for loading and processing the shape.

max_convex_hull_num

The maximum number of convex hulls that will be created for the mesh.

project_direction

Direction to project the UV coordinates.

sdf_resolution

Resolution for the signed distance field (SDF) of the mesh.

shape_type

Type of the shape.

visual_material

Configuration parameters for the visual material of the shape.

acd_method: str#

The method used for approximate convex decomposition (ACD) of the mesh.

Defaults to "visacd". "visacd", "coacd", and "vhacd" are supported. Only used when max_convex_hull_num is set to larger than 1. "visacd" requires CUDA support.

compute_uv: bool#

Whether to compute UV coordinates for the shape. Defaults to False.

If the shape already has UV coordinates, setting this to True will recompute and overwrite them.

fpath: str#

File path to the shape mesh file.

load_option: LoadOption#

Options for loading and processing the shape.

max_convex_hull_num: int#

The maximum number of convex hulls that will be created for the mesh.

If set to larger than 1, the mesh will be decomposed into multiple convex hulls using the approximate convex decomposition method specified by acd_method.

project_direction: List[float]#

Direction to project the UV coordinates. Defaults to [1.0, 1.0, 1.0].

sdf_resolution: int#

Resolution for the signed distance field (SDF) of the mesh.

The spacing of the uniformly sampled SDF is equal to the largest AABB extent of the mesh, divided by the resolution. If sdf_resolution is set to larger than 0, an SDF will be generated for collision detection. SDF increases the accuracy of collision, but also takes more time to initialize and simulate.

shape_type: str#

Type of the shape. Must be specified in subclasses.

visual_material: VisualMaterialCfg | None#

Configuration parameters for the visual material of the shape. Defaults to None.

class embodichain.lab.sim.shapes.CubeCfg[source]#

Bases: ShapeCfg

Configuration parameters for a cube shape.

Attributes:

shape_type

Type of the shape.

size

Size of the cube (in m) as [length, width, height].

visual_material

Configuration parameters for the visual material of the shape.

shape_type: str#

Type of the shape. Must be specified in subclasses.

size: List[float]#

Size of the cube (in m) as [length, width, height].

visual_material: VisualMaterialCfg | None#

Configuration parameters for the visual material of the shape. Defaults to None.

class embodichain.lab.sim.shapes.SphereCfg[source]#

Bases: ShapeCfg

Configuration parameters for a sphere shape.

Attributes:

radius

Radius of the sphere (in m).

resolution

Resolution of the sphere mesh.

shape_type

Type of the shape.

visual_material

Configuration parameters for the visual material of the shape.

radius: float#

Radius of the sphere (in m).

resolution: int#

Resolution of the sphere mesh. Defaults to 20.

shape_type: str#

Type of the shape. Must be specified in subclasses.

visual_material: VisualMaterialCfg | None#

Configuration parameters for the visual material of the shape. Defaults to None.

class embodichain.lab.sim.shapes.LoadOption[source]#

Bases: object

LoadOption(rebuild_normals: ‘bool’ = <factory>, rebuild_tangent: ‘bool’ = <factory>, rebuild_3rdnormal: ‘bool’ = <factory>, rebuild_3rdtangent: ‘bool’ = <factory>, smooth: ‘float’ = <factory>)

Methods:

__init__([rebuild_normals, rebuild_tangent, ...])

copy(**kwargs)

Return a new object replacing specified fields with new values.

from_dict(init_dict)

Initialize the configuration from a dictionary.

replace(**kwargs)

Return a new object replacing specified fields with new values.

to_dict()

Convert an object into dictionary recursively.

validate([prefix])

Check the validity of configclass object.

Attributes:

rebuild_3rdnormal

Whether to rebuild the normal for the shape using 3rd party library.

rebuild_3rdtangent

Whether to rebuild the tangent for the shape using 3rd party library.

rebuild_normals

Whether to rebuild normals for the shape.

rebuild_tangent

Whether to rebuild tangents for the shape.

smooth

Angle threshold (in degrees) for smoothing normals.

__init__(rebuild_normals=<factory>, rebuild_tangent=<factory>, rebuild_3rdnormal=<factory>, rebuild_3rdtangent=<factory>, smooth=<factory>)#
copy(**kwargs)#

Return a new object replacing specified fields with new values.

This is especially useful for frozen classes. Example usage:

@configclass(frozen=True)
class C:
    x: int
    y: int

c = C(1, 2)
c1 = c.replace(x=3)
assert c1.x == 3 and c1.y == 2
Parameters:
  • obj (object) – The object to replace.

  • **kwargs – The fields to replace and their new values.

Return type:

object

Returns:

The new object.

classmethod from_dict(init_dict)[source]#

Initialize the configuration from a dictionary.

Return type:

LoadOption

rebuild_3rdnormal: bool#

Whether to rebuild the normal for the shape using 3rd party library. Defaults to False.

rebuild_3rdtangent: bool#

Whether to rebuild the tangent for the shape using 3rd party library. Defaults to False.

rebuild_normals: bool#

Whether to rebuild normals for the shape. Defaults to False.

rebuild_tangent: bool#

Whether to rebuild tangents for the shape. Defaults to False.

replace(**kwargs)#

Return a new object replacing specified fields with new values.

This is especially useful for frozen classes. Example usage:

@configclass(frozen=True)
class C:
    x: int
    y: int

c = C(1, 2)
c1 = c.replace(x=3)
assert c1.x == 3 and c1.y == 2
Parameters:
  • obj (object) – The object to replace.

  • **kwargs – The fields to replace and their new values.

Return type:

object

Returns:

The new object.

smooth: float#

Angle threshold (in degrees) for smoothing normals. Defaults to -1.0 (no smoothing).

to_dict()#

Convert an object into dictionary recursively.

Note

Ignores all names starting with “__” (i.e. built-in methods).

Parameters:

obj (object) – An instance of a class to convert.

Raises:

ValueError – When input argument is not an object.

Return type:

dict[str, Any]

Returns:

Converted dictionary mapping.

validate(prefix='')#

Check the validity of configclass object.

This function checks if the object is a valid configclass object. A valid configclass object contains no MISSING entries.

Parameters:
  • obj (object) – The object to check.

  • prefix (str) – The prefix to add to the missing fields. Defaults to ‘’.

Return type:

list[str]

Returns:

A list of missing fields.

Raises:

TypeError – When the object is not a valid configuration object.