Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed GetCollision API it's redundant #444

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions bullet-featherstone/src/SDFFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -945,18 +945,6 @@ bool SDFFeatures::AddSdfCollision(
return true;
}

Identity SDFFeatures::GetCollision(
const Identity &_linkID,
const std::string &_collisionName)
{
const auto *link = this->ReferenceInterface<LinkInfo>(_linkID);
const auto it = link->collisionNameToEntityId.find(_collisionName);
if (it == link->collisionNameToEntityId.end())
return this->GenerateInvalidId();

return this->GenerateIdentity(it->second, this->collisions.at(it->second));
}

Identity SDFFeatures::ConstructSdfCollision(
const Identity &_linkID,
const ::sdf::Collision &_collision)
Expand Down
4 changes: 0 additions & 4 deletions bullet-featherstone/src/SDFFeatures.hh
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ class SDFFeatures :
private: Identity ConstructSdfCollision(
const Identity &_linkID,
const ::sdf::Collision &_collision) override;

private: Identity GetCollision(
const Identity &_linkID,
const std::string &_collisionName) override;
};

} // namespace bullet_featherstone
Expand Down
19 changes: 0 additions & 19 deletions bullet/src/SDFFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,6 @@ Identity SDFFeatures::ConstructSdfLink(
return linkIdentity;
}

Identity SDFFeatures::GetCollision(
const Identity &_linkID,
const std::string &_collisionName)
{
const auto link = this->ReferenceInterface<LinkInfo>(_linkID);
const auto it = std::find_if(
link->shapes.begin(),
link->shapes.end(),
[this, &_collisionName](const auto& shapeID)
{
return _collisionName == this->collisions.at(shapeID)->name;
});

if (it == link->shapes.end())
return this->GenerateInvalidId();

return this->GenerateIdentity(*it, this->collisions.at(*it));
}

Identity SDFFeatures::ConstructSdfCollision(
const Identity &_linkID,
const ::sdf::Collision &_collision)
Expand Down
4 changes: 0 additions & 4 deletions bullet/src/SDFFeatures.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ class SDFFeatures :
const Identity &_linkID,
const ::sdf::Collision &_collision) override;

private: Identity GetCollision(
const Identity &_linkID,
const std::string &_collisionName) override;

private: Identity ConstructSdfJoint(
const Identity &_modelID,
const ::sdf::Joint &_sdfJoint) override;
Expand Down
26 changes: 0 additions & 26 deletions dartsim/src/SDFFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,32 +669,6 @@ Identity SDFFeatures::ConstructSdfLink(
return linkIdentity;
}

Identity SDFFeatures::GetCollision(
const Identity &_linkID,
const std::string &_collisionName)
{
auto bn = this->ReferenceInterface<LinkInfo>(_linkID)->link;

DartShapeNode *const sn = bn->getSkeleton()->getShapeNode(
bn->getName() + ":" + _collisionName);

// If the shape doesn't exist in "shapes", it means the containing entity has
// been removed.
if (this->shapes.HasEntity(sn))
{
const std::size_t shapeID = this->shapes.IdentityOf(sn);
return this->GenerateIdentity(shapeID, this->shapes.at(shapeID));
}
else
{
// TODO(addisu) It's not clear what to do when `GetShape` is called on a
// link that has been removed. Right now we are returning an invalid
// identity, but that could cause a segfault if the use doesn't check if
// returned value before using it.
return this->GenerateInvalidId();
}
}

/////////////////////////////////////////////////
Identity SDFFeatures::ConstructSdfJoint(
const Identity &_modelID,
Expand Down
4 changes: 0 additions & 4 deletions dartsim/src/SDFFeatures.hh
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ class SDFFeatures :
const Identity &_linkID,
const ::sdf::Collision &_collision) override;

public: Identity GetCollision(
const Identity &_linkID,
const std::string &_collisionName) override;

public: Identity ConstructSdfVisual(
const Identity &_linkID,
const ::sdf::Visual &_visual) override;
Expand Down
14 changes: 0 additions & 14 deletions sdf/include/gz/physics/sdf/ConstructCollision.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,13 @@ class ConstructSdfCollision : public virtual Feature
public: using ShapePtrType = ShapePtr<PolicyT, FeaturesT>;

public: ShapePtrType ConstructCollision(const ::sdf::Collision &_collision);

public: ShapePtrType GetCollision(const std::string &_collisionName);
};

public: template <typename PolicyT>
class Implementation : public virtual Feature::Implementation<PolicyT>
{
public: virtual Identity ConstructSdfCollision(
const Identity &_linkID, const ::sdf::Collision &_collision) = 0;

public: virtual Identity GetCollision(
const Identity &_linkID, const std::string &_collisionName) = 0;
};
};

Expand All @@ -60,15 +55,6 @@ auto ConstructSdfCollision::Link<PolicyT, FeaturesT>::ConstructCollision(
this->template Interface<ConstructSdfCollision>()
->ConstructSdfCollision(this->identity, _collision));
}
/////////////////////////////////////////////////
template <typename PolicyT, typename FeaturesT>
auto ConstructSdfCollision::Link<PolicyT, FeaturesT>::GetCollision(
const std::string &_collisionName) -> ShapePtrType
{
return ShapePtrType(this->pimpl,
this->template Interface<ConstructSdfCollision>()
->GetCollision(this->identity, _collisionName));
}
}
}
}
Expand Down
26 changes: 0 additions & 26 deletions tpe/plugin/src/SDFFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,32 +250,6 @@ Identity SDFFeatures::ConstructSdfLink(
return linkIdentity;
}

/////////////////////////////////////////////////
Identity SDFFeatures::GetCollision(
const Identity &_linkID,
const std::string &_collisionName)
{
auto linkInfo = this->ReferenceInterface<LinkInfo>(_linkID);
if (linkInfo != nullptr)
{
tpelib::Entity &shapeEnt = linkInfo->link->GetChildByName(_collisionName);
for (auto it = this->collisions.begin();
it != this->collisions.end();
++it)
{
if (it->second != nullptr)
{
std::string name = it->second->collision->GetName();
if (it->first == shapeEnt.GetId() && name == shapeEnt.GetName())
{
return this->GenerateIdentity(it->first, it->second);
}
}
}
}
return this->GenerateInvalidId();
}

/////////////////////////////////////////////////
Identity SDFFeatures::ConstructSdfCollision(
const Identity &_linkID,
Expand Down
4 changes: 0 additions & 4 deletions tpe/plugin/src/SDFFeatures.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ class SDFFeatures :
private: Identity ConstructSdfCollision(
const Identity &_linkID,
const ::sdf::Collision &_collision) override;

private: Identity GetCollision(
const Identity &_linkID,
const std::string &_collisionName) override;
};

}
Expand Down