`MjSpec.{option,statistic,visual}`: "Unable to convert function return value to a Python type!"
Closed this issue · 1 comments
hartikainen commented
Intro
Hi!
I use MuJoCo for robotic manipulation.
My setup
MuJoCo:
$ python -c "import mujoco; print(mujoco.__version__)"
3.2.3
API:
Python
OS:
$ python -c "import platform; print(f'{platform.system()=}, {platform.release()=}, {platform.machine()=}')"
platform.system()='Darwin', platform.release()='24.0.0', platform.machine()='arm64'
What's happening? What did you expect?
The title pretty much describes the problem: the option
, statistic
, or visual
attributes of MjSpec
are inaccessible because of the following error:
python -c "import mujoco; mujoco.MjSpec().visual"
TypeError: Unregistered type : mjVisual_
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: Unable to convert function return value to a Python type! The signature was
(arg0: mujoco._specs.MjSpec) -> mjVisual_
Steps for reproduction
Add the following to specs_test.py and run the test:
def test_access_option_stat_visual(self):
spec = mujoco.MjSpec()
spec.from_string(textwrap.dedent("""
<mujoco model="MuJoCo Model">
<option timestep="0.001"/>
<statistic meansize="0.05"/>
<visual>
<quality shadowsize="4096"/>
</visual>
</mujoco>
"""))
self.assertEqual(spec.option.timestep, 0.001)
self.assertEqual(spec.statistic.meansize, 0.05)
self.assertEqual(spec.visual.quality.shadowsize, 4096)
spec.option.timestep = 0.002
spec.statistic.meansize = 0.06
spec.visual.quality.shadowsize = 8192
model = spec.compile()
self.assertEqual(model.opt.timestep, 0.002)
self.assertEqual(model.stat.meansize, 0.06)
self.assertEqual(model.vis.quality.shadowsize, 8192)
Minimal model for reproduction
See above.
Code required for reproduction
See above.
Confirmations
- I searched the latest documentation thoroughly before posting.
- I searched previous Issues and Discussions, I am certain this has not been raised before.
quagla commented
Thank you for such a clear test! Will send a fix shortly.