From 1b9d528d9501b8ff97b6c9a03987ab28773e279d Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Mon, 2 Jan 2023 12:10:47 -0600 Subject: [PATCH 1/2] Fix build errors and warnings for DART 6.13.0 Signed-off-by: Addisu Z. Taddese --- dartsim/src/Base.hh | 7 +++++++ dartsim/src/SimulationFeatures.cc | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/dartsim/src/Base.hh b/dartsim/src/Base.hh index 3b66a42dc..4f82a6706 100644 --- a/dartsim/src/Base.hh +++ b/dartsim/src/Base.hh @@ -339,10 +339,17 @@ class Base : public Implements3d> } for (auto &bn : skel->getBodyNodes()) { +#if DART_VERSION_AT_LEAST(6, 13, 0) + 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->models.RemoveEntity(skel); diff --git a/dartsim/src/SimulationFeatures.cc b/dartsim/src/SimulationFeatures.cc index d211787e6..ea0736d42 100644 --- a/dartsim/src/SimulationFeatures.cc +++ b/dartsim/src/SimulationFeatures.cc @@ -170,9 +170,17 @@ dart::constraint::ContactSurfaceParams IgnContactSurfaceHandler::createParams( typedef FeaturePolicy3d P; typename F::ContactSurfaceParams

pIgn; +#if DART_VERSION_AT_LEAST(6, 13, 0) + pIgn.frictionCoeff = pDart.mPrimaryFrictionCoeff; +#else pIgn.frictionCoeff = pDart.mFrictionCoeff; +#endif pIgn.secondaryFrictionCoeff = pDart.mSecondaryFrictionCoeff; +#if DART_VERSION_AT_LEAST(6, 13, 0) + pIgn.slipCompliance = pDart.mPrimarySlipCompliance; +#else pIgn.slipCompliance = pDart.mSlipCompliance; +#endif pIgn.secondarySlipCompliance = pDart.mSecondarySlipCompliance; pIgn.restitutionCoeff = pDart.mRestitutionCoeff; pIgn.firstFrictionalDirection = pDart.mFirstFrictionalDirection; @@ -185,11 +193,23 @@ dart::constraint::ContactSurfaceParams IgnContactSurfaceHandler::createParams( _numContactsOnCollisionObject, pIgn); if (pIgn.frictionCoeff) + { +#if DART_VERSION_AT_LEAST(6, 13, 0) + pDart.mPrimaryFrictionCoeff = pIgn.frictionCoeff.value(); +#else pDart.mFrictionCoeff = pIgn.frictionCoeff.value(); +#endif + } if (pIgn.secondaryFrictionCoeff) pDart.mSecondaryFrictionCoeff = pIgn.secondaryFrictionCoeff.value(); if (pIgn.slipCompliance) + { +#if DART_VERSION_AT_LEAST(6, 13, 0) + pDart.mPrimarySlipCompliance = pIgn.slipCompliance.value(); +#else pDart.mSlipCompliance = pIgn.slipCompliance.value(); +#endif + } if (pIgn.secondarySlipCompliance) pDart.mSecondarySlipCompliance = pIgn.secondarySlipCompliance.value(); if (pIgn.restitutionCoeff) From 51a7fed00b4ce7fd66f9f4dd44ab2bdb6ec9ab4b Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Wed, 4 Jan 2023 14:49:30 -0800 Subject: [PATCH 2/2] Define verbose macros for dart version check Define DART_HAS_EACH_SHAPE_NODE_API and DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES so the ifdef logic is more clear and readable. Signed-off-by: Steve Peters --- dartsim/src/Base.hh | 9 ++++++++- dartsim/src/SimulationFeatures.cc | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/dartsim/src/Base.hh b/dartsim/src/Base.hh index 4f82a6706..315221aee 100644 --- a/dartsim/src/Base.hh +++ b/dartsim/src/Base.hh @@ -33,6 +33,13 @@ #include #include +#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 { @@ -339,7 +346,7 @@ class Base : public Implements3d> } for (auto &bn : skel->getBodyNodes()) { -#if DART_VERSION_AT_LEAST(6, 13, 0) +#ifdef DART_HAS_EACH_SHAPE_NODE_API bn->eachShapeNode([this](dart::dynamics::ShapeNode *_sn) { this->shapes.RemoveEntity(_sn); diff --git a/dartsim/src/SimulationFeatures.cc b/dartsim/src/SimulationFeatures.cc index ea0736d42..fd2f7dd47 100644 --- a/dartsim/src/SimulationFeatures.cc +++ b/dartsim/src/SimulationFeatures.cc @@ -32,6 +32,15 @@ #include "gz/common/Profiler.hh" #include "gz/physics/GetContacts.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 { @@ -170,13 +179,13 @@ dart::constraint::ContactSurfaceParams IgnContactSurfaceHandler::createParams( typedef FeaturePolicy3d P; typename F::ContactSurfaceParams

pIgn; -#if DART_VERSION_AT_LEAST(6, 13, 0) +#ifdef DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES pIgn.frictionCoeff = pDart.mPrimaryFrictionCoeff; #else pIgn.frictionCoeff = pDart.mFrictionCoeff; #endif pIgn.secondaryFrictionCoeff = pDart.mSecondaryFrictionCoeff; -#if DART_VERSION_AT_LEAST(6, 13, 0) +#ifdef DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES pIgn.slipCompliance = pDart.mPrimarySlipCompliance; #else pIgn.slipCompliance = pDart.mSlipCompliance; @@ -194,7 +203,7 @@ dart::constraint::ContactSurfaceParams IgnContactSurfaceHandler::createParams( if (pIgn.frictionCoeff) { -#if DART_VERSION_AT_LEAST(6, 13, 0) +#ifdef DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES pDart.mPrimaryFrictionCoeff = pIgn.frictionCoeff.value(); #else pDart.mFrictionCoeff = pIgn.frictionCoeff.value(); @@ -204,7 +213,7 @@ dart::constraint::ContactSurfaceParams IgnContactSurfaceHandler::createParams( pDart.mSecondaryFrictionCoeff = pIgn.secondaryFrictionCoeff.value(); if (pIgn.slipCompliance) { -#if DART_VERSION_AT_LEAST(6, 13, 0) +#ifdef DART_HAS_UPSTREAM_FRICTION_VARIABLE_NAMES pDart.mPrimarySlipCompliance = pIgn.slipCompliance.value(); #else pDart.mSlipCompliance = pIgn.slipCompliance.value();