Cloth Object#
SurfaceDeformableObject represents batched Newton cloth
particle sets. Cloth requires the
Newton backend on CUDA and a particle-capable solver.
See Newton Physics Backend for solver selection, mixed rigid/deformable scene limitations, and the requirement to declare deformables before preparation.
Configuration#
Use SurfaceDeformableObjectCfg with physical parameters grouped
in attrs, following the rigid-object configuration convention.
Field |
Default |
Meaning |
|---|---|---|
|
|
Surface density in kg/m². |
|
|
Triangle elastic stiffness, area stiffness, and damping. |
|
|
Aerodynamic drag and lift. |
|
|
Bending stiffness and damping. |
|
|
Create explicit mesh-edge springs. |
|
|
Spring stiffness and damping. |
|
|
Particle radius; inherit solver default when omitted. |
|
|
Simulation source mesh and default render mesh. |
|
|
Optional independently indexed render mesh. |
The seven surface_props coefficients use
SurfaceElementPropertiesCfg. None preserves Newton’s
cloth defaults. Cloth uses its source triangle mesh directly and does not
require volume voxelization.
from embodichain.lab.sim.cfg import (
SurfaceElementPropertiesCfg,
SurfaceDeformableObjectCfg,
SurfaceDeformablePhysicsCfg,
)
from embodichain.lab.sim.shapes import MeshCfg
cfg = SurfaceDeformableObjectCfg(
uid="cloth",
shape=MeshCfg(fpath="cloth.obj"),
attrs=SurfaceDeformablePhysicsCfg(
density=0.2,
surface_props=SurfaceElementPropertiesCfg(
tri_ke=1000.0, tri_ka=1000.0, edge_ke=0.001,
),
),
)
Add this configuration through sim.add_deformable_object(cfg) and call
sim.prepare() before accessing cloth.data. For a runnable example, see
Cloth Body Simulation.
Cloth Object Class#
Nodal State#
After sim.prepare(), read simulation nodes through object.data. Each state
property returns an independent tensor snapshot.
Property |
Shape |
Description |
|---|---|---|
|
|
Current simulation-node positions in world coordinates. |
|
|
Current simulation-node velocities in world coordinates. |
|
|
Positions and velocities captured at Spawn binding. |
N is the number of instances; V is data.n_nodes. Render vertices are
separate and are read through get_surface_vertices().
# Example: Accessing vertex data
vert_position = cloth_object.data.nodal_pos_w
print(f"vertices positions: {vert_position}")
vert_velocity = cloth_object.data.nodal_vel_w
print(f"Vertex Velocities: {vert_velocity}")
Visual Material#
When a cloth object is constructed, EmbodiChain wraps the first valid material already attached to each environment’s render body. The original dexsim material instance is retained.
materials = cloth_object.get_visual_material_inst()
if materials[0] is not None:
materials[0].set_roughness(0.8)
set_visual_material(mat, env_ids=None, shared=False) assigns a replacement material, while restore_visual_material(env_ids=None) restores the original per-segment assignments. get_visual_material_inst(env_ids=None) returns one representative VisualMaterialInst | None per selected environment. reset() restores the original material before resetting the selected cloth bodies.
Pose Management#
You can set the global pose of a cloth object (which transforms all its vertices), but getting a single “pose” from a deformed surface object is not supported.
Method |
Description |
|---|---|
|
Sets the pose of the object by transforming all vertices. |
|
Not Supported. Raises |
# Reset or Move the Cloth Object
target_pose = torch.tensor([[0, 0, 1.0, 0, 0, 0, 1]], device=device) # (x, y, z, qx, qy, qz, qw)
cloth_object.set_local_pose(target_pose)
# Important: Step simulation to apply changes
sim.update()