Skip to content

Commit

Permalink
Fix build errors and warnings for DART 6.13.0 (#465)
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Co-authored-by: Steve Peters <scpeters@openrobotics.org>
  • Loading branch information
azeey and scpeters committed Jan 6, 2023
1 parent 3b7995a commit 79e0aef
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 ignition {
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 ignition {
namespace physics {
namespace dartsim {
Expand Down Expand Up @@ -216,9 +225,17 @@ dart::constraint::ContactSurfaceParams IgnContactSurfaceHandler::createParams(
typedef FeaturePolicy3d P;
typename F::ContactSurfaceParams<P> pIgn;

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

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

0 comments on commit 79e0aef

Please sign in to comment.