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

Inconsistent Behavior qLD Mujoco & MJX #2508

Open
2 tasks done
MoritzSchwerdt opened this issue Mar 17, 2025 · 1 comment
Open
2 tasks done

Inconsistent Behavior qLD Mujoco & MJX #2508

MoritzSchwerdt opened this issue Mar 17, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@MoritzSchwerdt
Copy link

Intro

Hi!

I am a undergrad student at Goethe University & TU Darmstadt, I use MuJoCo for my research on Physics 3D BinPacking

My setup

Mujoco 3..3.0

What's happening? What did you expect?

Mujoco and MJX seem to handle qLD differently in stepping, leading to Value Error when retrieving mj_data like

"mj_data = mjx.get_data(mj_model, mjx_data)"

Steps for reproduction

  1. Load the model below.
  2. Run the code below.
  3. Observe Value Error in qLD after mjx.step

Minimal model for reproduction

  1. Define Mujoco with 15+ Boxes

xml = " "
for i in range(15):
xml += f"""




"""
xml += ""

  1. Load into Mujoco & MJX
    mj_model = mujoco.MjModel.from_xml_string(xml)
    mj_data = mujoco.MjData(mj_model)

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

  1. Step & observe Error

stepped_mjx_data = mjx.step(mjx_model, mjx_data)
mjx_data.qLD.shape

stepped_mj_data = mjx.get_data(mj_model, stepped_mjx_data)

Leading to:
ValueError: Input field qLD has shape (315,), but output has shape (90,)

Code required for reproduction

import mujoco
from mujoco import mjx

xml = "<mujoco> <worldbody>"
for i in range(15):
  xml += f"""
    <body name="box{i}">
      <joint name="box_{i}" type="free"/>
      <geom name="box_geom_{i}" type="box" size=".2 .2 .2" rgba="1 0 0 1" condim="3"/>
    </body>
  """
xml += "</worldbody></mujoco>"

# Make model, data
mj_model = mujoco.MjModel.from_xml_string(xml)
mj_data = mujoco.MjData(mj_model)

# put onto GPU
mjx_model = mjx.put_model(mj_model)
mjx_data = mjx.put_data(mj_model, mj_data)

# Step Model
stepped_mjx_data = mjx.step(mjx_model, mjx_data)

# Obtain Updated Data
mj_data = mjx.get_data(mj_model, stepped_mjx_data)

Confirmations

@MoritzSchwerdt MoritzSchwerdt added the bug Something isn't working label Mar 17, 2025
@yuvaltassa
Copy link
Collaborator

Nice catch.
This will be fixed shortly.

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