diff --git a/src/user/user_api.cc b/src/user/user_api.cc index af465e75..af7cd9b5 100644 --- a/src/user/user_api.cc +++ b/src/user/user_api.cc @@ -614,7 +614,7 @@ mjsBody* mjs_findBody(mjSpec* s, const char* name) { // find element in spec by name mjsElement* mjs_findElement(mjSpec* s, mjtObj type, const char* name) { mjCModel* model = static_cast(s->element); - if (model->IsCompiled()) { + if (model->IsCompiled() && type != mjOBJ_FRAME) { return model->FindObject(type, std::string(name)); // fast lookup } switch (type) { diff --git a/test/user/user_api_test.cc b/test/user/user_api_test.cc index 67b7282d..c6620c1c 100644 --- a/test/user/user_api_test.cc +++ b/test/user/user_api_test.cc @@ -1014,6 +1014,9 @@ TEST_F(MujocoTest, AttachDifferent) { mjModel* m_attached = mj_compile(parent, 0); EXPECT_THAT(m_attached, NotNull()); + // check frame is present + EXPECT_THAT(mjs_findFrame(parent, "frame"), NotNull()); + // check full name stored in mjModel EXPECT_STREQ(mj_id2name(m_attached, mjOBJ_BODY, 2), "attached-body-1");