Hi, I am having an issue with PyMJCF handling nested default classes containing muscle elements.
Environment
- dm_control==1.0.41
- mujoco==3.8.1
Minimal repro
from dm_control import mjcf
xml = """<mujoco model="repro">
<default>
<default class="forearm_muscle">
<muscle ctrllimited="true" ctrlrange="-1 1" />
<tendon width="0.002" />
</default>
</default>
</mujoco>
"""
mjcf.from_xml_string(xml)
Observed behavior
This fails with:
KeyError: "Line 4: error while parsing element <muscle>: 'muscle'"
Manual construction also fails
from dm_control import mjcf
root = mjcf.RootElement(model="repro")
d = root.default.add("default", dclass="forearm_muscle")
d.add("muscle", ctrllimited="true", ctrlrange="-1 1")
This raises:
AttributeError: <muscle> is not a valid child of <default>
Additional observation
from dm_control import mjcf
root = mjcf.RootElement(model="debug")
outer = root.default
inner = outer.add("default", dclass="forearm_muscle")
print("muscle" in outer.spec.children) # True
print("muscle" in inner.spec.children) # False
So it looks like the top-level default accepts muscle, but nested default does not.
Expected behavior
I would expect nested default classes to accept <muscle .../> children as well.
This came up while parsing a musculoskeletal MJCF model that uses blocks like:
<default class="forearm_muscle">
<muscle ctrllimited="true" ctrlrange="-1 1" />
<tendon width="0.002" />
</default>
I am fairly new to using this parser, so please let me know if there is something I am missing
Hi, I am having an issue with PyMJCF handling nested default classes containing muscle elements.
Environment
Minimal repro
Observed behavior
This fails with:
Manual construction also fails
This raises:
Additional observation
So it looks like the top-level default accepts muscle, but nested default does not.
Expected behavior
I would expect nested default classes to accept <muscle .../> children as well.
This came up while parsing a musculoskeletal MJCF model that uses blocks like:
I am fairly new to using this parser, so please let me know if there is something I am missing