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

contact/exclude appears to ignore links which are rigidly attached to the worldbody #2444

Open
2 tasks done
rdeits-bd opened this issue Feb 21, 2025 · 6 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@rdeits-bd
Copy link

Intro

I'm a researcher at Boston Dynamics.

My setup

I'm using the latest release 3.2.7 for linux x86_64.

What's happening? What did you expect?

Here's a minimal model that illustrates the problem. First, a working version:

<mujoco model="minimal-repro">
  <worldbody>
    <body name="body_1">
      <freejoint/>
      <geom type="sphere" size="0.5" mass="1"/>
      <body name="body_2" pos="0.25 0 0">
        <joint type="slide" axis="1 0 0"/>
        <geom type="sphere" size="0.5" mass="0.5"/>
        <body name="body_3" pos="0.25 0 0">
          <joint type="slide" axis="1 0 0"/>
          <geom type="sphere" size="0.5" mass="0.5"/>
        </body>
      </body>
    </body>
  </worldbody>
  <contact>
    <exclude body1="body_1" body2="body_3"/>
  </contact>
</mujoco>

This model consists of three spheres, each of which overlaps with the others. Collision between body_1 and body_2 is ignored because they are direct ancestors in the kinematic tree, likewise body_2 and body_3. I have manually excluded collision between body_1 and body_3 with a contact/exclude group. This all works correctly: When I run ./bin/simulate minimal-repro.xml, the three spheres fall together.

However, if I remove the freejoint, like so:

<mujoco model="minimal-repro">
  <worldbody>
    <body name="body_1">
      <geom type="sphere" size="0.5" mass="1"/>
      <body name="body_2" pos="0.25 0 0">
        <joint type="slide" axis="1 0 0"/>
        <geom type="sphere" size="0.5" mass="0.5"/>
        <body name="body_3" pos="0.25 0 0">
          <joint type="slide" axis="1 0 0"/>
          <geom type="sphere" size="0.5" mass="0.5"/>
        </body>
      </body>
    </body>
  </worldbody>
  <contact>
    <exclude body1="body_1" body2="body_3"/>
  </contact>
</mujoco>

then body_3 immediately shoots away, presumably due to the collision with body_1.

I have also tried <compiler fusestatic="false"/> (even though I expect that to be the default), and it had no effect.

Steps for reproduction

  1. Load the model below with the ./bin/simulate from the latest Mujoco release (3.2.7)
  2. Observe that the sphere flies away.

Minimal model for reproduction

<mujoco model="minimal-repro">
  <worldbody>
    <body name="body_1">
      <geom type="sphere" size="0.5" mass="1"/>
      <body name="body_2" pos="0.25 0 0">
        <joint type="slide" axis="1 0 0"/>
        <geom type="sphere" size="0.5" mass="0.5"/>
        <body name="body_3" pos="0.25 0 0">
          <joint type="slide" axis="1 0 0"/>
          <geom type="sphere" size="0.5" mass="0.5"/>
        </body>
      </body>
    </body>
  </worldbody>
  <contact>
    <exclude body1="body_1" body2="body_3"/>
  </contact>
</mujoco>

Code required for reproduction

No response

Confirmations

@rdeits-bd rdeits-bd added the bug Something isn't working label Feb 21, 2025
@yuvaltassa
Copy link
Collaborator

Thanks!

Can you please try to use "world" as the excluded body and report what happens?

IIRC, bodies that are kinematically welded to the world are considered to be the world for collision purposes. If my suggestion above works then this is basically a documentation issue. If not, we will examine more carefully.

@yuvaltassa
Copy link
Collaborator

Mmmm this is technically documented but is rather hard to find. Assuming my diagnosis is correct, the exclude documetation should be clarified to explain that in cases of static descendants, it is the top ancestor body that should be excluded.

@rdeits-bd
Copy link
Author

Interestingly, setting world instead of body_1 actually results in yet another behavior -- now both the second and third spheres fly away:

<mujoco model="minimal-repro">
  <compiler fusestatic="false"/>
  <worldbody>
    <body name="body_1">
      <geom type="sphere" size="0.5" mass="1"/>
      <body name="body_2" pos="0.25 0 0">
        <joint type="slide" axis="1 0 0"/>
        <geom type="sphere" size="0.5" mass="0.5"/>
        <body name="body_3" pos="0.25 0 0">
          <joint type="slide" axis="1 0 0"/>
          <geom type="sphere" size="0.5" mass="0.5"/>
        </body>
      </body>
    </body>
  </worldbody>
  <contact>
    <exclude body1="world" body2="body_3"/>
  </contact>
</mujoco>

Image

vs what I got with body1="body_1":

Image

@yuvaltassa
Copy link
Collaborator

Thanks, I'll investigate.

@yuvaltassa
Copy link
Collaborator

Okay I finally took a look.

  1. My recommendation was wrong, you can and should use the names of static bodies in exclude.
  2. Your diagnosis of what happens in your second example

Observe that the sphere flies away.

is incorrect, it is not body2 that flies away, but body3. It helps if you turn on body names in the visualizer.

Image

So as far as I can tell this is a user error and everything works as intended and documented.

Please let me know if I am mistaken. Closing for now.

@rdeits-bd
Copy link
Author

You're right, my mistake. In fact, this is almost word-for-word the "Surprising Collisions" section from the docs, which I hadn't found before now: https://mujoco.readthedocs.io/en/stable/overview.html#surprising-collisions

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

2 participants