Skip to content

Commit

Permalink
Merge 5 to 6
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
azeey committed Jan 6, 2023
2 parents 2a93515 + 79e0aef commit f0b2012
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
14 changes: 14 additions & 0 deletions dartsim/src/Base.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@

#include <sdf/Types.hh>

#if DART_VERSION_AT_LEAST(6, 13, 0)
// The BodyNode::getShapeNodes method was deprecated in dart 6.13.0
// in favor of an iterator approach with BodyNode::eachShapeNode
// See https://github.com/dartsim/dart/pull/1644 for more info
#define DART_HAS_EACH_SHAPE_NODE_API
#endif

namespace gz {
namespace physics {
namespace dartsim {
Expand Down Expand Up @@ -528,10 +535,17 @@ class Base : public Implements3d<FeatureList<Feature>>
}
for (auto &bn : skel->getBodyNodes())
{
#ifdef DART_HAS_EACH_SHAPE_NODE_API
bn->eachShapeNode([this](dart::dynamics::ShapeNode *_sn)
{
this->shapes.RemoveEntity(_sn);
});
#else
for (auto &sn : bn->getShapeNodes())
{
this->shapes.RemoveEntity(sn);
}
#endif
this->links.RemoveEntity(bn);
this->linksByName.erase(::sdf::JoinName(
world->getName(), ::sdf::JoinName(skel->getName(), bn->getName())));
Expand Down
29 changes: 29 additions & 0 deletions dartsim/src/SimulationFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@

#include "SimulationFeatures.hh"

#if DART_VERSION_AT_LEAST(6, 13, 0)
// The ContactSurfaceParams class was first added to version 6.10 of our fork
// of dart, and then merged upstream and released in version 6.13.0 with
// different public member variable names.
// See https://github.com/dartsim/dart/pull/1626 and
// https://github.com/gazebo-forks/dart/pull/22 for more info.
#define DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES
#endif

namespace gz {
namespace physics {
namespace dartsim {
Expand Down Expand Up @@ -233,9 +242,17 @@ dart::constraint::ContactSurfaceParams GzContactSurfaceHandler::createParams(
typedef FeaturePolicy3d P;
typename F::ContactSurfaceParams<P> pGz;

#ifdef DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES
pGz.frictionCoeff = pDart.mPrimaryFrictionCoeff;
#else
pGz.frictionCoeff = pDart.mFrictionCoeff;
#endif
pGz.secondaryFrictionCoeff = pDart.mSecondaryFrictionCoeff;
#ifdef DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES
pGz.slipCompliance = pDart.mPrimarySlipCompliance;
#else
pGz.slipCompliance = pDart.mSlipCompliance;
#endif
pGz.secondarySlipCompliance = pDart.mSecondarySlipCompliance;
pGz.restitutionCoeff = pDart.mRestitutionCoeff;
pGz.firstFrictionalDirection = pDart.mFirstFrictionalDirection;
Expand All @@ -248,11 +265,23 @@ dart::constraint::ContactSurfaceParams GzContactSurfaceHandler::createParams(
_numContactsOnCollisionObject, pGz);

if (pGz.frictionCoeff)
{
#ifdef DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES
pDart.mPrimaryFrictionCoeff = pGz.frictionCoeff.value();
#else
pDart.mFrictionCoeff = pGz.frictionCoeff.value();
#endif
}
if (pGz.secondaryFrictionCoeff)
pDart.mSecondaryFrictionCoeff = pGz.secondaryFrictionCoeff.value();
if (pGz.slipCompliance)
{
#ifdef DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES
pDart.mPrimarySlipCompliance = pGz.slipCompliance.value();
#else
pDart.mSlipCompliance = pGz.slipCompliance.value();
#endif
}
if (pGz.secondarySlipCompliance)
pDart.mSecondarySlipCompliance = pGz.secondarySlipCompliance.value();
if (pGz.restitutionCoeff)
Expand Down

0 comments on commit f0b2012

Please sign in to comment.