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

Set slip compliance #56

Merged
merged 18 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
74 changes: 74 additions & 0 deletions dartsim/src/ShapeFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,80 @@ AlignedBox3d ShapeFeatures::GetShapeAxisAlignedBoundingBox(
return AlignedBox3d(box.getMin(), box.getMax());
}

/////////////////////////////////////////////////
double ShapeFeatures::GetShapeFrictionPyramidPrimarySlipCompliance(
const Identity &_shapeID) const
{
auto &node = this->ReferenceInterface<ShapeInfo>(_shapeID)->node;
auto aspect = node->getDynamicsAspect();
if (nullptr == aspect)
{
ignerr
<< "Attempt to get FrictionPyramidPrimarySlipCompliance for a "
<< "ShapeNode that doesn't have a DynamicAspect. "
<< "Returning default value of 0.0."
<< std::endl;
return 0.0;
}
return aspect->getSlipCompliance();
}

/////////////////////////////////////////////////
double ShapeFeatures::GetShapeFrictionPyramidSecondarySlipCompliance(
const Identity &_shapeID) const
{
auto &node = this->ReferenceInterface<ShapeInfo>(_shapeID)->node;
auto aspect = node->getDynamicsAspect();
if (nullptr == aspect)
{
ignerr
<< "Attempt to get FrictionPyramidSecondarySlipCompliance for a "
<< "ShapeNode that doesn't have a DynamicAspect. "
<< "Returning default value of 0.0."
<< std::endl;
return 0.0;
}
return aspect->getSecondarySlipCompliance();
}

/////////////////////////////////////////////////
bool ShapeFeatures::SetShapeFrictionPyramidPrimarySlipCompliance(
const Identity &_shapeID, double _value)
{
auto &node = this->ReferenceInterface<ShapeInfo>(_shapeID)->node;
auto aspect = node->getDynamicsAspect();
if (nullptr == aspect)
{
ignerr
<< "Attempt to set FrictionPyramidPrimarySlipCompliance for a "
<< "ShapeNode that doesn't have a DynamicAspect. "
<< "The parameter has not been set."
<< std::endl;
return false;
}
aspect->setSlipCompliance(_value);
return true;
}

/////////////////////////////////////////////////
bool ShapeFeatures::SetShapeFrictionPyramidSecondarySlipCompliance(
const Identity &_shapeID, double _value)
{
auto &node = this->ReferenceInterface<ShapeInfo>(_shapeID)->node;
auto aspect = node->getDynamicsAspect();
if (nullptr == aspect)
{
ignerr
<< "Attempt to set FrictionPyramidSecondarySlipCompliance for a "
<< "ShapeNode that doesn't have a DynamicAspect. "
<< "The parameter has not been set."
<< std::endl;
return false;
}
aspect->setSecondarySlipCompliance(_value);
return true;
}

}
}
}
28 changes: 28 additions & 0 deletions dartsim/src/ShapeFeatures.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ namespace dartsim {
using ShapeFeatureList = FeatureList<
GetShapeKinematicProperties,
SetShapeKinematicProperties,
GetShapeFrictionPyramidSlipCompliance,
SetShapeFrictionPyramidSlipCompliance,
GetShapeBoundingBox,
GetBoxShapeProperties,
// dartsim cannot yet update shape properties without reloading the model into
Expand Down Expand Up @@ -135,6 +137,19 @@ class ShapeFeatures :
public: AlignedBox3d GetShapeAxisAlignedBoundingBox(
const Identity &_shapeID) const override;

// ----- Friction Features -----
public: virtual double GetShapeFrictionPyramidPrimarySlipCompliance(
const Identity &_shapeID) const override;

public: virtual double GetShapeFrictionPyramidSecondarySlipCompliance(
const Identity &_shapeID) const override;

public: virtual bool SetShapeFrictionPyramidPrimarySlipCompliance(
const Identity &_shapeID, double _value) override;

public: virtual bool SetShapeFrictionPyramidSecondarySlipCompliance(
const Identity &_shapeID, double _value) override;

// ----- Plane Features -----
public: Identity CastToPlaneShape(
const Identity &_shapeID) const override;
Expand All @@ -150,6 +165,19 @@ class ShapeFeatures :
const std::string &_name,
const LinearVector3d &_normal,
const LinearVector3d &_point) override;

// ----- Friction Features -----
public: virtual double GetShapeFrictionPyramidPrimarySlipCompliance(
const Identity &_shapeID) const override;

public: virtual double GetShapeFrictionPyramidSecondarySlipCompliance(
const Identity &_shapeID) const override;

public: virtual bool SetShapeFrictionPyramidPrimarySlipCompliance(
const Identity &_shapeID, double _value) override;

public: virtual bool SetShapeFrictionPyramidSecondarySlipCompliance(
const Identity &_shapeID, double _value) override;
};

}
Expand Down
74 changes: 74 additions & 0 deletions include/ignition/physics/Shape.hh
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,80 @@ namespace ignition
Scalar _value) = 0;
};
};

/////////////////////////////////////////////////
class IGNITION_PHYSICS_VISIBLE GetShapeFrictionPyramidSlipCompliance
: public virtual Feature
{
public: template <typename PolicyT, typename FeaturesT>
class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
{
public: using Scalar = typename PolicyT::Scalar;

/// \brief Get the slip compliance for the first friction direction
/// of a friction pyramid model.
/// \return
/// The value of the slip compliance.
public: Scalar GetPrimarySlipCompliance() const;

/// \brief Get the slip compliance for the second friction direction
/// of a friction pyramid model.
/// \return
/// The value of the slip compliance.
public: Scalar GetSecondarySlipCompliance() const;
};

public: template <typename PolicyT>
class Implementation : public virtual Feature::Implementation<PolicyT>
{
public: using Scalar = typename PolicyT::Scalar;

public: virtual Scalar GetShapeFrictionPyramidPrimarySlipCompliance(
const Identity &_shapeID) const = 0;

public: virtual Scalar GetShapeFrictionPyramidSecondarySlipCompliance(
const Identity &_shapeID) const = 0;
};
};

/////////////////////////////////////////////////
class IGNITION_PHYSICS_VISIBLE SetShapeFrictionPyramidSlipCompliance
: public virtual Feature
{
public: template <typename PolicyT, typename FeaturesT>
class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
{
public: using Scalar = typename PolicyT::Scalar;

/// \brief Set the slip compliance for the first friction direction
/// of a friction pyramid model.
/// \param[in] _value
/// The value to set the slip compliance to.
/// \return
/// True if the parameter was set successfully, false otherwise.
public: bool SetPrimarySlipCompliance(Scalar _value);

/// \brief Set the slip compliance for the second friction direction
/// of a friction pyramid model.
/// \param[in] _value
/// The value to set the slip compliance to.
/// \return
/// True if the parameter was set successfully, false otherwise.
public: bool SetSecondarySlipCompliance(Scalar _value);
};

public: template <typename PolicyT>
class Implementation : public virtual Feature::Implementation<PolicyT>
{
public: using Scalar = typename PolicyT::Scalar;

public: virtual bool SetShapeFrictionPyramidPrimarySlipCompliance(
const Identity &_shapeID, Scalar _value) = 0;

public: virtual bool SetShapeFrictionPyramidSecondarySlipCompliance(
const Identity &_shapeID, Scalar _value) = 0;
};
};
}
}

Expand Down
40 changes: 40 additions & 0 deletions include/ignition/physics/detail/Shape.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,46 @@ namespace ignition
this->template Interface<SetShapeCollisionProperties>()
->SetShapeRestitutionCoefficient(this->identity, _other, _value);
}

/////////////////////////////////////////////////
template <typename PolicyT, typename FeaturesT>
auto GetShapeFrictionPyramidSlipCompliance::Shape<PolicyT, FeaturesT>
::GetPrimarySlipCompliance() const
-> Scalar
{
return this->template Interface<SetShapeFrictionPyramidSlipCompliance>()
->GetShapeFrictionPyramidPrimarySlipCompliance(this->identity);
}

/////////////////////////////////////////////////
template <typename PolicyT, typename FeaturesT>
auto GetShapeFrictionPyramidSlipCompliance::Shape<PolicyT, FeaturesT>
::GetSecondarySlipCompliance() const
-> Scalar
{
return this->template Interface<SetShapeFrictionPyramidSlipCompliance>()
->GetShapeFrictionPyramidSecondarySlipCompliance(this->identity);
}

/////////////////////////////////////////////////
template <typename PolicyT, typename FeaturesT>
bool SetShapeFrictionPyramidSlipCompliance::Shape<PolicyT, FeaturesT>
::SetPrimarySlipCompliance(Scalar _value)
{
return this->template Interface<SetShapeFrictionPyramidSlipCompliance>()
->SetShapeFrictionPyramidPrimarySlipCompliance(
this->identity, _value);
}

/////////////////////////////////////////////////
template <typename PolicyT, typename FeaturesT>
bool SetShapeFrictionPyramidSlipCompliance::Shape<PolicyT, FeaturesT>
::SetSecondarySlipCompliance(Scalar _value)
{
return this->template Interface<SetShapeFrictionPyramidSlipCompliance>()
->SetShapeFrictionPyramidSecondarySlipCompliance(
this->identity, _value);
}
}
}

Expand Down