Simulate cardboard boxes

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!

@alexam98 Stacking of deformables is certainly a pretty hard usecase, espececially since the deformable bodies don’t support static friction. Also modeling thin objects like carboard seems rather tricky. It’s hard to tell what goes exactly wrong in your case. Do you have a video, or a full stage USD file that we could load to see what’s going on?

Cheers,
Simon

Hi Simon, this is an example of the behavior of the boxes. I have tested the same scenario with rigid bodies and everything was stable. It seems that the objects are too deformable, even with parameters for rigid bodies (higher value for young modulus …).

IsaacSim2023.1.1-NewStage_2024-04-1015-26-41-ezgif.com-video-to-gif-converter

The only way I could achieve a deformable with some rigidity was with a small Simulation Mesh Resolution (3 - 5)

Thanks for the advice! I have tried it with a value of 4 and still was similar. I also tried changing the solver position iteration count to small and high values, but I did not succeed.

Thanks for the video! Yes, I don’t think our deformables are ready for stable stacking yet. At the very least we would need static friction support. Regarding stiffness, we do have some improvements in the pipeline.

Cheers,
Simon

Thanks for your response! Do you know when will these improvements be ready? I know that this is hard to tell but just to have an idea of how far we are from the possibility of simulating this scenario.

Thanks!!

I can’t promise anything obviously, but if all goes according to plan it should be in the coming months.

Cheers,
Simon