Drake

This ForceElement allows modeling the effect of a uniform gravity field as felt by bodies on the surface of the Earth. More...
#include <drake/multibody/multibody_tree/uniform_gravity_field_element.h>
Public Member Functions  
UniformGravityFieldElement (Vector3< double > g_W)  
Constructs a uniform gravity field element with a strength given by the acceleration of gravity vector g_W , expressed in the world frame W. More...  
const Vector3< double > &  gravity_vector () const 
Returns the acceleration of gravity vector, expressed in the world frame W. More...  
VectorX< T >  CalcGravityGeneralizedForces (const systems::Context< T > &context) const 
Computes the generalized forces tau_g(q) due to this gravity field element as a function of the generalized positions q stored in the input context , for the multibody model to which this element belongs. More...  
T  CalcPotentialEnergy (const MultibodyTreeContext< T > &context, const PositionKinematicsCache< T > &pc) const final 
Computes the total potential energy of all bodies in the model in this uniform gravity field. More...  
T  CalcConservativePower (const MultibodyTreeContext< T > &context, const PositionKinematicsCache< T > &pc, const VelocityKinematicsCache< T > &vc) const final 
Calculates and returns the power generated by conservative force elements or zero if this force element is nonconservative. More...  
T  CalcNonConservativePower (const MultibodyTreeContext< T > &context, const PositionKinematicsCache< T > &pc, const VelocityKinematicsCache< T > &vc) const final 
Calculates the rate at which mechanical energy is being generated (positive) or dissipated (negative) other than by conversion between potential and kinetic energy. More...  
Does not allow copy, move, or assignment  
UniformGravityFieldElement (const UniformGravityFieldElement &)=delete  
UniformGravityFieldElement &  operator= (const UniformGravityFieldElement &)=delete 
UniformGravityFieldElement (UniformGravityFieldElement &&)=delete  
UniformGravityFieldElement &  operator= (UniformGravityFieldElement &&)=delete 
Public Member Functions inherited from ForceElement< T >  
ForceElement (ModelInstanceIndex model_instance)  
Default constructor for a generic force element. More...  
void  CalcAndAddForceContribution (const MultibodyTreeContext< T > &context, const PositionKinematicsCache< T > &pc, const VelocityKinematicsCache< T > &vc, MultibodyForces< T > *forces) const 
Computes the force contribution for this force element and adds it to the output arrays of forces. More...  
ForceElement (const ForceElement &)=delete  
ForceElement &  operator= (const ForceElement &)=delete 
ForceElement (ForceElement &&)=delete  
ForceElement &  operator= (ForceElement &&)=delete 
Protected Member Functions  
void  DoCalcAndAddForceContribution (const MultibodyTreeContext< T > &context, const PositionKinematicsCache< T > &pc, const VelocityKinematicsCache< T > &vc, MultibodyForces< T > *forces) const final 
This method is called only from the public nonvirtual CalcAndAddForceContributions() which will already have errorchecked the parameters so you don't have to. More...  
std::unique_ptr< ForceElement< double > >  DoCloneToScalar (const MultibodyTree< double > &tree_clone) const override 
Clones this ForceElement (templated on T) to a mobilizer templated on double . More...  
std::unique_ptr< ForceElement< AutoDiffXd > >  DoCloneToScalar (const MultibodyTree< AutoDiffXd > &tree_clone) const override 
Clones this ForceElement (templated on T) to a mobilizer templated on AutoDiffXd. More...  
Methods to make a clone templated on different scalar types.  
Specific force element subclasses must implement these to support scalar conversion to other types. These methods are only called from MultibodyTree::CloneToScalar(); users must not call these explicitly since there is no external mechanism to ensure the argument template <typename T> class SpringElement { public: // Class's constructor. SpringElement( const Body<T>& body1, const Body<T>& body2, double stiffness); // Get the first body to which this spring is connected. const Body<T>& get_body1() const; // Get the second body to which this spring is connected. const Body<T>& get_body2() const; // Get the spring stiffness constant. double get_stiffness() const; protected: // Implementation of the scalar conversion from T to double. std::unique_ptr<ForceElement<double>> DoCloneToScalar( const MultibodyTree<double>& tree_clone) const) { const Body<ToScalar>& body1_clone = tree_clone.get_variant(get_body1()); const Body<ToScalar>& body2_clone = tree_clone.get_variant(get_body2()); return std::make_unique<SpringElement<double>>( body1_clone, body2_clone, get_stiffness()); } MultibodyTree::get_variant() methods are available to retrieve cloned variants from For examples on how a MultibodyTree model can be converted to other scalar types, please refer to the documentation for MultibodyTree::CloneToScalar(). 
This ForceElement allows modeling the effect of a uniform gravity field as felt by bodies on the surface of the Earth.
This gravity fields acts on all bodies in the MultibodyTree model.
T  The scalar type. Must be a valid Eigen scalar. 
Instantiated templates for the following kinds of T's are provided:
They are already available to link against in the containing library. No other values for T are currently supported.

delete 

delete 

explicit 
Constructs a uniform gravity field element with a strength given by the acceleration of gravity vector g_W
, expressed in the world frame W.

finalvirtual 
Calculates and returns the power generated by conservative force elements or zero if this
force element is nonconservative.
This quantity is defined to be positive when the potential energy is decreasing. In other words, if PE
is the potential energy as defined by CalcPotentialEnergy(), then the conservative power, Pc
, is Pc = d(PE)/dt
.
Implements ForceElement< T >.
VectorX< T > CalcGravityGeneralizedForces  (  const systems::Context< T > &  context  )  const 
Computes the generalized forces tau_g(q)
due to this
gravity field element as a function of the generalized positions q
stored in the input context
, for the multibody model to which this
element belongs.
tau_g(q)
is defined such that it appears on the right hand side of the equations of motion together with any other generalized forces, like so:
Mv̇ + C(q, v)v = tau_g(q) + tau_app
where tau_app
includes any other generalized forces applied on the system.
[in]  context  The context storing the state of the multibody model to which this element belongs. 
v
for the parent MultibodyTree model so that the inner product v⋅tau_g
corresponds to the power applied by the gravity forces on the mechanical system. That is, v⋅tau_g > 0
corresponds to potential energy going into the system, as either mechanical kinetic energy, some other potential energy, or heat, and therefore to a decrease of potential energy.

finalvirtual 
Calculates the rate at which mechanical energy is being generated (positive) or dissipated (negative) other than by conversion between potential and kinetic energy.
Integrating this quantity yields work W, and the total energy E = PE + KE  W
should be conserved by any physicallycorrect model, to within integration accuracy of W.
Implements ForceElement< T >.

finalvirtual 
Computes the total potential energy of all bodies in the model in this uniform gravity field.
The definition of potential energy allows to arbitrarily choose the zero energy height. This element takes the zero energy height to be the same as the world's height. That is, a body will have zero potential energy when its the height of its center of mass is at the world's origin.
Implements ForceElement< T >.

finalprotectedvirtual 
This method is called only from the public nonvirtual CalcAndAddForceContributions() which will already have errorchecked the parameters so you don't have to.
Refer to the documentation for CalcAndAddForceContribution() for details describing the purpose and parameters of this method. It assumes forces
to be a valid pointer to a MultibodyForces object compatible with the MultibodyTree model owning this
force element.
pc
must have been previously updated with a call to CalcPositionKinematicsCache(). vc
must have been previously updated with a call to CalcVelocityKinematicsCache(). Implements ForceElement< T >.

overrideprotectedvirtual 
Clones this ForceElement (templated on T) to a mobilizer templated on double
.
Implements ForceElement< T >.

overrideprotectedvirtual 
Clones this ForceElement (templated on T) to a mobilizer templated on AutoDiffXd.
Implements ForceElement< T >.
Returns the acceleration of gravity vector, expressed in the world frame W.

delete 

delete 