Skip to content

Commit

Permalink
Merge pull request #5 from mmurooka/update-local-vertices
Browse files Browse the repository at this point in the history
Add updateLocalVertices methods
  • Loading branch information
mmurooka authored Aug 4, 2024
2 parents be65f6a + 0045ecc commit 2ff226b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
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

0 comments on commit 2ff226b

Please sign in to comment.