Search code examples
drake

The hydroelastic contact does not give expected contact surface


I have been using Hydroelastic Contact to simulate a peg-in-hole task. The simulation scene is like enter image description here

The blue peg is a compliant hydroelastic cylinder and the hole is a rigid hydroelastic mesh. The wire frame view of the hole mesh is enter image description here

When I push the peg down and apply an external force on it (downward force at the left end of the peg, pointed into the hole's surface), I find that the peg tilted unexpectly. enter image description here

enter image description here

It can be seen that the left part of the peg's tip penetrated into the surface of the hole and thus the tilt angle. Since the peg is a compliant body, penetraction is expected. However, what confuses me is the tilt angle and the contact surface. What I expect is that the contact surface should contain all areas of the penetration part of the peg, however, what I really get is just a strip. The illustration is shown in the figure below. The left shows the contact surface that I really get and the right shows the contact surface that I expect. enter image description here Since the contact between the hole's surface and the peg's end is surface-to-surface, I would expect that after contact between the hole's surface and the peg's end, the peg will be in norminal position (vertically oriented) and the tilt angle of the peg will be small despite of the external applied force. However, since the contact surface is a strip, the peg can rotate along that strip and the tilt angle can be large. At first I suspect that the reason is that the triangles of my hole's mesh are sparse. However, after I add more triangles to my hole's surface, I get nealy the same result. Increasing the hydroelastic modulus also does not help. I have also tried to add small collision sphere at the peg's tip like the point contact case. However, I get

RuntimeError: Bad tetrahedron. Cannot compute gradient.

What modifications should I make to get the correct contact surface? Or are there workaround ways that can make the penetration tilt angle of the peg small after surface-to-surface contact?

I have run the ball and plate hydroelastic contact example and find that the contact between the plate and the plane seems do not have this issue.

Thank you very much for your answer!


Solution

  • (EDIT): resolution_hint is too SMALL (~1e-17) triggering a bug in Drake. Here is the result with resolution_hint = peg_circumference / 20:

    hydroelastic peg in hole

    (Original Answer):

    Do you have a public branch that I can use to reproduce the error?

    My first suspicion is that your resolution_hint is too large. All primitive shapes used in hydroelastics are given an internal mesh representation and this parameter controls the coarseness of the mesh. With a very large resolution hint, the approximation of the cylinder can end up being a box. Try a smaller resolution hint.

    If that doesn't work:

    Are you using a cylinder primitive for your peg or a mesh with the drake:declare_convex tag? My other suspicion is that the orientation of some of the faces in either the peg mesh or the hole mesh are reversed.

    We rely on an expectation that meshes used as hydroelastic geometries have consistent and outwardly orientated face normals.