diff --git a/bullet-featherstone/src/JointFeatures.cc b/bullet-featherstone/src/JointFeatures.cc index 79e4113aa..dd8e72c6a 100644 --- a/bullet-featherstone/src/JointFeatures.cc +++ b/bullet-featherstone/src/JointFeatures.cc @@ -303,11 +303,11 @@ Identity JointFeatures::AttachFixedJoint( const BaseLink3dPtr &_parent, const std::string &_name) { - auto linkInfo = this->ReferenceInterface(_childID); - auto modelInfo = this->ReferenceInterface(linkInfo->model); - auto parentLinkInfo = this->ReferenceInterface( + auto *linkInfo = this->ReferenceInterface(_childID); + auto *modelInfo = this->ReferenceInterface(linkInfo->model); + auto *parentLinkInfo = this->ReferenceInterface( _parent->FullIdentity()); - auto parentModelInfo = this->ReferenceInterface( + auto *parentModelInfo = this->ReferenceInterface( parentLinkInfo->model); auto *world = this->ReferenceInterface(modelInfo->world); @@ -322,16 +322,18 @@ Identity JointFeatures::AttachFixedJoint( linkInfo->model }); - auto jointInfo = this->ReferenceInterface(jointID); + auto parentLinkIdx = parentLinkInfo->indexInModel.value_or(-1); + auto childLinkIdx = linkInfo->indexInModel.value_or(-1); + auto *jointInfo = this->ReferenceInterface(jointID); jointInfo->fixedConstraint = std::make_shared( - parentModelInfo->body.get(), -1, - modelInfo->body.get(), -1, + parentModelInfo->body.get(), parentLinkIdx, + modelInfo->body.get(), childLinkIdx, btVector3(0, 0, 0), btVector3(0, 0, 0), btMatrix3x3::getIdentity(), btMatrix3x3::getIdentity()); - if (world && world->world) + if (world != nullptr && world->world) { world->world->addMultiBodyConstraint(jointInfo->fixedConstraint.get()); return this->GenerateIdentity(jointID, this->joints.at(jointID));