Add "frame" attribute to <attach> element.

The `<attach>` element now supports a "frame" attribute, allowing users to specify either a "body" or a "frame" to attach to, but not both. The XML parser has been updated to handle this new attribute and the mutual exclusivity constraint.

PiperOrigin-RevId: 941245904
Change-Id: I4c0edeed5f3a9e456aed96c373b1647fe79841d9
This commit is contained in:
Yuval Tassa
2026-07-01 12:49:01 -07:00
committed by Copybara-Service
parent 1f6cf4035c
commit c6c3ec3149
5 changed files with 77 additions and 27 deletions
+12 -1
View File
@@ -1,7 +1,18 @@
<mujoco model="child">
<worldbody>
<body name="body">
<geom name="geom" size="1" pos="2 0 0"/>
<geom name="geom" size="1" pos="0 0 -2" rgba="1 0 0 1"/>
</body>
<frame name="frame">
<body name="body2" pos="-1 0 0">
<freejoint/>
<geom name="geom2" type="box" size="1 1 1" rgba="0 1 0 1"/>
</body>
<body name="body3" pos="1 0 0">
<freejoint/>
<geom name="geom3" type="box" size="1 1 1" rgba="0 1 0 1"/>
</body>
</frame>
</worldbody>
</mujoco>
+16 -2
View File
@@ -3,9 +3,23 @@
<model name="other" file="child.xml"/>
</asset>
<worldbody>
<!-- attach body to body -->
<body name="parent">
<geom name="geom" size="2"/>
<attach model="other" body="body" prefix="other"/>
<geom name="geom" size="1" pos="0 0 2"/>
<attach model="other" body="body" prefix="other1"/>
</body>
<!-- attach frame to body (world) -->
<attach model="other" frame="frame" prefix="other2"/>
<!-- attach frame to frame -->
<frame name="top" pos="0 0 4">
<attach model="other" frame="frame" prefix="other3"/>
</frame>
<!-- attach body to frame -->
<frame name="bottom-right" pos="2 0 -1">
<attach model="other" body="body" prefix="other4"/>
</frame>
</worldbody>
</mujoco>