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

MJX unstable collision for partially overlapping boxes with a free joint #2356

Open
2 tasks done
Andrew-Luo1 opened this issue Jan 13, 2025 · 1 comment
Open
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@Andrew-Luo1
Copy link
Contributor

Intro

Hi!

I'm working on writing RL environments using Mujoco MJX.

My setup

mujoco==3.2.6
mujoco-mjx==3.2.6
ubuntu 22.04
RTX4090, Intel processor
Python 3.10.16

I've also reproduced this issue on a Colab instance.

What's happening? What did you expect?

When I simulate a peg laying on top of a small cube, the peg jitters without any external perturbances. When I expand the cube so it fully supports the peg, this stops. This issue seems to be MJX-specific.

Steps for reproduction

  1. Load the model below.
  2. Run the code below.
  3. See jittering behaviour.
funny_cube.mp4

Minimal model for reproduction

<mujoco>
    <worldbody>
        <light name="top" pos="0 0 1"/>
        <geom type="box" size="0.025 0.025 0.025" pos="0 0 0.025"/>
        <body name="peg" pos="0 0 0.06">
            <freejoint/>
            <geom name="peg" size="0.048 0.01 0.01" type="box" rgba="0.8 0.6 0.4 1" condim="6"/>
        </body>
    </worldbody>
</mujoco>

Code required for reproduction

import mujoco
from mujoco import mjx

mj_model = mujoco.MjModel.from_xml_string(xml)
mj_data = mujoco.MjData(mj_model)
renderer = mujoco.Renderer(mj_model)

mjx_model = mjx.put_model(mj_model)
mjx_data = mjx.put_data(mj_model, mj_data)

jit_step = jax.jit(mjx.step)

duration = 3.8  # (seconds)
framerate = 60  # (Hz)

frames = []
while mjx_data.time < duration:
  mjx_data = jit_step(mjx_model, mjx_data)
  if len(frames) < mjx_data.time * framerate:
    mj_data = mjx.get_data(mj_model, mjx_data)
    renderer.update_scene(mj_data)
    pixels = renderer.render()
    frames.append(pixels)

media.show_video(frames, fps=framerate)

Confirmations

@Andrew-Luo1 Andrew-Luo1 added the bug Something isn't working label Jan 13, 2025
@btaba btaba self-assigned this Jan 13, 2025
@btaba
Copy link
Collaborator

btaba commented Jan 13, 2025

Thanks for the bug report! Confirmed locally, looks like we need to bias toward face contacts rather than edge when the two are nearly equivalent ways to separate the two objects. Will push a fix soon-ish

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