Skip to content
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

Fix build errors and warnings for DART 6.13.0 #465

Merged
merged 2 commits into from
Jan 5, 2023
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
14 changes: 14 additions & 0 deletions dartsim/src/Base.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
#include <gz/common/Console.hh>
#include <gz/physics/Implements.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 @@ -339,10 +346,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->models.RemoveEntity(skel);
Expand Down
29 changes: 29 additions & 0 deletions dartsim/src/SimulationFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -170,9 +179,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 @@ -185,11 +202,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