google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
8.25k stars 823 forks source link

`MjSpec.copy()`: Unable to convert function return value to a Python type! #2209

Closed hartikainen closed 2 weeks ago

hartikainen commented 2 weeks ago

Intro

Hi!

I am a MuJoCo user working on manipulation.

My setup

MuJoCo:

$ python -c "import mujoco; print(mujoco.__version__)"
3.2.4

What's happening? What did you expect?

In specs_test.py:

  def test_copy_spec(self):
    spec_0 = mujoco.MjSpec()
    body_0 = spec_0.worldbody.add_body(pos=[1, 2, 3])
    spec_0.compile()
    spec_1 = spec_0.copy()
    body_1 = spec_1.worldbody.first_body()
    np.testing.assert_array_equal(body_1.pos, body_0.pos)
python -m unittest ./python/mujoco/specs_test.py -k "test_copy_spec"
E
======================================================================
ERROR: test_copy_spec (python.mujoco.specs_test.SpecsTest.test_copy_spec)
python.mujoco.specs_test.SpecsTest.test_copy_spec
----------------------------------------------------------------------
TypeError: Unregistered type : mjSpec_

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "mujoco/python/mujoco/specs_test.py", line 898, in test_copy_spec
    spec_1 = spec_0.copy()
             ^^^^^^^^^^^^^
TypeError: Unable to convert function return value to a Python type! The signature was
        (self: mujoco._specs.MjSpec) -> mjSpec_

----------------------------------------------------------------------
Ran 1 test in 0.006s

FAILED (errors=1)

I was expecting/hoping this to create a (deep) copy the spec.

Steps for reproduction

See above.

Minimal model for reproduction

See above.

Code required for reproduction

See above.

Confirmations

quagla commented 2 weeks ago

Hi, this should have been fixed by ca45041049003d55fc030a254d548edd86b3d54c could you build from source and test? Or you can wait for the next release which should happen this week.