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

Bug in box-sphere collider #2206

Open
2 tasks done
yuvaltassa opened this issue Nov 4, 2024 · 0 comments
Open
2 tasks done

Bug in box-sphere collider #2206

yuvaltassa opened this issue Nov 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@yuvaltassa
Copy link
Collaborator

yuvaltassa commented Nov 4, 2024

Intro

MuJoCo dev. Original bug report in #2199

My setup

n/a

What's happening? What did you expect?

The box-sphere collider returns correct contact positions, but the depth (contact.dist) is wrong after full penetration of the sphere into the box.

Steps for reproduction

Run the code below, get this plot

image

Minimal model for reproduction

See below.

Code required for reproduction

xml = """
<mujoco>
  <worldbody>
    <geom name="plane" pos="0 0 -.005" type="plane" size="0.5 0.5 0.01"/>-->
    <geom name="box"   type="box" pos = "0 0 -0.255" size="0.5 0.5 .25"  />
    <body>
      <freejoint/>
      <geom name="sphere" type="sphere" mass="1" size="0.005"/>
    </body>
  </worldbody>
</mujoco>
"""
model = mujoco.MjModel.from_xml_string(xml)
data = mujoco.MjData(model)

depth = np.linspace(-.01, -1e-6, 200)
contact = [[], []]
for z in depth:
  data.qpos[2] = z
  mujoco.mj_forward(model, data)
  for i in range(2):
    c = data.contact[i]
    condata = np.array((c.pos[2], c.dist))
    contact[i].append(condata)

plt.plot(depth, contact[0], label=['plane contact pos', 'plane contact depth']);
plt.plot(depth, contact[1], '--', label=['box contact pos', 'box contact depth']);
plt.xlabel('Penetration (m)');
plt.legend()

Confirmations

@yuvaltassa yuvaltassa added the bug Something isn't working label Nov 4, 2024
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

1 participant