Skip to content

Add updateLocalVertices methods #5

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

Merged
merged 1 commit into from
Aug 4, 2024
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
6 changes: 6 additions & 0 deletions include/ForceColl/Contact.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ class SurfaceContact : public Contact
return "Surface";
}

/** \brief Update localVertices_ and localGraspMat_ according to the input pose. */
void updateLocalVertices(const std::vector<Eigen::Vector3d> & localVertices);

/** \brief Update graspMat_ and vertexWithRidgeList_ according to the input pose. */
virtual void updateGlobalVertices(const sva::PTransformd & pose) override;

Expand Down Expand Up @@ -265,6 +268,9 @@ class GraspContact : public Contact
return "Grasp";
}

/** \brief Update localVertices_ and localGraspMat_ according to the input pose. */
void updateLocalVertices(const std::vector<sva::PTransformd> & localVertices);

/** \brief Update graspMat_ and vertexWithRidgeList_ according to the input pose. */
virtual void updateGlobalVertices(const sva::PTransformd & pose) override;

Expand Down
52 changes: 28 additions & 24 deletions src/Contact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,22 @@ SurfaceContact::SurfaceContact(const std::string & name,
std::optional<sva::ForceVecd> maxWrench)
: Contact(name, std::move(maxWrench))
{
// Set graspMat_ and localRidgeList_
fricPyramid_ = std::make_shared<FrictionPyramid>(fricCoeff);
updateLocalVertices(localVertices);
updateGlobalVertices(pose);
}

SurfaceContact::SurfaceContact(const mc_rtc::Configuration & mcRtcConfig)
: SurfaceContact(mcRtcConfig("name"),
mcRtcConfig("fricCoeff"),
verticesMap.at(mcRtcConfig("verticesName")),
mcRtcConfig("pose"),
mcRtcConfig("maxWrench", std::optional<sva::ForceVecd>{}))
{
}

void SurfaceContact::updateLocalVertices(const std::vector<Eigen::Vector3d> & localVertices)
{
localVertices_.resize(localVertices.size());
std::copy(localVertices.begin(), localVertices.end(), localVertices_.begin());

Expand All @@ -207,17 +220,6 @@ SurfaceContact::SurfaceContact(const std::string & name,
localGraspMat_.col(colIdx) << localVertex.cross(localRidge), localRidge;
}
}

updateGlobalVertices(pose);
}

SurfaceContact::SurfaceContact(const mc_rtc::Configuration & mcRtcConfig)
: SurfaceContact(mcRtcConfig("name"),
mcRtcConfig("fricCoeff"),
verticesMap.at(mcRtcConfig("verticesName")),
mcRtcConfig("pose"),
mcRtcConfig("maxWrench", std::optional<sva::ForceVecd>{}))
{
}

void SurfaceContact::updateGlobalVertices(const sva::PTransformd & pose)
Expand Down Expand Up @@ -280,9 +282,22 @@ GraspContact::GraspContact(const std::string & name,
std::optional<sva::ForceVecd> maxWrench)
: Contact(name, std::move(maxWrench))
{
// Set graspMat_ and localRidgeList_
fricPyramid_ = std::make_shared<FrictionPyramid>(fricCoeff);
updateLocalVertices(localVertices);
updateGlobalVertices(pose);
}

GraspContact::GraspContact(const mc_rtc::Configuration & mcRtcConfig)
: GraspContact(mcRtcConfig("name"),
mcRtcConfig("fricCoeff"),
verticesMap.at(mcRtcConfig("verticesName")),
mcRtcConfig("pose"),
mcRtcConfig("maxWrench", std::optional<sva::ForceVecd>{}))
{
}

void GraspContact::updateLocalVertices(const std::vector<sva::PTransformd> & localVertices)
{
localVertices_.resize(localVertices.size());
std::copy(localVertices.begin(), localVertices.end(), localVertices_.begin());

Expand All @@ -302,17 +317,6 @@ GraspContact::GraspContact(const std::string & name,
localGraspMat_.col(colIdx) << localVertex.cross(localRidge), localRidge;
}
}

updateGlobalVertices(pose);
}

GraspContact::GraspContact(const mc_rtc::Configuration & mcRtcConfig)
: GraspContact(mcRtcConfig("name"),
mcRtcConfig("fricCoeff"),
verticesMap.at(mcRtcConfig("verticesName")),
mcRtcConfig("pose"),
mcRtcConfig("maxWrench", std::optional<sva::ForceVecd>{}))
{
}

void GraspContact::updateGlobalVertices(const sva::PTransformd & pose)
Expand Down
Loading