Require prefix for the attach tag.
For `mjs_attachFrame` and `mjs_attachBody`, require either a prefix or suffix. It is tempting for users to not use a prefix (see #2162), but this causes issues. For example, it creates a duplicate "main" default class in the parent as a child of the already existing "main" default. PiperOrigin-RevId: 688535755 Change-Id: I653181ca35943f1e4eb89c70fca8b5289818324e
This commit is contained in:
committed by
Copybara-Service
parent
94e9912d28
commit
bfa78614c8
@@ -1544,12 +1544,12 @@ TEST_F(XMLReaderTest, InvalidAttach) {
|
||||
<body name="parent">
|
||||
<joint name="joint1"/>
|
||||
<geom size="2"/>
|
||||
<attach model="other" body="body"/>
|
||||
<attach model="other" body="body" prefix="_"/>
|
||||
</body>
|
||||
</worldbody>
|
||||
|
||||
<actuator>
|
||||
<motor name="actuator" joint="joint1"/>
|
||||
<motor name="_actuator" joint="joint1"/>
|
||||
</actuator>
|
||||
</mujoco>
|
||||
)";
|
||||
@@ -1578,7 +1578,7 @@ TEST_F(XMLReaderTest, InvalidAttach) {
|
||||
LoadModelFromString(xml_parent, er.data(), er.size(), vfs.get());
|
||||
|
||||
EXPECT_THAT(model, IsNull()) << er.data();
|
||||
EXPECT_THAT(er.data(), HasSubstr("repeated name 'actuator' in actuator"));
|
||||
EXPECT_THAT(er.data(), HasSubstr("repeated name '_actuator' in actuator"));
|
||||
EXPECT_THAT(er.data(), HasSubstr("Element 'attach'"));
|
||||
mj_deleteVFS(vfs.get());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user