Associate children of deleted body to the newly created frame in mjs_bodyToFrame.

Also associate all children that need a parent body to the parent of the deleted body.

This is a bug that was causing the former children of the body that gets transformed to a frame to not be children of the new frame.

PiperOrigin-RevId: 702702853
Change-Id: I36d48f0446bc87c665b18d34e0b0609d82c70f51
This commit is contained in:
Alessio Quaglino
2024-12-04 06:29:41 -08:00
committed by Copybara-Service
parent 0ba717a653
commit afc86ac1b3
3 changed files with 34 additions and 23 deletions
+4 -2
View File
@@ -1316,7 +1316,7 @@ TEST_F(MujocoTest, AttachWorld) {
static constexpr char xml_parent[] = R"(
<mujoco>
<worldbody>
<frame name="frame"/>
<frame name="frame" pos="1 2 3"/>
</worldbody>
</mujoco>)";
@@ -1327,18 +1327,20 @@ TEST_F(MujocoTest, AttachWorld) {
<joint type="slide"/>
<geom size=".1"/>
</body>
<camera pos="0 0 0" quat="1 0 0 0"/>
</worldbody>
</mujoco>)";
static constexpr char xml_result[] = R"(
<mujoco>
<worldbody>
<frame name="frame">
<frame name="frame" pos="1 2 3">
<frame name="attached-world-1">
<body name="attached-sphere-1">
<joint type="slide"/>
<geom size=".1"/>
</body>
<camera pos="0 0 0" quat="1 0 0 0"/>
</frame>
</frame>
</worldbody>