Simulation Assets#
Simulation assets in EmbodiChain are configured using Python dataclasses. This approach provides a structured and type-safe way to define properties for physics, materials and objects in the simulation environment.
Visual Materials#
Configuration#
The VisualMaterialCfg class defines the visual appearance of objects using Physically Based Rendering (PBR) properties.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Unique identifier for the material. |
|
|
|
Base color/diffuse color (RGBA). |
|
|
|
Metallic factor (0.0 = dielectric, 1.0 = metallic). |
|
|
|
Surface roughness (0.0 = smooth, 1.0 = rough). |
|
|
|
Emissive color (RGB). |
|
|
|
Emissive intensity multiplier. |
|
|
|
Path to base color texture map. |
|
|
|
Path to metallic map. |
|
|
|
Path to roughness map. |
|
|
|
Path to normal map. |
|
|
|
Path to ambient occlusion map. |
|
|
|
Index of refraction for ray tracing materials. |
Visual Material and Visual Material Instance#
A visual material is defined using the VisualMaterialCfg class. It is a material template that can create multiple instances with independent parameters.
A VisualMaterialInst can come from either of two sources:
create_instance()creates a new dexsim material instance from an EmbodiChain material template.from_existing()wraps a dexsim material instance parsed from an asset without copying or replacing it.
When a rigid object, articulation, soft object, or cloth object is constructed, EmbodiChain inspects its render body and automatically wraps an existing material. If no material exists, list-based assets return None, while an articulation omits that link from its material dictionary. For render bodies with multiple mesh segments, this compatibility API exposes the first valid material as the representative instance. Rigid objects and articulations additionally provide get_existing_visual_material() for per-segment access.
get_existing_visual_material() retains every original dexsim MaterialInst and creates a separate working MaterialInst from the first segment’s existing material template. Randomizers can therefore modify and attach the working instance while keeping the original instance available for restoration. This creates an instance, not a new VisualMaterial template.
For batched simulation, set_visual_material() creates an instance per environment by default. Pass shared=True to reuse one instance across environments.
Rigid objects, articulations, soft objects, and cloth objects retain their construction-time per-segment material assignments. Call restore_visual_material() explicitly to restore them; each asset’s reset() method performs the same restoration for the selected environments.
Code#
# Create a visual material with base color white and low roughness.
mat: VisualMaterial = sim.create_visual_material(
cfg=VisualMaterialCfg(
base_color=[1.0, 1.0, 1.0, 1.0],
roughness=0.05,
)
)
# Set the material to a rigid object.
object: RigidObject
object.set_visual_material(mat)
# Get the material registered for each environment.
mat_inst: list[VisualMaterialInst | None] = object.get_visual_material_inst()
# Modify one instance without changing the other environments.
if mat_inst[0] is not None:
mat_inst[0].set_base_color([1.0, 0.0, 0.0, 1.0])
To modify a material already contained in a loaded asset, no replacement call is needed:
object: RigidObject = sim.add_rigid_object(cfg=object_cfg)
asset_inst = object.get_visual_material_inst()[0]
if asset_inst is not None:
asset_inst.set_roughness(0.4)
VisualMaterialInst.set_base_color_texture() accepts a file path, a tensor, or a pre-created dexsim Texture. Reusing a pre-created texture avoids uploading the same image on every material update.
Objects#
All objects inherit from ObjectBaseCfg, which provides common properties.
Base Properties
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Unique identifier. |
|
|
|
Position of the root in simulation world frame. |
|
|
|
Euler angles (in degrees) of the root. |
|
|
|
4x4 transformation matrix (overrides |
Rigid Object#
Configured via RigidObjectCfg.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Shape configuration (e.g., Mesh, Box). |
|
|
|
Physical attributes. |
|
|
|
“dynamic”, “kinematic”, or “static”. |
|
|
|
Max convex hulls for decomposition (CoACD). |
|
|
|
Resolution for signed distance field. In most cases, a resolution of around 250 produces good results; resolutions exceeding 1000 are rarely necessary. |
|
|
|
Scale of the rigid body. |
Rigid Body Attributes#
The RigidBodyAttributesCfg class defines physical properties for rigid bodies.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Mass in kg. Set to 0 to use density. |
|
|
|
Density in kg/m^3. |
|
|
|
Angular damping coefficient. |
|
|
|
Linear damping coefficient. |
|
|
|
Maximum depenetration velocity. |
|
|
|
Threshold below which the body can go to sleep. |
|
|
|
Enable continuous collision detection. |
|
|
|
Contact offset for collision detection. |
|
|
|
Rest offset for collision detection. |
|
|
|
Enable collision for the rigid body. |
|
|
|
Restitution (bounciness) coefficient. |
|
|
|
Dynamic friction coefficient. |
|
|
|
Static friction coefficient. |
For Rigid Object tutorial, please refer to the Create Scene tutorial.
Rigid Object Groups#
RigidObjectGroupCfg allows initializing multiple rigid objects, potentially from a folder.
Lights#
Configured via LightCfg. Supports six light types matching the dexsim rendering backend.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Light type: |
|
|
|
RGB color of the light source. |
|
|
|
Intensity of the light source in watts/m^2. |
|
|
|
Whether the light casts shadows. |
|
|
|
Falloff radius (only for |
|
|
|
Direction vector for directional types ( |
|
|
|
Inner cone angle in degrees (only for |
|
|
|
Outer cone angle in degrees (only for |
|
|
|
Width of rectangular area light (only for |
|
|
|
Height of rectangular area light (only for |
|
|
|
Asset path for mesh-based emissive lights (only for |
.. attention::
"sun" and "direction" are global scene lights (infinite-distance directional light
sources). They are created as a single instance on the root environment, not batched per
environment. Use :meth:Light.set_direction instead of :meth:Light.set_local_pose for
these types.