Soft Object#
The SoftObject class represents deformable entities (e.g., cloth, sponges, soft robotics) in EmbodiChain. Unlike rigid bodies, soft objects are defined by vertices and meshes rather than a single rigid pose.
Configuration#
Configured via SoftObjectCfg.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Voxelization attributes. |
|
|
|
Physical attributes. |
|
|
|
Mesh configuration. |
Soft Body Attributes#
Soft bodies require both voxelization and physical attributes.
Voxel Attributes (SoftbodyVoxelAttributesCfg)
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Resolution to remesh the softbody mesh before building physics collision mesh. |
|
|
|
Simplify mesh faces to target value. |
|
|
|
Resolution to build simulation voxelize textra mesh. |
|
|
|
Whether to output the simulation mesh as an obj file for debugging. |
Physical Attributes (SoftbodyPhysicalAttributesCfg)
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Young’s modulus (higher = stiffer). |
|
|
|
Poisson’s ratio (higher = closer to incompressible). |
|
|
|
Dynamic friction coefficient. |
|
|
|
Elasticity damping factor. |
|
|
|
Material constitutive model. |
|
|
|
If True, (partially) kinematic behavior is enabled. |
|
|
|
Enable continuous collision detection. |
|
|
|
Enable self-collision handling. |
|
|
|
Total mass. If negative, density is used. |
|
|
|
Material density in kg/m^3. |
For Soft Object tutorial, please refer to the Soft Body Simulation.
Setup & Initialization#
import torch
from embodichain.lab.sim import SimulationManager, SimulationManagerCfg
from embodichain.lab.sim.objects import SoftObject, SoftObjectCfg
# 1. Initialize Simulation
device = "cuda" if torch.cuda.is_available() else "cpu"
sim_cfg = SimulationManagerCfg(sim_device=device)
sim = SimulationManager(sim_config=sim_cfg)
# 2. Configure Soft Object
soft_cfg = SoftObjectCfg(
fpath="assets/objects/sponge.msh", # Example asset path
init_pos=(0, 0, 0.5),
init_rot=(0, 0, 0)
)
# 3. Spawn Soft Object
# Note: Assuming the method in SimulationManager is 'add_soft_object'
soft_object: SoftObject = sim.add_soft_object(cfg=soft_cfg)
# 4. Initialize Physics
sim.reset_objects_state()
Soft Object Class#
Vertex Data (Observation)#
For soft objects, the state is represented by the positions and velocities of its vertices, rather than a single root pose.
Method |
Return Shape |
Description |
|---|---|---|
|
|
Current positions of collision mesh vertices. |
|
|
Current positions of simulation mesh vertices (nodes). |
|
|
Current velocities of simulation vertices. |
|
|
Rest (initial) positions of collision vertices. |
|
|
Rest (initial) positions of simulation vertices. |
Note: N is the number of environments/instances, V_col is the number of collision vertices, and V_sim is the number of simulation vertices.
# Example: Accessing vertex data
sim_verts = soft_object.get_current_sim_vertices()
print(f"Simulation Vertices Shape: {sim_verts.shape}")
velocities = soft_object.get_current_sim_vertex_velocities()
print(f"Vertex Velocities: {velocities}")
Pose Management#
You can set the global pose of a soft object (which transforms all its vertices), but getting a single “pose” from a deformed object is not supported.
Method |
Description |
|---|---|
|
Sets the pose of the object by transforming all vertices. |
|
Not Supported. Raises |
# Reset or Move the Soft Object
target_pose = torch.tensor([[0, 0, 1.0, 1, 0, 0, 0]], device=device) # (x, y, z, qw, qx, qy, qz)
soft_object.set_local_pose(target_pose)
# Important: Step simulation to apply changes
sim.update()