-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add Gravity Feature, fix LinkFeatures_TEST #275
Changes from 7 commits
e270f65
5f41fcc
94048ea
356d191
ec232ac
573f001
d593676
5324195
7fa6ab2
8cbc89f
315424c
ef1012d
37d09ae
5261eee
12b4cd4
9ce8fd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
#include <string> | ||
|
||
#include <ignition/physics/FeatureList.hh> | ||
#include <ignition/physics/FrameSemantics.hh> | ||
|
||
namespace ignition | ||
{ | ||
|
@@ -61,6 +62,81 @@ namespace ignition | |
}; | ||
}; | ||
|
||
///////////////////////////////////////////////// | ||
using GravityRequiredFeatures = FeatureList<FrameSemantics>; | ||
|
||
///////////////////////////////////////////////// | ||
/// \brief Get and set the World's gravity vector in a specified frame. | ||
class IGNITION_PHYSICS_VISIBLE Gravity | ||
: public virtual | ||
FeatureWithRequirements<GravityRequiredFeatures> | ||
{ | ||
/// \brief The World API for getting and setting the gravity vector. | ||
public: template <typename PolicyT, typename FeaturesT> | ||
class World : public virtual Feature::World<PolicyT, FeaturesT> | ||
{ | ||
public: using LinearVectorType = | ||
typename FromPolicy<PolicyT>::template Use<LinearVector>; | ||
|
||
public: using RelativeGravityType = RelativeQuantity< | ||
LinearVectorType, PolicyT::Dim, | ||
detail::VectorSpace<typename PolicyT::Scalar, PolicyT::Dim>>; | ||
|
||
/// \brief Set the World gravity vector. | ||
/// \param[in] _gravity The desired gravity as a Relative Gravity | ||
/// (a quantity that contains information about the coordinates | ||
/// in which it is expressed). | ||
public: void SetGravity(const RelativeGravityType &_gravity); | ||
|
||
/// \brief Set the World gravity vector. Optionally, you may specify | ||
/// the frame whose coordinates are used to express the gravity vector. | ||
/// The World frame is used as a default if no frame is specified. | ||
/// \param[in] _gravity Gravity vector. | ||
/// \param[in] _inCoordinatesOf Frame whose coordinates are used | ||
/// to express _gravity. | ||
public: void SetGravity( | ||
const LinearVectorType &_gravity, | ||
const FrameID &_forceInCoordinatesOf = FrameID::World()); | ||
|
||
/// \brief Get the World gravity vector as a Relative Gravity | ||
/// (a quantity that contains information about the coordinates | ||
/// in which it is expressed). | ||
/// \return Relative Gravity vector. | ||
public: RelativeGravityType GetGravity() const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it now occurs to me that the two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's weird that the compiler doesn't catch this. I'd also vote for removing the function that returns There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed in 7fa6ab2 |
||
|
||
/// \brief Get the World gravity vector. Optionally, you may specify | ||
/// the frame whose coordinates are used to express the gravity vector. | ||
/// The World frame is used as a default if no frame is specified. | ||
/// \param[in] _inCoordinatesOf Frame whose coordinates are used | ||
/// to express _gravity. | ||
/// \return Gravity vector in corrdinates of _inCoordinatesOf. | ||
public: LinearVectorType GetGravity( | ||
const FrameID &_forceInCoordinatesOf = FrameID::World()) const; | ||
}; | ||
|
||
/// \private The implementation API for the gravity. | ||
public: template <typename PolicyT> | ||
class Implementation : public virtual Feature::Implementation<PolicyT> | ||
{ | ||
public: using LinearVectorType = | ||
typename FromPolicy<PolicyT>::template Use<LinearVector>; | ||
|
||
/// \brief Implementation API for setting the gravity vector, which is | ||
/// expressed in the World frame.. | ||
/// \param[in] _id Identity of the world. | ||
/// \param[in] _gravity Name of gravity. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "Name"->"Value"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
public: virtual void SetWorldGravity( | ||
const Identity &_id, const LinearVectorType &_gravity) = 0; | ||
|
||
/// \brief Implementation API for getting the gravity expressed in the | ||
/// world frame. | ||
/// \param[in] _id Identity of the world. | ||
/// \return Name of gravity. | ||
public: virtual LinearVectorType GetWorldGravity( | ||
const Identity &_id) const = 0; | ||
}; | ||
}; | ||
|
||
///////////////////////////////////////////////// | ||
class IGNITION_PHYSICS_VISIBLE Solver : public virtual Feature | ||
{ | ||
|
@@ -83,7 +159,7 @@ namespace ignition | |
{ | ||
/// \brief Implementation API for setting the solver. | ||
/// \param[in] _id Identity of the world. | ||
/// \param[in] _collisionDetector Name of solver. | ||
/// \param[in] _solver Name of solver. | ||
public: virtual void SetWorldSolver( | ||
const Identity &_id, const std::string &_solver) = 0; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an expectation on
GetGravity
just to exercise the API?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had intended to do that, but then I realized that I would need to move the
AssertVectorApprox
class definition up above this function in order to use it in the expectation. So I stalled out on doing it. I'll do it now thoughThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in ef1012d