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

Shape mismatch in MJX's put_data function #2141

Open
2 tasks done
rustam-e opened this issue Oct 15, 2024 · 2 comments
Open
2 tasks done

Shape mismatch in MJX's put_data function #2141

rustam-e opened this issue Oct 15, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@rustam-e
Copy link

rustam-e commented Oct 15, 2024

Intro

Hi!

I am a masters student at Vrije Universiteit Amsterdam, I use MuJoCo for my research on Modular Robotics.

My setup

Currently, Mujoco - trying to convert existing Evolutionary Computing for modular robotics framework Revolve2 (https://github.com/ci-group/revolve2) from Mujoco to MJX 3.2.3

What's happening? What did you expect?

I am following the provided tutorial on https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/mjx/tutorial.ipynb#scrollTo=Jtz7j1PDOnw5 and convert currently working code running the mujoco.mj_step to run using MJX.

I get an error related efc_J:

Steps for reproduction

  1. checkout https://github.com/rustam-e/revolve2/tree/develop
  2. dependency installation - https://ci-group.github.io/revolve2/installation/index.html
  3. run the experiment with python examples/4_example_experiment_setups/4c_robot_bodybrain_ea-mjx/main.py

the only differences from a functional examples/4_example_experiment_setups/4c_robot_bodybrain_ea/main.py can be found in rustam-e/revolve2@30bfc7f

Minimal model for reproduction

the issue is consistent with all of the experiements we ran

Code required for reproduction

running any of the examples by changing
from:
from revolve2.simulators.mujoco_simulator import LocalSimulator

to:
from revolve2.simulators.mjx_simulator import LocalSimulator

would throw consistently the same error like:
ValueError: could not broadcast input array from shape (0,10) into shape (4,10)

the only diference across examples being the second dimension

Confirmations

@rustam-e rustam-e added the bug Something isn't working label Oct 15, 2024
@rustam-e rustam-e changed the title Shape mismatch in put_data function Shape mismatch in MJX's put_data function Oct 15, 2024
@rustam-e
Copy link
Author

The issue seems to be due to the fact the the Mujoco did not instantiate efc_J property of the model, but running the mj_step once before the put_data call seems to have resolved the issue

@yuvaltassa yuvaltassa reopened this Oct 17, 2024
@yuvaltassa
Copy link
Collaborator

It's good that you found the solution, but put_data should either handle this situation (being called before any arena allocations) gracefully or, if that's not possible, give the user an informative error.

That, I think, is a bug. WDYT @erikfrey ?

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