Simbody  3.4 (development)
SimTK::CableSpring Class Reference

This force element implements a passive elastic element (like a rubber band) that follows a frictionless CablePath across a set of "obstacles". More...

#include <CableSpring.h>

+ Inheritance diagram for SimTK::CableSpring:

List of all members.

Public Member Functions

 CableSpring (GeneralForceSubsystem &forces, const CablePath &path, Real defaultStiffness, Real defaultSlackLength, Real defaultDissipationCoef)
 Create an elastic force element that follows a given CablePath and add it to a GeneralForceSubsystem.
 CableSpring ()
 Default constructor creates an empty handle.
Default Parameters

These refer to Topology-stage parameters normally set in the constructor; these determine the initial values assigned to the corresponding Instance-stage state variables.

Notes
  • Changing one of these parameters invalidates the containing System's topology, meaning that realizeTopology() will have to be called before subsequent use.
  • The set...() methods return a reference to "this" CableSpring (in the manner of an assignment operator) so they can be chained in a single expression.
CableSpringsetDefaultStiffness (Real stiffness)
 Set the stiffness (spring constant) k that will be used by default for this cable spring; must be nonnegative.
CableSpringsetDefaultSlackLength (Real slackLength)
 Set the slack length L0 that will be used by default for this cable spring; must be nonnegative.
CableSpringsetDefaultDissipationCoef (Real dissipation)
 Set the dissipation coefficient c that will be used by default for this cable spring; must be nonnegative.
Real getDefaultStiffness () const
 Return the stiffnesses k that will be used by default for this cable spring.
Real getDefaultSlackLength () const
 Return the slack length L0 that will be used by default for this cable spring.
Real getDefaultDissipationCoef () const
 Return the dissipation coefficient c that will be used by default for this cable spring.
Instance Parameters

These refer to the Instance-stage state variables that determine the geometry and material properties that will be used in computations involving this cable spring when performed with the given State.

If these are not set explicitly, the default values are set to those provided in the constructor or via the correponding setDefault...() methods.

Notes
  • Changing one of these parameters invalidates the given State's Instance stage, meaning that realize(Instance) will have to be called (explicitly or implicitly by realizing a higher stage) before subsequent use.
  • The set...() methods here return a const reference to "this" CableSpring (in the manner of an assignment operator, except read-only) so they can be chained in a single expression.
const CableSpringsetStiffness (State &state, Real stiffness) const
 Set the stiffness (spring constant) k that will be used for this cable spring when evaluated using this State.
const CableSpringsetSlackLength (State &state, Real slackLength) const
 Set the slack length L0 that will be used for this cable spring when evaluated using this State.
const CableSpringsetDissipationCoef (State &state, Real dissipationCoef) const
 Set the dissipation coefficient c that will be used for this cable spring when evaluated using this State.
Real getStiffness (const State &state) const
 Return the stiffness (spring constant) k currently being used for this cable spring by this State.
Real getSlackLength (const State &state) const
 Return the slack length L0 currently being used for this cable spring by this State.
Real getDissipationCoef (const State &state) const
 Return the dissipation coefficient c currently being used for this cable spring by this State.
Position-related Quantities

These methods return position-dependent quantities that are calculated by the cable spring as part of its force calculations and stored in the State cache.

These can be obtained at no cost, although the first call after a position change may initiate computation if forces haven't already been computed.

Precondition:
These methods may be called only after the supplied state has been realized to Stage::Position.
Real getLength (const State &state) const
 Return the current length of the CablePath that underlies this cable spring element.
Velocity-related Quantities

These methods return velocity-dependent quantities that are calculated by the cable spring as part of its force calculations and stored in the State cache.

These can be obtained at no cost, although the first call after a velocity change may initiate computation if forces haven't already been computed.

Precondition:
These methods may be called only after the supplied state has been realized to Stage::Velocity.
Real getLengthDot (const State &state) const
 Return the current rate of length change (time derivative of length) of the CablePath that underlies this cable spring element.
Forces

These methods return the forces being applied by this cable spring in the configuration and velocities contained in the supplied State.

These are evaluated during force calculation and available at no computational cost afterwards, although the first call after a velocity change may initiate computation if forces haven't already been computed.

Precondition:
These methods may be called only after the supplied state has been realized to Stage::Velocity.
Real getTension (const State &state) const
 Return the current level of tension in the cable spring.
Energy, Power, and Work

These methods return the energy, power, and work-related quantities associated with this CableSpring element for the values in the supplied State.

Real getPotentialEnergy (const State &state) const
 Obtain the potential energy stored in this cable spring in the current configuration.
Real getPowerDissipation (const State &state) const
 Obtain the rate at which energy is being dissipated by this cable spring, that is, the power being lost (presumably due to heat).
Real getDissipatedEnergy (const State &state) const
 Obtain the total amount of energy dissipated by this cable spring since some arbitrary starting point.
void setDissipatedEnergy (State &state, Real energy) const
 Set the accumulated dissipated energy to an arbitrary value.
Advanced/obscure/debugging

Miscellaneous methods that you probably aren't going to need.

const CablePathgetCablePath () const
 Get a reference to the CablePath that is used to determine the routing of this cable spring force element.

Detailed Description

This force element implements a passive elastic element (like a rubber band) that follows a frictionless CablePath across a set of "obstacles".

The element calculates a uniform nonnegative tension that is used to apply forces at the end points of the CablePath and to each intermediate obstacle. The model provides stiffness and dissipation, and has a slack length below which the tension is zero and no forces are generated. Dissipated power is calculated and integrated so that work lost to dissipation is available for conservation of energy calculations.

Theory:

Given current CablePath length L with time derivative Ldot, and slack length L0 for this force element, define stretch x=max(0,L-L0) and xdot=Ldot. Then calculate the nonnegative tension f(x,xdot), the potential energy pe(x) stored in this force element, and dissipating power powerLoss(x,xdot) due to rate-dependent resistance to length change, as follows:

    f_stretch   = k*x
    f_rate      = max(-f_stretch, f_stretch*c*xdot)    
    f           = f_stretch + f_rate
    pe          = k*x^2/2
    powerLoss   = f_rate * xdot
    dissipation = integ(powerLoss, dt)

where k >= 0 is the stiffness coefficient (force per unit length) and c >= 0 is the dissipation coefficient (1/velocity) for this force element.

Note that in this model the tension component f_rate, due to rate-dependent dissipation in the elastic element, is calculated as a fraction of the stretch-dependent tension component f_stretch, similar to a Hunt and Crossley contact model. That is why the dissipation coefficient c has units of 1/velocity, rather than force/velocity. This makes the generated tension grow smoothly from zero as the slack length is exceeded, but even so this is not necessarily a good model for any particular physically-realizable elastic element. A ligament, for example, while perhaps qualitatively similar to this element, is likely to require a more complicated relationship between x, xdot, and f to yield quantitative agreement with experimental data.

While the total tension f must be nonnegative, the tension f_rate due to stretch rate can be positive (resists stretching) or negative (resists shortening) but can never be less than -f_stretch since f can't be negative. When a stretched cable spring is shortening so rapidly that force due to dissipation cancels the force due to stiffness, there will be no tension generated but we will still dissipate power at a rate that exactly accounts for the continuing loss of potential energy in the spring (k*x*xdot) as it shortens to its slack length. In that way total energy E=pe+ke+dissipation is conserved, where dissipation is the time integral of powerLoss calculated above (note that powerLoss >= 0 as defined).

See also:
CablePath, CableTrackerSubsystem

Constructor & Destructor Documentation

SimTK::CableSpring::CableSpring ( GeneralForceSubsystem forces,
const CablePath path,
Real  defaultStiffness,
Real  defaultSlackLength,
Real  defaultDissipationCoef 
)

Create an elastic force element that follows a given CablePath and add it to a GeneralForceSubsystem.

Default values for the cable spring properties are given here; you can override them in the State. See the CableSpring class description for a detailed explanation of these parameters.

Parameters:
[in,out]forcesThe subsystem to which this force element should be added.
[in]pathThe CablePath that defines the routing of this elastic element over geometric obstacles.
[in]defaultStiffnessA nonnegative spring constant representing the stiffness of this element, in units of force/length, where the force represents a uniform tension along the element that results from stretching it beyond its slack length.
[in]defaultSlackLengthThe maximum length this elastic element can have before it begins to generate force. At or below this length the element is slack and has zero tension and zero power dissipation.
[in]defaultDissipationCoefA nonnegative dissipation coefficient for this elastic element in units of 1/velocity.

Default constructor creates an empty handle.


Member Function Documentation

Set the stiffness (spring constant) k that will be used by default for this cable spring; must be nonnegative.

Parameters:
[in]stiffnessThe spring constant k to be used by default.
Returns:
A writable reference to "this" CableSpring which will now have the new default stiffness.

Set the slack length L0 that will be used by default for this cable spring; must be nonnegative.

Parameters:
[in]slackLengthThe slack length L0 to be used by default.
Returns:
A writable reference to "this" CableSpring which will now have the new default slack length.

Set the dissipation coefficient c that will be used by default for this cable spring; must be nonnegative.

Parameters:
[in]dissipationThe dissipation coefficient c to be used by default.
Returns:
A writable reference to "this" CableSpring which will now have the new default dissipation coefficient.

Return the stiffnesses k that will be used by default for this cable spring.

Returns:
The default spring constant.

Return the slack length L0 that will be used by default for this cable spring.

Returns:
The default slack length.

Return the dissipation coefficient c that will be used by default for this cable spring.

Returns:
The default dissipation coefficient.
const CableSpring& SimTK::CableSpring::setStiffness ( State state,
Real  stiffness 
) const

Set the stiffness (spring constant) k that will be used for this cable spring when evaluated using this State.

Precondition:
state realized to Stage::Topology
Parameters:
[in,out]stateThe State object to be modified by this method.
[in]stiffnessThe spring constant k.
Returns:
A const reference to "this" CableSpring for convenient chaining of set...() methods in a single expression.
const CableSpring& SimTK::CableSpring::setSlackLength ( State state,
Real  slackLength 
) const

Set the slack length L0 that will be used for this cable spring when evaluated using this State.

Precondition:
state realized to Stage::Topology
Parameters:
[in,out]stateThe State object to be modified by this method.
[in]slackLengthThe slack length L0.
Returns:
A const reference to "this" CableSpring for convenient chaining of set...() methods in a single expression.
const CableSpring& SimTK::CableSpring::setDissipationCoef ( State state,
Real  dissipationCoef 
) const

Set the dissipation coefficient c that will be used for this cable spring when evaluated using this State.

Precondition:
state realized to Stage::Topology
Parameters:
[in,out]stateThe State object that is modified by this method.
[in]dissipationCoefThe dissipation coefficient c.
Returns:
A const reference to "this" CableSpring for convenient chaining of set...() methods in a single expression.
Real SimTK::CableSpring::getStiffness ( const State state) const

Return the stiffness (spring constant) k currently being used for this cable spring by this State.

Precondition:
state realized to Stage::Topology
Parameters:
[in]stateThe State object from which to obtain the stiffness.
Returns:
The current value in the given state of the spring constant k.
Real SimTK::CableSpring::getSlackLength ( const State state) const

Return the slack length L0 currently being used for this cable spring by this State.

Precondition:
state realized to Stage::Topology
Parameters:
[in]stateThe State object from which to obtain the slack length.
Returns:
The current value in the given state of the slack length L0.
Real SimTK::CableSpring::getDissipationCoef ( const State state) const

Return the dissipation coefficient c currently being used for this cable spring by this State.

Precondition:
state realized to Stage::Topology
Parameters:
[in]stateThe State object from which to obtain the dissipation coefficient.
Returns:
The current value in the given state of the dissipation coefficient c.
Real SimTK::CableSpring::getLength ( const State state) const

Return the current length of the CablePath that underlies this cable spring element.

Note that this may return a value less than the spring's slack length.

Precondition:
state realized to Stage::Position
Parameters:
stateThe State from which the path length is retrieved.
Returns:
The current length of the underlying CablePath (nonnegative).
See also:
getLengthDot()
Real SimTK::CableSpring::getLengthDot ( const State state) const

Return the current rate of length change (time derivative of length) of the CablePath that underlies this cable spring element.

Precondition:
state realized to Stage::Velocity
Parameters:
stateThe State from which the path length rate of change is retrieved.
Returns:
The current length change rate of the underlying CablePath.
See also:
getLength()
Real SimTK::CableSpring::getTension ( const State state) const

Return the current level of tension in the cable spring.

Precondition:
state realized to Stage::Velocity
Parameters:
[in]stateThe State from which the current tension is retrieved.
Returns:
The current tension in the cable spring in the configuration and velocity contained in state (a nonnegative scalar).
Real SimTK::CableSpring::getPotentialEnergy ( const State state) const

Obtain the potential energy stored in this cable spring in the current configuration.

Precondition:
state realized to Stage::Position
Parameters:
[in]stateThe State from whose cache the potential energy is retrieved.
Returns:
The potential energy currently contained in the cable spring in the configuration contained in state (a nonnegative scalar).
Real SimTK::CableSpring::getPowerDissipation ( const State state) const

Obtain the rate at which energy is being dissipated by this cable spring, that is, the power being lost (presumably due to heat).

This is in units of energy/time which is watts in MKS.

Precondition:
state realized to Stage::Velocity
Parameters:
[in]stateThe State from which to obtain the current value of the power dissipation.
Returns:
The instantaneous power dissipation (a nonnegative scalar).
See also:
getDissipatedEnergy() for the time-integrated power loss
Real SimTK::CableSpring::getDissipatedEnergy ( const State state) const

Obtain the total amount of energy dissipated by this cable spring since some arbitrary starting point.

This is the time integral of the power dissipation. For a system whose only non-conservative forces are cable springs, the sum of potential, kinetic, and dissipated energies should be conserved. This is a State variable so you can obtain its value any time after it is allocated.

Precondition:
state realized to Stage::Model
Parameters:
[in]stateThe State from which to obtain the current value of the dissipated energy.
Returns:
The total dissipated energy (a nonnegative scalar).
See also:
getPowerDissipation() for the instantaneous power loss
void SimTK::CableSpring::setDissipatedEnergy ( State state,
Real  energy 
) const

Set the accumulated dissipated energy to an arbitrary value.

Typically this is used only to reset the dissipated energy to zero, but non-zero values can be useful if you are trying to match some existing data or continuing a simulation. This is a State variable so you can set its value any time after it is allocated.

Precondition:
state realized to Stage::Model
Parameters:
[in,out]stateThe State whose dissipated energy variable for this cable spring is to be modified.
[in]energyThe new value for the accumulated dissipated energy (must be a nonnegative scalar).

Get a reference to the CablePath that is used to determine the routing of this cable spring force element.

This is set during CableSpring construction and cannot be changed subsequently.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines