Skip to content

Commit

Permalink
Fix construction of nested models (#445)
Browse files Browse the repository at this point in the history
* Fix construction of nested models

Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll authored Oct 28, 2022
1 parent 96425a2 commit 924e0b4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion dartsim/src/SDFFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,23 @@ Identity SDFFeatures::ConstructSdfModelImpl(
if (isNested)
{
worldID = this->GetWorldOfModelImpl(_parentID);
const auto &skel = this->models.at(_parentID)->model;

const auto parentModelInfo = this->models.at(_parentID);
const auto &skel = parentModelInfo->model;
modelName = ::sdf::JoinName(skel->getName(), _sdfModel.Name());

// Check to see if the nested model has already been constructed.
// This can happen in the case that it was recursively created as
// part of the parent model.
// In this case, return the identity, rather than duplicating.
for (const auto &nestedModelID : parentModelInfo->nestedModels)
{
auto nestedModel = this->models.at(nestedModelID);
if (nestedModel->localName == _sdfModel.Name())
{
return this->GenerateIdentity(nestedModelID, nestedModel);
}
}
}

dart::dynamics::Frame *parentFrame = this->frames.at(_parentID);
Expand Down

0 comments on commit 924e0b4

Please sign in to comment.