ipc-sim / rigid-ipc

Robust, intersection-free, simulations of rigid bodies.
https://ipc-sim.github.io/rigid-ipc
MIT License
142 stars 18 forks source link

How to set coefficient_restitution ? Can't get ball to bounce. #33

Closed alecjacobson closed 5 months ago

alecjacobson commented 5 months ago

I've edited the fixtures/3D/examples/example.json to use a sphere

{
    "scene_type": "distance_barrier_rb_problem",
    "max_iterations": 1000,
    "timestep": 0.01,
    "rigid_body_problem": {
        "coefficient_restitution": 1,
        "gravity": [0, -9.8, 0],
        "rigid_bodies": [{
            "mesh": "sphere.obj",
            "position": [0, 3, 0],
            "rotation": [30, 135, 0],
            "linear_velocity": [0, 0, 0],
            "angular_velocity": [0, 0, 0]
        }, {
            "mesh": "plane.obj",
            "is_dof_fixed": [true, true, true, true, true, true],
            "position": [0, -1, 0]
        }]
    }
}

I changed coefficient_restitution = 1 hoping that this would get the sphere to bounce off the ground plane but it's still sticky:

https://github.com/ipc-sim/rigid-ipc/assets/2241689/be530834-38f1-42bc-b0f8-1e0d3b9db6f8

I don't think I understand how to set coefficient_restitution. All of the 3D examples set it to -1. But I thought this value was setting the coefficient of restitution which is a non-negative quantity.

How should I adjust my .json to see a bouncing ball?

zfergus commented 5 months ago

Hi Alec, actually the coefficient_restitution is broken as in our paper we say: "Our current formulation does not provide direct control for restitution." The parameter was left in from a legacy attempt that was only implemented in 2D (I don't think it is even compatible with IPC). I have found the implicit Euler time integrator dampens out the motion so that bouncing doesn't happen at "large" time step sizes (e.g., the 0.01 you are using). The alternative to reducing timestep would be to switch time integrators, but I remember we had difficulty implementing other integrators that were reliably stable.

alecjacobson commented 5 months ago

Thanks. I'm finding exactly the same issues.

On Tue, May 28, 2024, 1:59 PM Zachary Ferguson @.***> wrote:

Closed #33 https://github.com/ipc-sim/rigid-ipc/issues/33 as not planned.

— Reply to this email directly, view it on GitHub https://github.com/ipc-sim/rigid-ipc/issues/33#event-12961405728, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARDJGNHMFUGPZGRXOEKQADZETAXDAVCNFSM6AAAAABII6N53WVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSHE3DCNBQGU3TEOA . You are receiving this because you authored the thread.Message ID: @.***>