Simbody  3.7
SimTK::Force::MobilityLinearSpring Class Reference

A linear spring that acts along or around a mobility coordinate to apply a generalized force there. More...

+ Inheritance diagram for SimTK::Force::MobilityLinearSpring:

Public Member Functions

 MobilityLinearSpring (GeneralForceSubsystem &forces, const MobilizedBody &mobod, MobilizerQIndex whichQ, Real defaultStiffness, Real defaultQZero)
 Create a MobilityLinearSpring force element on a particular generalized coordinate. More...
 
 MobilityLinearSpring ()
 Default constructor creates an empty handle that can be assigned to refer to any MobilityLinearSpring object. More...
 
MobilityLinearSpringsetDefaultStiffness (Real defaultStiffness)
 Provide a new value for the default stiffness k of this spring. More...
 
MobilityLinearSpringsetDefaultQZero (Real defaultQZero)
 Provide a new value for the zero position q0 of this spring, at which position the spring force will be zero. More...
 
Real getDefaultStiffness () const
 Return the default value for the spring's stiffness k. More...
 
Real getDefaultQZero () const
 Return the default value for the spring's zero position q0. More...
 
const MobilityLinearSpringsetStiffness (State &state, Real stiffness) const
 Change the value of the spring stiffness in the given state; this may differ from the default value supplied at construction. More...
 
const MobilityLinearSpringsetQZero (State &state, Real qZero) const
 Change the value of the spring zero length in the given state; this may differ from the default value supplied at construction. More...
 
Real getStiffness (const State &state) const
 Return the value for the spring's stiffness k that is stored in the given state. More...
 
Real getQZero (const State &state) const
 Return the value for the spring zero position q0 that is stored in the given state. More...
 
Deprecated

Methods here are for backwards compatibility but have been replaced with better ones that you should use.

 MobilityLinearSpring (GeneralForceSubsystem &forces, const MobilizedBody &mobod, int whichQ, Real defaultStiffness, Real defaultQZero)
 Deprecated: Alternate signature for backwards compatibility – for safety you should prefer using the other constructor signature that takes a MobilizerQIndex rather than a plain int. 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 linear spring that acts along or around a mobility coordinate to apply a generalized force there.

The stiffness k is provided, along with an arbitrary "zero" coordinate value q0 at which the spring generates no force. The generated force is k*(q-q0), and potential energy is pe = 1/2 k (q-q0)^2.

Constructor & Destructor Documentation

◆ MobilityLinearSpring() [1/3]

SimTK::Force::MobilityLinearSpring::MobilityLinearSpring ( GeneralForceSubsystem forces,
const MobilizedBody mobod,
MobilizerQIndex  whichQ,
Real  defaultStiffness,
Real  defaultQZero 
)

Create a MobilityLinearSpring force element on a particular generalized coordinate.

Parameters
[in,out]forces
The subsystem to which this force should be added.
[in]mobod
Mobilizer to which the force should be applied.
[in]whichQ
To which of the mobilizer's generalized coordinates q should this force be applied (first is 0)?
[in]defaultStiffness
The default value for the spring constant k.
[in]defaultQZero
The default for the value of the coordinate q0 at which the force is 0.

◆ MobilityLinearSpring() [2/3]

Default constructor creates an empty handle that can be assigned to refer to any MobilityLinearSpring object.

◆ MobilityLinearSpring() [3/3]

SimTK::Force::MobilityLinearSpring::MobilityLinearSpring ( GeneralForceSubsystem forces,
const MobilizedBody mobod,
int  whichQ,
Real  defaultStiffness,
Real  defaultQZero 
)
inline

Deprecated: Alternate signature for backwards compatibility – for safety you should prefer using the other constructor signature that takes a MobilizerQIndex rather than a plain int.

Member Function Documentation

◆ setDefaultStiffness()

MobilityLinearSpring& SimTK::Force::MobilityLinearSpring::setDefaultStiffness ( Real  defaultStiffness)

Provide a new value for the default stiffness k of this spring.

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 setStiffness() to set the stiffness in a State rather than in the System.

Parameters
[in]defaultStiffness
The default value for the spring constant k.
Returns
A writable reference to this modified force element for convenience in chaining set methods.
See also
getDefaultStiffness(), setStiffness()

◆ setDefaultQZero()

MobilityLinearSpring& SimTK::Force::MobilityLinearSpring::setDefaultQZero ( Real  defaultQZero)

Provide a new value for the zero position q0 of this spring, at which position the spring force will be zero.

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 setQZero() to set the zero position in a State rather than in the System.

Parameters
[in]defaultQZero
The default for the value of the coordinate at which the force is 0.
Returns
A writable reference to this modified force element for convenience in chaining set methods.
See also
getDefaultQZero(), setQZero()

◆ getDefaultStiffness()

Real SimTK::Force::MobilityLinearSpring::getDefaultStiffness ( ) const

Return the default value for the spring's stiffness k.

This is normally set at construction but can be modified with setDefaultStiffness().

See also
setDefaultStiffness(), getStiffness()

◆ getDefaultQZero()

Real SimTK::Force::MobilityLinearSpring::getDefaultQZero ( ) const

Return the default value for the spring's zero position q0.

This is normally set at construction but can be modified with setDefaultQZero().

See also
setDefaultQZero(), getQZero()

◆ setStiffness()

const MobilityLinearSpring& SimTK::Force::MobilityLinearSpring::setStiffness ( State state,
Real  stiffness 
) const

Change the value of the spring stiffness in the given state; this may differ from the default value supplied at construction.

Parameters
[in,out]state
The State in which the stiffness is to be changed.
[in]stiffness
The new stiffness k (>= 0) that overrides the default.
Returns
A const reference to this MobilityLinearSpring element for convenience in chaining set methods together.

Changing the spring stiffness invalidates Stage::Dynamics and above in the state since it can affect force generation.

See also
setDefaultStiffness(), getStiffness()

◆ setQZero()

const MobilityLinearSpring& SimTK::Force::MobilityLinearSpring::setQZero ( State state,
Real  qZero 
) const

Change the value of the spring zero length in the given state; this may differ from the default value supplied at construction.

Parameters
[in,out]state
The State in which the zero length is to be changed.
[in]qZero
The value of the controlled coordinate q at which the generated spring force should be zero. This overrides the default.
Returns
A const reference to this MobilityLinearSpring element for convenience in chaining set methods together.

Changing the spring stiffness invalidates Stage::Dynamics and above in the state since it can affect force generation.

See also
setDefaultStiffness(), getStiffness()

◆ getStiffness()

Real SimTK::Force::MobilityLinearSpring::getStiffness ( const State state) const

Return the value for the spring's stiffness k that is stored in the given state.

Note that this is not the same thing as the default stiffness that was supplied on construction or in setDefaultStiffness().

See also
setStiffness(), getDefaultStiffness()

◆ getQZero()

Real SimTK::Force::MobilityLinearSpring::getQZero ( const State state) const

Return the value for the spring zero position q0 that is stored in the given state.

Note that this is not the same thing as the default q0 that was supplied on construction or in setDefaultQZero().

See also
setQZero(), getDefaultQZero()

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