Hi, I am trying to simulate the stability of some cardboard boxes like they would be placed in a pallet. In order to make it as realistic as possible I want to treat them as deformable bodys.
To implement the deformable material I am using this:
self.deformable_cardboard_material = DeformableMaterial(
prim_path="/World/physics_material/deformable_cardboard_material", # path to the material prim to create
dynamic_friction=0.4,
youngs_modulus=1e6,
poissons_ratio=0.4,
elasticity_damping=0.0,
damping_scale=0.0,
)
To create the boxes objects I have the following code:
for b in boxes_list:
position = [b['position'][0] / self.scale, b['position'][1] / self.scale, b['position'][2] / self.scale]
scale = [b['dimensions'][0] / self.scale, b['dimensions'][1] / self.scale, b['dimensions'][2] / self.scale]
box_path = f"/World/box_{len(self.boxes)}"
boxGeom = UsdGeom.Xform.Define(self.stage, box_path)
boxPrim = self.stage.GetPrimAtPath(box_path)
xforms_utils.reset_and_set_xform_ops(
prim=boxPrim,
translation=Gf.Vec3f(position[0], position[1], position[2]),
orientation=Gf.Rotation(Gf.Vec3d([1, 0, 0]), 0).GetQuat(),
scale=Gf.Vec3d(scale[0], scale[1], scale[2])
)
skin_mesh = UsdGeom.Mesh.Define(self.stage, box_path)
tri_points, tri_indices = deformableMeshUtils.createTriangleMeshCube(8)
skin_mesh.GetPointsAttr().Set(tri_points)
skin_mesh.GetFaceVertexIndicesAttr().Set(tri_indices)
skin_mesh.GetFaceVertexCountsAttr().Set([3] * (len(tri_indices) // 3))
physicsUtils.setup_transform_as_scale_orient_translate(skin_mesh)
physicsUtils.set_or_add_translate_op(skin_mesh, (position[0], position[1], position[2]))
physicsUtils.set_or_add_orient_op(skin_mesh, Gf.Rotation(Gf.Vec3d([1, 0, 0]), 0).GetQuat())
massAPI = UsdPhysics.MassAPI.Apply(boxPrim)
massAPI.CreateMassAttr().Set(b['weight'])
material_path = f"/World/Materials/MaterialBox_{len(self.boxes)}"
material = UsdShade.Material.Define(self.stage, material_path)
shader = UsdShade.Shader.Define(self.stage, material_path + "/Shader")
shader.CreateIdAttr("UsdPreviewSurface")
shader.CreateInput("diffuseColor", Sdf.ValueTypeNames.Color3f).Set(Gf.Vec3f(b['color'][0], b['color'][1], b['color'][2]))
material.CreateSurfaceOutput().ConnectToSource(shader.ConnectableAPI(), "surface")
UsdShade.MaterialBindingAPI(boxPrim).Bind(material)
physxCollisionAPI = PhysxSchema.PhysxCollisionAPI.Apply(boxPrim)
physxCollisionAPI.CreateContactOffsetAttr(0.05)
physxCollisionAPI.CreateRestOffsetAttr(0.03)
self.boxes.append(DeformablePrim(
name=box_path,
prim_path=box_path,
deformable_material=self.deformable_cardboard_material,
vertex_velocity_damping=0.0,
sleep_damping=1.0,
sleep_threshold=0.05,
settling_threshold=0.1,
self_collision=False,
self_collision_filter_distance=0.05,
solver_position_iteration_count=50,
kinematic_enabled=False,
simulation_hexahedral_resolution=8, # 4 ... 64
collision_simplification=False,
))
The simulation is running but the results don’t seem to be realistic. It is like the contact between the boxes generates a force too strong sometimes.
I have tried changing the values of the material parameters and also the ones that affect the deformable object (mesh resolution …) but it is still not realistic.
Does anyone know how can I improve the quality of the results?
Thanks!