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
Configuration parameters for a cube shape. |
|
LoadOption(rebuild_normals: 'bool' = <factory>, rebuild_tangent: 'bool' = <factory>, rebuild_3rdnormal: 'bool' = <factory>, rebuild_3rdtangent: 'bool' = <factory>, smooth: 'float' = <factory>) |
|
Configuration parameters for a triangle mesh shape. |
|
ShapeCfg(shape_type: 'str' = <factory>, visual_material: 'VisualMaterialCfg | None' = <factory>) |
|
Configuration parameters for a sphere shape. |
- class embodichain.lab.sim.shapes.ShapeCfg[source]#
Bases:
objectShapeCfg(shape_type: ‘str’ = <factory>, visual_material: ‘VisualMaterialCfg | None’ = <factory>)
Methods:
from_dict(init_dict)Initialize the configuration from a dictionary.
Attributes:
Type of the shape.
Configuration parameters for the visual material of the shape.
- classmethod from_dict(init_dict)[source]#
Initialize the configuration from a dictionary.
- Return type:
-
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:
ShapeCfgConfiguration parameters for a triangle mesh shape.
Attributes:
The method used for approximate convex decomposition (ACD) of the mesh.
Whether to compute UV coordinates for the shape.
File path to the shape mesh file.
Options for loading and processing the shape.
The maximum number of convex hulls that will be created for the mesh.
Direction to project the UV coordinates.
Resolution for the signed distance field (SDF) of the mesh.
Type of the shape.
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 whenmax_convex_hull_numis 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_resolutionis 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.
-
acd_method:
- class embodichain.lab.sim.shapes.CubeCfg[source]#
Bases:
ShapeCfgConfiguration parameters for a cube shape.
Attributes:
Type of the shape.
Size of the cube (in m) as [length, width, height].
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.
-
shape_type:
- class embodichain.lab.sim.shapes.SphereCfg[source]#
Bases:
ShapeCfgConfiguration parameters for a sphere shape.
Attributes:
Radius of the sphere (in m).
Resolution of the sphere mesh.
Type of the shape.
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.
-
radius:
- class embodichain.lab.sim.shapes.LoadOption[source]#
Bases:
objectLoadOption(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:
Whether to rebuild the normal for the shape using 3rd party library.
Whether to rebuild the tangent for the shape using 3rd party library.
Whether to rebuild normals for the shape.
Whether to rebuild tangents for the shape.
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:
-
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.