google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
7.93k stars 795 forks source link

Is it possible to generate large transverse friction forces for soft contacts? #1649

Closed acrylic-origami closed 1 month ago

acrylic-origami commented 4 months ago

Hi,

I'm an engineer trying to use MuJoCo for humanoid robotic control.

I'm trying to model grass interactions in MuJoCo, specifically its anisotropic drag against the robot's feet (where it is springy and fairly lossless in the normal direction and frictional in transverse directions). It sounds like friction should be perfect for this. My impression was that I could make the contact soft so the robot could sink into the grass geom, then use large friction coefficients to create transverse drag in spite of the small reaction force.

However, I think I must be misunderstanding the friction model. Symptomatically, when using larger friction values, I don't seem to get much damping, but instead I have noticed the contact seems to get much softer.

For example, here's a box on a pendulum penetrating a relatively soft, undamped plane:

<mujoco>
    <visual>
        <headlight ambient="1 1 1"/>
    </visual>
    <worldbody>
        <geom type="plane" rgba="0 1 0 0.3" size="1 1 1" condim="3" solref="-100 -0.001" friction="0.1" priority="2" solimp="0.9 0.99 0.06" pos="0 0 -0.9" /><!-- The plane has higher priority -->
            <body name="b1">
                <joint type="hinge" name="j1" axis="0 1 0" />
                <geom name="g1" type="box" size="0.1 0.1 0.1" pos="1 0 0" mass="1" />
            </body>
    </worldbody>
</mujoco>

When friction=0.1, I get a springy undamped response as expected:

https://github.com/google-deepmind/mujoco/assets/13635288/61956114-0c1f-4c1d-b7c0-0ffb9618731b

However, when friction=1.0, the stiffness drops out enough for the box to swing to the other side, and I don't see any additional losses:

https://github.com/google-deepmind/mujoco/assets/13635288/aa10f2d6-2c27-45bf-b2d1-321ef5f38923

Higher values of friction don't do much, and I worry that I'm heading towards instabilities. Here's friction=10 for completeness:

https://github.com/google-deepmind/mujoco/assets/13635288/9c041ca8-3b53-4e2d-81ff-b2a1557520fb

These are all simulated with pyramidal cones, but elliptical cones look much the same.

Is this expected behavior and am I missing something about MuJoCo's slip/friction model? Is there a way to achieve anisotropic dynamic slipping friction for a soft geom (i.e. without resorting to isotropic solref damping)?

acrylic-origami commented 4 months ago

It took a few more reads of the Computation chapter, but I think I'm starting to see where I misunderstood the friction and soft contact models. It's still unclear to me how to generate large transverse drag using only contacts, so I've narrowed the issue title.

I do also appreciate some corrections if I'm still missing some parts of the picture. As I understand it, my mistake was that I thought that dynamic friction was always proportional to the normal force of the contact, and this normal force was defined by the mass-spring-damper system. That assumed:

  1. The transverse (frictional) force was given by: $f{trans}=-\hat{v}\mu f{\bot}$, and
  2. The normal force was defined as $f\bot := -bJ\bot v_\bot - kr$, where
    • $r$ is the scalar, purely normal constraint violation for elliptic cones, and
    • $J_\bot$ is the Jacobian of the normal contact component

I now understand that this is wrong, and instead, for small $R$, the constraint dynamics approach $a{ref}$ up to the friction cone, where $a{ref} := -bJv - kr$ is defined in all directions, and since $b$ and $r$ are scalars for every contact, the target drag is isotropic. The upshot is that friction can only limit transverse drag components relative to the drag in the normal direction for the same velocity.

It seems the simulations showed just that:

My understanding is that most use cases have hard and dissipative surfaces with very little penetration, so that slip involves being on the friction cone almost all the time, and friction behaves intuitively, being mostly proportional to $\mu$.

Meanwhile, in cases with soft yet grippy surfaces, the better intuition is that the penetrating object "sticks" to the soft surface and encounters the drag as it retracts and pulls the surface of the soft object back to equilibrium.

My issue with isotropic drag is that every step the robot takes will incur large energy losses, even if the robot lifts the foot directly upwards. I'm a bit surprised that I haven't found any other issues about energy losses from rebounding drag for soft surfaces; does using flex/flexcomp avoid this?