Skip to content

Commit

Permalink
Merge branch 'sdf12' into merge_12_13_20240530
Browse files Browse the repository at this point in the history
  • Loading branch information
iche033 committed May 30, 2024
2 parents e9a2c01 + c71fc82 commit 2db49ec
Show file tree
Hide file tree
Showing 8 changed files with 912 additions and 36 deletions.
10 changes: 10 additions & 0 deletions include/sdf/Link.hh
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,22 @@ namespace sdf
/// \sa bool Model::EnableWind
public: bool EnableWind() const;

/// \brief Check if this link should be subject to gravity.
/// If true, this link should be affected by gravity.
/// \return true if the model should be subject to gravity, false otherwise.
public: bool EnableGravity() const;

/// \brief Set whether this link should be subject to wind.
/// \param[in] _enableWind True or false depending on whether the link
/// should be subject to wind.
/// \sa Model::SetEnableWind(bool)
public: void SetEnableWind(bool _enableWind);

/// \brief Set whether this link should be subject to gravity.
/// \param[in] _enableGravity True or false depending on whether the link
/// should be subject to gravity.
public: void SetEnableGravity(bool _enableGravity);

/// \brief Add a collision to the link.
/// \param[in] _collision Collision to add.
/// \return True if successful, false if a collision with the name already
Expand Down
145 changes: 145 additions & 0 deletions include/sdf/Surface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef SDF_SURFACE_HH_
#define SDF_SURFACE_HH_

#include <gz/math/Vector3.hh>
#include <gz/utils/ImplPtr.hh>
#include "sdf/Element.hh"
#include "sdf/Types.hh"
Expand Down Expand Up @@ -122,6 +123,132 @@ namespace sdf
GZ_UTILS_IMPL_PTR(dataPtr)
};

/// \brief BulletFriction information for a friction.
class SDFORMAT_VISIBLE BulletFriction
{
/// \brief Default constructor
public: BulletFriction();

/// \brief Load BulletFriction friction based on a element pointer. This is
/// *not* the usual entry point. Typical usage of the SDF DOM is through
/// the Root object.
/// \param[in] _sdf The SDF Element pointer
/// \return Errors, which is a vector of Error objects. Each Error includes
/// an error code and message. An empty vector indicates no error.
public: Errors Load(ElementPtr _sdf);

/// \brief Get the friction coefficient in first friction pyramid direction.
/// \returns Friction coefficient
public: double Friction() const;

/// \brief Set friction coefficient in first friction pyramid direction.
/// \param[in] _fricton Friction coefficient
public: void SetFriction(double _friction);

/// \brief Get the friction coefficient in second friction pyramid
/// direction.
/// \return Second friction coefficient
public: double Friction2() const;

/// \brief Set friction coefficient in second friction pyramid direction.
/// \param[in] _fricton Friction coefficient
public: void SetFriction2(double _friction);

/// \brief Get the first friction pyramid direction in collision-fixed
/// reference
/// \return First friction pyramid direction.
public: const gz::math::Vector3d &Fdir1() const;

/// \brief Set the first friction pyramid direction in collision-fixed
/// reference
/// \param[in] _fdir First friction pyramid direction.
public: void SetFdir1(const gz::math::Vector3d &_fdir);

/// \brief Get the rolling friction coefficient
/// \return Rolling friction coefficient
public: double RollingFriction() const;

/// \brief Set the rolling friction coefficient
/// \param[in] _slip1 Rolling friction coefficient
public: void SetRollingFriction(double _friction);

/// \brief Get a pointer to the SDF element that was used during
/// load.
/// \return SDF element pointer. The value will be nullptr if Load has
/// not been called.
public: sdf::ElementPtr Element() const;

/// \brief Private data pointer.
IGN_UTILS_IMPL_PTR(dataPtr)
};

/// \brief Torsional friction
class SDFORMAT_VISIBLE Torsional
{
/// \brief Default constructor
public: Torsional();

/// \brief Load torsional friction based on a element pointer. This is *not*
/// the usual entry point. Typical usage of the SDF DOM is through the Root
/// object.
/// \param[in] _sdf The SDF Element pointer
/// \return Errors, which is a vector of Error objects. Each Error includes
/// an error code and message. An empty vector indicates no error.
public: Errors Load(ElementPtr _sdf);

/// \brief Get the torsional friction coefficient.
/// \return Torsional friction coefficient
public: double Coefficient() const;

/// \brief Set the torsional friction coefficient.
/// \param[in] _fricton Torsional friction coefficient
public: void SetCoefficient(double _coefficient);

/// \brief Get whether the patch radius is used to calculate torsional
/// friction.
/// \return True if patch radius is used.
public: bool UsePatchRadius() const;

/// \brief Set whether to use patch radius for torsional friction
/// calculation.
/// \param[in] _usePatchRadius True to use patch radius.
/// False to use surface radius.
public: void SetUsePatchRadius(bool _usePatchRadius);

/// \brief Get the radius of contact patch surface.
/// \return Patch radius
public: double PatchRadius() const;

/// \brief Set the radius of contact patch surface.
/// \param[in] _radius Patch radius
public: void SetPatchRadius(double _radius);

/// \brief Get the surface radius on the contact point
/// \return Surface radius
public: double SurfaceRadius() const;

/// \brief Set the surface radius on the contact point.
/// \param[in] _radius Surface radius
public: void SetSurfaceRadius(double _radius);

/// \brief Get the ODE force dependent slip for torsional friction
/// \return Force dependent slip for torsional friction.
public: double ODESlip() const;

/// \brief Set the ODE force dependent slip for torsional friction
/// \param[in] _slip Force dependent slip for torsional friction.
public: void SetODESlip(double _slip);

/// \brief Get a pointer to the SDF element that was used during
/// load.
/// \return SDF element pointer. The value will be nullptr if Load has
/// not been called.
public: sdf::ElementPtr Element() const;

/// \brief Private data pointer.
IGN_UTILS_IMPL_PTR(dataPtr)
};

/// \brief Friction information for a surface.
class SDFORMAT_VISIBLE Friction
{
Expand All @@ -145,6 +272,24 @@ namespace sdf
/// \param[in] _ode The ODE object.
public: void SetODE(const sdf::ODE &_ode);

/// \brief Get the associated BulletFriction object
/// \return Pointer to the associated BulletFriction object,
/// nullptr if the Surface doesn't contain a BulletFriction element.
public: const sdf::BulletFriction *BulletFriction() const;

/// \brief Set the associated BulletFriction object.
/// \param[in] _bullet The BulletFriction object.
public: void SetBulletFriction(const sdf::BulletFriction &_bullet);

/// \brief Get the torsional friction
/// \return Pointer to the torsional friction
/// nullptr if the Surface doesn't contain a torsional friction element.
public: const sdf::Torsional *Torsional() const;

/// \brief Set the torsional friction
/// \param[in] _torsional The torsional friction.
public: void SetTorsional(const sdf::Torsional &_torsional);

/// \brief Get a pointer to the SDF element that was used during
/// load.
/// \return SDF element pointer. The value will be nullptr if Load has
Expand Down
20 changes: 19 additions & 1 deletion src/Link.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class sdf::Link::Implementation
/// \brief True if this link should be subject to wind, false otherwise.
public: bool enableWind = false;

/// \brief True if this link should be subject to gravity, false otherwise.
public: bool enableGravity = true;

/// \brief Scoped Pose Relative-To graph at the parent model scope.
public: sdf::ScopedGraph<sdf::PoseRelativeToGraph> poseRelativeToGraph;
};
Expand Down Expand Up @@ -261,6 +264,9 @@ Errors Link::Load(ElementPtr _sdf, const ParserConfig &_config)
this->dataPtr->enableWind = _sdf->Get<bool>("enable_wind",
this->dataPtr->enableWind).first;

this->dataPtr->enableGravity = _sdf->Get<bool>("gravity",
this->dataPtr->enableGravity).first;

return errors;
}

Expand Down Expand Up @@ -712,11 +718,23 @@ bool Link::EnableWind() const
}

/////////////////////////////////////////////////
void Link::SetEnableWind(const bool _enableWind)
bool Link::EnableGravity() const
{
return this->dataPtr->enableGravity;
}

/////////////////////////////////////////////////
void Link::SetEnableWind(bool _enableWind)
{
this->dataPtr->enableWind = _enableWind;
}

/////////////////////////////////////////////////
void Link::SetEnableGravity(bool _enableGravity)
{
this->dataPtr->enableGravity = _enableGravity;
}

//////////////////////////////////////////////////
bool Link::AddCollision(const Collision &_collision)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Link_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ TEST(DOMLink, Construction)
link.SetEnableWind(true);
EXPECT_TRUE(link.EnableWind());

EXPECT_TRUE(link.EnableGravity());
link.SetEnableGravity(false);
EXPECT_FALSE(link.EnableGravity());

EXPECT_EQ(0u, link.SensorCount());
EXPECT_EQ(nullptr, link.SensorByIndex(0));
EXPECT_EQ(nullptr, link.SensorByIndex(1));
Expand Down
Loading

0 comments on commit 2db49ec

Please sign in to comment.