mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

Leaking Contacts Through Convex Hulls

Open tudorjnu opened this issue 2 years ago • 5 comments

Hi,

I am trying to create an endovascular simulator for RL using MuJoCo. The aorta is decomposed into a series of convex hulls using V-HACD whereas a guidewire is represented as a rope. The idea is to push the guidewire through the aorta using translation and rotation.

The issue comes when the guidewire (rope) comes in contact with the convex hulls. If the guidewire collides between the hulls, it will penetrate the aorta (see images attached). Is there a way to prevent this from happening?

Thank you!

image-1

image-2

tudorjnu avatar Aug 12 '22 19:08 tudorjnu

Can you generate a tighter approximation with V-HACD?

kevinzakka avatar Aug 12 '22 20:08 kevinzakka

The simplest thing would be to overlap the geoms. Geoms belonging to the same body cannot collide with each other and can (and in your case should) overlap. A quick and dirty way to do this would be to add a margin to the existing one i.e. "inflate" them. This will have the disadvantage that it will narrow your "aorta" and that the visual geometry won't match the collision geometry, but it should prevent the penetration.

As a second stage you could recreate your decomposition or better yet, construct it procedurally with primitives rather than meshes.

yuvaltassa avatar Aug 12 '22 22:08 yuvaltassa

I have tried to play a bit with the parameters of V-HACD but it does not work as planned. For tiny objects with which I am working, the newer version seems to not work that well as it produces convex hulls with lower than the required volume for qhull. So I refactored obj2mjcf for V-HACD version 3.

The margin parameter seems to work quite well as it seems the guidewire does not penetrate the aorta anymore. I will try to make the geoms overlap so I can get a tighter approximation. Is there any parameter that can adjust this within V-HACD?

Thank you very much for the prompt answers!

tudorjnu avatar Aug 13 '22 14:08 tudorjnu

@tudorjnu, I have indeed noticed that v4 produces almost flat meshes at times which makes qhull complain. Have you tried giving this video a watch?

kevinzakka avatar Aug 13 '22 15:08 kevinzakka

@kevinzakka, yes, I watched the video but it doesn't solve the problem. And when I increase the number of the convex hulls enough to have the arteries accessible, most of the time I get a qhull error.

Here is my simplistic version of obj2mjcf using trimesh and V-HACD-3 (in case someone has similar issues). However, it uses STL (which might be helpful for people that use the earlier versions of gym and mujoco).

tudorjnu avatar Aug 13 '22 15:08 tudorjnu

Hi, I found this issue related to a problem I'm facing. I converted a cup model using V-HACD-4 and got an obj file containing a collection of 64 convex hulls. However, when I tried to import the converted file into the mujoco scene, it only showed one piece of the convex hulls. What is the right way to import the collection of convex hulls into mujoco?

tychen32 avatar Oct 20 '22 14:10 tychen32

Did you try @kevinzakka's obj2mjcf ?

yuvaltassa avatar Oct 20 '22 14:10 yuvaltassa

Thanks for the prompt answer! I tried obj2mjcf and was able to import the whole cup model. But it seems mujoco still creates a convex hull for the model and prevents anything from going into the cup. What should I do if I want the cup to behave like a real cup then?

tychen32 avatar Oct 20 '22 15:10 tychen32

I think I've figured it out using obj2mjcf with vhacd. Thank you!

tychen32 avatar Oct 21 '22 16:10 tychen32

@tychen32 Please feel free to raise an issue if you run into any future problems with obj2mjcf :)

kevinzakka avatar Oct 21 '22 23:10 kevinzakka