Do not use fast lookup for frames.
Fast lookup is not possible since mjOBJ_FRAME > mjNOBJECT, which is the size of the objects maps used for the search. Fixes #2328. PiperOrigin-RevId: 712479460 Change-Id: I7bcfa75ff8a1e288183d60ed4a44cab5bc6f4173
This commit is contained in:
committed by
Copybara-Service
parent
daed8f46c8
commit
65048d6b8f
@@ -614,7 +614,7 @@ mjsBody* mjs_findBody(mjSpec* s, const char* name) {
|
|||||||
// find element in spec by name
|
// find element in spec by name
|
||||||
mjsElement* mjs_findElement(mjSpec* s, mjtObj type, const char* name) {
|
mjsElement* mjs_findElement(mjSpec* s, mjtObj type, const char* name) {
|
||||||
mjCModel* model = static_cast<mjCModel*>(s->element);
|
mjCModel* model = static_cast<mjCModel*>(s->element);
|
||||||
if (model->IsCompiled()) {
|
if (model->IsCompiled() && type != mjOBJ_FRAME) {
|
||||||
return model->FindObject(type, std::string(name)); // fast lookup
|
return model->FindObject(type, std::string(name)); // fast lookup
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@@ -1014,6 +1014,9 @@ TEST_F(MujocoTest, AttachDifferent) {
|
|||||||
mjModel* m_attached = mj_compile(parent, 0);
|
mjModel* m_attached = mj_compile(parent, 0);
|
||||||
EXPECT_THAT(m_attached, NotNull());
|
EXPECT_THAT(m_attached, NotNull());
|
||||||
|
|
||||||
|
// check frame is present
|
||||||
|
EXPECT_THAT(mjs_findFrame(parent, "frame"), NotNull());
|
||||||
|
|
||||||
// check full name stored in mjModel
|
// check full name stored in mjModel
|
||||||
EXPECT_STREQ(mj_id2name(m_attached, mjOBJ_BODY, 2), "attached-body-1");
|
EXPECT_STREQ(mj_id2name(m_attached, mjOBJ_BODY, 2), "attached-body-1");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user