Simbody  3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimTK::Force::MobilityDiscreteForce Class Reference

A discrete mobility (generalized) force f applied to a particular mobility that is specified at construction. Useful for applying external forces or forces that are updated at discrete times due to the occurrence of events. More...

#include <Force_MobilityDiscreteForce.h>

+ Inheritance diagram for SimTK::Force::MobilityDiscreteForce:

Public Member Functions

 MobilityDiscreteForce (GeneralForceSubsystem &forces, const MobilizedBody &mobod, MobilizerUIndex whichU, Real defaultForce=0)
 Create a MobilityDiscreteForce. More...
 
 MobilityDiscreteForce (GeneralForceSubsystem &forces, const MobilizedBody &mobod, Real defaultForce=0)
 Alternate constructor signature for when the mobilizer has only a single generalized speed, in which case we'll use MobilizerUIndex(0). More...
 
 MobilityDiscreteForce ()
 Default constructor creates an empty handle. More...
 
MobilityDiscreteForcesetDefaultMobilityForce (Real defaultForce)
 Provide a new value for the defaultForce, overriding the one provided in the constructor. More...
 
Real getDefaultMobilityForce () const
 Return the value that this generalized force will have by default. More...
 
void setMobilityForce (State &state, Real f) const
 Change the value of the generalized force to be applied in the given state. More...
 
Real getMobilityForce (const State &state) const
 Return the value for this generalized force that is stored in the given state. More...
 
- Public Member Functions inherited from SimTK::Force
void disable (State &) const
 Disable this force element, effectively removing it from the System for computational purposes (it is still using its ForceIndex, however). More...
 
void enable (State &) const
 Enable this force element if it was previously disabled. More...
 
bool isDisabled (const State &) const
 Test whether this force element is currently disabled in the supplied State. More...
 
void setDisabledByDefault (bool shouldBeDisabled)
 Normally force elements are enabled when defined and can be disabled later. More...
 
bool isDisabledByDefault () const
 Test whether this force element is disabled by default in which case it must be explicitly enabled before it will take effect. More...
 
void calcForceContribution (const State &state, Vector_< SpatialVec > &bodyForces, Vector_< Vec3 > &particleForces, Vector &mobilityForces) const
 Calculate the force that would be applied by this force element if the given state were realized to Dynamics stage. More...
 
Real calcPotentialEnergyContribution (const State &state) const
 Calculate the potential energy contribution that is made by this force element at the given state. More...
 
 Force ()
 Default constructor for Force handle base class does nothing. More...
 
 operator ForceIndex () const
 Implicit conversion to ForceIndex when needed. More...
 
const GeneralForceSubsystemgetForceSubsystem () const
 Get the GeneralForceSubsystem of which this Force is an element. More...
 
ForceIndex getForceIndex () const
 Get the index of this force element within its parent force subsystem. More...
 
- Public Member Functions inherited from SimTK::PIMPLHandle< Force, ForceImpl, true >
bool isEmptyHandle () const
 Returns true if this handle is empty, that is, does not refer to any implementation object. More...
 
bool isOwnerHandle () const
 Returns true if this handle is the owner of the implementation object to which it refers. More...
 
bool isSameHandle (const Force &other) const
 Determine whether the supplied handle is the same object as "this" PIMPLHandle. More...
 
void disown (Force &newOwner)
 Give up ownership of the implementation to an empty handle. More...
 
PIMPLHandlereferenceAssign (const Force &source)
 "Copy" assignment but with shallow (pointer) semantics. More...
 
PIMPLHandlecopyAssign (const Force &source)
 This is real copy assignment, with ordinary C++ object ("value") semantics. More...
 
void clearHandle ()
 Make this an empty handle, deleting the implementation object if this handle is the owner of it. More...
 
const ForceImpl & getImpl () const
 Get a const reference to the implementation associated with this Handle. More...
 
ForceImpl & updImpl ()
 Get a writable reference to the implementation associated with this Handle. More...
 
int getImplHandleCount () const
 Return the number of handles the implementation believes are referencing it. More...
 

Additional Inherited Members

- Public Types inherited from SimTK::PIMPLHandle< Force, ForceImpl, true >
typedef PIMPLHandle< Force,
ForceImpl, PTR > 
HandleBase
 
typedef HandleBase ParentHandle
 
- Protected Member Functions inherited from SimTK::Force
 Force (ForceImpl *r)
 Use this in a derived Force handle class constructor to supply the concrete implementation object to be stored in the handle base. More...
 
- Protected Member Functions inherited from SimTK::PIMPLHandle< Force, ForceImpl, true >
 PIMPLHandle ()
 The default constructor makes this an empty handle. More...
 
 PIMPLHandle (ForceImpl *p)
 This provides consruction of a handle referencing an existing implementation object. More...
 
 PIMPLHandle (const PIMPLHandle &source)
 The copy constructor makes either a deep (value) or shallow (reference) copy of the supplied source PIMPL object, based on whether this is a "pointer semantics" (PTR=true) or "object (value) semantics" (PTR=false, default) class. More...
 
 ~PIMPLHandle ()
 Note that the destructor is non-virtual. More...
 
PIMPLHandleoperator= (const PIMPLHandle &source)
 Copy assignment makes the current handle either a deep (value) or shallow (reference) copy of the supplied source PIMPL object, based on whether this is a "pointer sematics" (PTR=true) or "object (value) semantics" (PTR=false, default) class. More...
 
void setImpl (ForceImpl *p)
 Set the implementation for this empty handle. More...
 
bool hasSameImplementation (const Force &other) const
 Determine whether the supplied handle is a reference to the same implementation object as is referenced by "this" PIMPLHandle. More...
 

Detailed Description

A discrete mobility (generalized) force f applied to a particular mobility that is specified at construction. Useful for applying external forces or forces that are updated at discrete times due to the occurrence of events.

Note that a mobility is a generalized speed (u), not a generalized coordinate (q). The meaning of a generalized force depends on the definition of the generalized speed. If that speed is a translation then this is a force; if a rotation then this is a torque; if something else then f has a comparable definition (the defining condition is that f*u should always have physically meaningful units of power). This force does not contribute to the potential energy, so adding it to a system will cause potential+kinetic energy not to be conserved.

If you want to be able to apply discrete forces to any body or mobilizer specifying which one in advance, see Force::DiscreteForces.

See Also
Force::DiscreteForces

Constructor & Destructor Documentation

SimTK::Force::MobilityDiscreteForce::MobilityDiscreteForce ( GeneralForceSubsystem forces,
const MobilizedBody mobod,
MobilizerUIndex  whichU,
Real  defaultForce = 0 
)

Create a MobilityDiscreteForce.

Parameters
forcessubsystem to which this force element should be added
mobodmobilizer to which the force should be applied
whichUto which of the mobilizer's mobilities (degrees of freedom) should this force be applied (first is 0)?
defaultForceinitial value for the generalized force to be applied (default 0)

Note that if you have an integer value for the generalized speed (u) index, you have to cast it to a MobilizerUIndex here. The generalized speeds are numbered starting with 0 for each mobilizer. Here is an example:

GeneralForceSubsystem forces;
MobilizedBody::Pin pinJoint(...);
MobilityDiscreteForce myForce(forces, pinJoint, MobilizerUIndex(0));
SimTK::Force::MobilityDiscreteForce::MobilityDiscreteForce ( GeneralForceSubsystem forces,
const MobilizedBody mobod,
Real  defaultForce = 0 
)
inline

Alternate constructor signature for when the mobilizer has only a single generalized speed, in which case we'll use MobilizerUIndex(0).

See the other signature for documentation.

Default constructor creates an empty handle.

Member Function Documentation

MobilityDiscreteForce& SimTK::Force::MobilityDiscreteForce::setDefaultMobilityForce ( Real  defaultForce)

Provide a new value for the defaultForce, overriding the one provided in the constructor.

This is a topological change because it affects the value that the containing System's default state will have when realizeTopology() is called. This is for use during construction, not for during a simulation where you should be using setGeneralizedForce().

Parameters
defaultForcethe value this generalized force should have by default
Returns
a writable reference to this modified force element
See Also
setMobilityForce(), getDefaultMobilityForce()
Real SimTK::Force::MobilityDiscreteForce::getDefaultMobilityForce ( ) const

Return the value that this generalized force will have by default.

This is normally set in the constructor, or left to its default value of 0. It can also be set in setDefaultMobilityForce(). Note that this is not the same as the value that may be set in any particular State.

See Also
getMobilityForce(), setDefaultMobilityForce()
void SimTK::Force::MobilityDiscreteForce::setMobilityForce ( State state,
Real  f 
) const

Change the value of the generalized force to be applied in the given state.

Set this to zero if you don't want it to do anything.

See Also
getMobilityForce()
Real SimTK::Force::MobilityDiscreteForce::getMobilityForce ( const State state) const

Return the value for this generalized force that is stored in the given state.

If no calls to setMobilityForce() have been made on this state then it will have the defaultForce value that was supplied on construction or via setDefaultMobilityForce().

See Also
setMobilityForce()

The documentation for this class was generated from the following file: