Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative distance between non colliding geometries #1857

Open
cganuza opened this issue Jul 25, 2024 · 2 comments
Open

Negative distance between non colliding geometries #1857

cganuza opened this issue Jul 25, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@cganuza
Copy link

cganuza commented Jul 25, 2024

Hi,

I'm an engineer and I'm trying to use MuJoCo for collision detection.

At the beginning I experienced this behavior with our own geometries, but after looking more in depth I found the same output with two general MuJoCo geometries. The issue is that I found negative distances between bodies even though they are not in contact. when they are in a close distance you can see negative distance. Not only that the contact point it is not where I would expect it to be. As you can see in the screenshot bellow it seems it is facing the center of the disk instead of the surface.

I want to get the distance between the bodies. Am I missing some setting for this?

Here is a simplified model which explains my question:

I am using MuJoCo 3.2.0

XML
<mujoco>
  <option>
    <flag energy="disable" gravity="disable"/>
  </option>


  <worldbody>
    <light pos="0 0 1" mode="trackcom"/>
    <body name="0" pos="0 0 0">
      <joint name="up" type="slide" pos="0 0 0" axis="0 0 1" />
      <joint name="twist" type="hinge" pos="0 0 0" axis="0 0 1" />
      <geom type="capsule" size=".01" fromto="-.1 0 -0.05 -.1 0 0.05" rgba="1 1 0 1"/>
    </body>

    <body name="disk_muj" pos="0 0 0.1">
      <geom type="cylinder" size=".2" fromto="0 0 -0.005 0 0 0.005" rgba="1 1 0 1" margin="0.3" gap="0.3"/>
    </body>
    
  </worldbody>
</mujoco>

the python script (not including the xml model from above:

import mujoco
import mujoco.viewer

model = mujoco.MjModel.from_xml_string(model_xml)
data = mujoco.MjData(model)
mujoco.viewer.launch(model, data)

Here is a screenshot, illustrating my question, already with the initial conditions I have the issue:
image

@cganuza cganuza added the question Request for help or information label Jul 25, 2024
@yuvaltassa
Copy link
Collaborator

Yes, this is a bug we are working on fixing.

See caveat here

@yuvaltassa yuvaltassa added bug Something isn't working and removed question Request for help or information labels Jul 25, 2024
@cganuza
Copy link
Author

cganuza commented Jul 26, 2024

Thank you for the prompt response @yuvaltassa. Do you have a time line when this will be fixed?

For mesh geometries the only option now is to create SDF files? Does this change the way of interacting with mujoco? Do you have any example? And, is it easy to change a mesh file to SDF?

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants