Simbody  3.7
SimTK::Constraint Class Reference

This is the base class for all Constraint classes, which is just a handle for the underlying hidden implementation. More...

+ Inheritance diagram for SimTK::Constraint:

Classes

class  Ball
 Enforce that a fixed station on one body remains coincident with a fixed station on a second body, as though there were a ball joint connecting them at those points. More...
 
class  ConstantAcceleration
 Constrain a single mobility to have a particular acceleration. More...
 
class  ConstantAngle
 This constraint consists of a single constraint equation that enforces that a unit vector v1 fixed to one body (the "base body") must maintain a fixed angle theta with respect to a unit vector v2 fixed on the other body (the "follower body"). More...
 
class  ConstantCoordinate
 Constrain a single mobilizer coordinate q to have a particular value. More...
 
class  ConstantOrientation
 Three constraint equations. More...
 
class  ConstantSpeed
 Constrain a single mobility to have a particular speed. More...
 
class  CoordinateCoupler
 This is a Constraint that uses a Function object to define a single holonomic (position) constraint equation acting to relate a set of generalized coordinates q. More...
 
class  Custom
 The handle class Constraint::Custom (dataless) and its companion class Constraint::Custom::Implementation can be used together to define new Constraint types with arbitrary properties. More...
 
class  LineOnLineContact
 This constraint represents a bilateral connection between an edge on one body and a non-parallel edge on another. More...
 
class  NoSlip1D
 One non-holonomic constraint equation. More...
 
class  PointInPlane
 One constraint equation. More...
 
class  PointOnLine
 Two constraint equations. More...
 
class  PointOnPlaneContact
 (Advanced) This is the underlying constraint for unilateral contact with friction but must be combined with contact and friction conditions. More...
 
class  PrescribedMotion
 This is a Constraint that uses a Function to prescribe the behavior of a single generalized coordinate as a function of time. More...
 
class  Rod
 This constraint consists of one constraint equation that enforces a constant distance between a point on one body and a point on another body. More...
 
class  SpeedCoupler
 This is a Constraint that uses a Function object to define a nonholonomic (velocity) constraint. More...
 
class  SphereOnPlaneContact
 This constraint represents a bilateral connection between a sphere on one body and a plane on another. More...
 
class  SphereOnSphereContact
 This constraint represents a bilateral connection between a sphere on one body and a sphere on another. More...
 
class  Weld
 Six constraint equations. More...
 

Public Types

typedef Rod ConstantDistance
 Synonym for Rod constraint. More...
 
typedef Ball CoincidentPoints
 Synonym for Ball constraint. More...
 
typedef Ball Spherical
 Synonym for Ball constraint. More...
 
typedef Weld CoincidentFrames
 
- Public Types inherited from SimTK::PIMPLHandle< Constraint, ConstraintImpl, true >
typedef PIMPLHandle< Constraint, ConstraintImpl, PTR > HandleBase
 
typedef HandleBase ParentHandle
 

Public Member Functions

 Constraint ()
 Default constructor creates an empty Constraint handle that can be used to reference any Constraint. More...
 
 Constraint (ConstraintImpl *r)
 For internal use: construct a new Constraint handle referencing a particular implementation object. More...
 
void disable (State &) const
 Disable this Constraint, effectively removing it from the system. More...
 
void enable (State &) const
 Enable this Constraint, without necessarily satisfying it. More...
 
bool isDisabled (const State &) const
 Test whether this constraint is currently disabled in the supplied State. More...
 
bool isDisabledByDefault () const
 Test whether this Constraint is disabled by default in which case it must be explicitly enabled before it will take effect. More...
 
void setDisabledByDefault (bool shouldBeDisabled)
 Normally Constraints are enabled when defined and can be disabled later. More...
 
 operator ConstraintIndex () const
 This is an implicit conversion from Constraint to ConstraintIndex when needed. More...
 
const SimbodyMatterSubsystemgetMatterSubsystem () const
 Get a const reference to the matter subsystem that contains this Constraint. More...
 
SimbodyMatterSubsystemupdMatterSubsystem ()
 Assuming you have writable access to this Constraint, get a writable reference to the containing matter subsystem. More...
 
ConstraintIndex getConstraintIndex () const
 Get the ConstraintIndex that was assigned to this Constraint when it was added to the matter subsystem. More...
 
bool isInSubsystem () const
 Test whether this Constraint is contained within a matter subsystem. More...
 
bool isInSameSubsystem (const MobilizedBody &mobod) const
 Test whether the supplied MobilizedBody is in the same matter subsystem as this Constraint. More...
 
int getNumConstrainedBodies () const
 Return the number of unique bodies directly restricted by this constraint. More...
 
const MobilizedBodygetMobilizedBodyFromConstrainedBody (ConstrainedBodyIndex consBodyIx) const
 Return a const reference to the actual MobilizedBody corresponding to one of the Constrained Bodies included in the count returned by getNumConstrainedBodies(). More...
 
const MobilizedBodygetAncestorMobilizedBody () const
 Return a const reference to the actual MobilizedBody which is serving as the Ancestor body for the constrained bodies in this Constraint. More...
 
int getNumConstrainedMobilizers () const
 Return the number of unique mobilizers directly restricted by this Constraint. More...
 
const MobilizedBodygetMobilizedBodyFromConstrainedMobilizer (ConstrainedMobilizerIndex consMobilizerIx) const
 Return a const reference to the actual MobilizedBody corresponding to one of the Constrained Mobilizers included in the count returned by getNumConstrainedMobilizers(). More...
 
const SimbodyMatterSubtreegetSubtree () const
 Return a subtree object indicating which parts of the multibody tree are potentially affected by this Constraint. More...
 
int getNumConstrainedQ (const State &, ConstrainedMobilizerIndex) const
 Return the number of constrainable generalized coordinates q associated with a particular constrained mobilizer. More...
 
int getNumConstrainedU (const State &, ConstrainedMobilizerIndex) const
 Return the number of constrainable mobilities u associated with a particular constrained mobilizer. More...
 
ConstrainedUIndex getConstrainedUIndex (const State &, ConstrainedMobilizerIndex, MobilizerUIndex which) const
 Return the index into the constrained mobilities u array corresponding to a particular mobility of the indicated ConstrainedMobilizer. More...
 
ConstrainedQIndex getConstrainedQIndex (const State &, ConstrainedMobilizerIndex, MobilizerQIndex which) const
 Return the index into the constrained coordinates q array corresponding to a particular coordinate of the indicated ConstrainedMobilizer. More...
 
int getNumConstrainedQ (const State &) const
 Return the sum of the number of coordinates q associated with each of the constrained mobilizers. More...
 
int getNumConstrainedU (const State &) const
 Return the sum of the number of mobilities u associated with each of the constrained mobilizers. More...
 
QIndex getQIndexOfConstrainedQ (const State &state, ConstrainedQIndex consQIndex) const
 Map one of this Constraint's constrained q's to the corresponding index within the matter subsystem's whole q vector. More...
 
UIndex getUIndexOfConstrainedU (const State &state, ConstrainedUIndex consUIndex) const
 Map one of this Constraint's constrained U's (or mobilities) to the corresponding index within the matter subsystem's whole u vector. More...
 
void getNumConstraintEquationsInUse (const State &state, int &mp, int &mv, int &ma) const
 Find out how many holonomic (position), nonholonomic (velocity), and acceleration-only constraint equations are currently being generated by this Constraint. More...
 
void getIndexOfMultipliersInUse (const State &state, MultiplierIndex &px0, MultiplierIndex &vx0, MultiplierIndex &ax0) const
 Return the start of the blocks of multipliers (or acceleration errors) assigned to this Constraint. More...
 
void setMyPartInConstraintSpaceVector (const State &state, const Vector &myPart, Vector &constraintSpace) const
 Set the part of a complete constraint-space vector that belongs to this constraint. More...
 
void getMyPartFromConstraintSpaceVector (const State &state, const Vector &constraintSpace, Vector &myPart) const
 Get the part of a complete constraint-space vector that belongs to this constraint. More...
 
Vector getPositionErrorsAsVector (const State &) const
 Get a Vector containing the position errors. More...
 
Vector calcPositionErrorFromQ (const State &, const Vector &q) const
 
Matrix calcPositionConstraintMatrixP (const State &) const
 
Matrix calcPositionConstraintMatrixPt (const State &) const
 
Matrix calcPositionConstraintMatrixPNInv (const State &) const
 
void calcConstraintForcesFromMultipliers (const State &, const Vector &lambda, Vector_< SpatialVec > &bodyForcesInA, Vector &mobilityForces) const
 This operator calculates this constraint's body and mobility forces given the complete set of multipliers lambda for this Constraint. More...
 
Vector getVelocityErrorsAsVector (const State &) const
 Get a Vector containing the velocity errors. More...
 
Vector calcVelocityErrorFromU (const State &, const Vector &u) const
 
Matrix calcVelocityConstraintMatrixV (const State &) const
 
Matrix calcVelocityConstraintMatrixVt (const State &) const
 
Vector getAccelerationErrorsAsVector (const State &) const
 Get a Vector containing the acceleration errors. More...
 
Vector calcAccelerationErrorFromUDot (const State &, const Vector &udot) const
 
Vector getMultipliersAsVector (const State &) const
 Get a Vector containing the Lagrange multipliers. More...
 
void getConstraintForcesAsVectors (const State &state, Vector_< SpatialVec > &bodyForcesInG, Vector &mobilityForces) const
 Given a State realized through Acceleration stage, return the forces that were applied to the system by this Constraint, with body forces expressed in Ground. More...
 
Vector_< SpatialVecgetConstrainedBodyForcesAsVector (const State &state) const
 For convenience, returns constrained body forces as the function return. More...
 
Vector getConstrainedMobilityForcesAsVector (const State &state) const
 For convenience, returns constrained mobility forces as the function return. More...
 
Real calcPower (const State &state) const
 Calculate the power being applied by this Constraint to the system. More...
 
Matrix calcAccelerationConstraintMatrixA (const State &) const
 
Matrix calcAccelerationConstraintMatrixAt (const State &) const
 
void setIsConditional (bool isConditional)
 (Advanced) Mark this constraint as one that is only conditionally active. More...
 
bool isConditional () const
 (Advanced) Get the value of the isConditional flag. More...
 
- Public Member Functions inherited from SimTK::PIMPLHandle< Constraint, ConstraintImpl, 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 Constraint &other) const
 Determine whether the supplied handle is the same object as "this" PIMPLHandle. More...
 
void disown (Constraint &newOwner)
 Give up ownership of the implementation to an empty handle. More...
 
PIMPLHandlereferenceAssign (const Constraint &source)
 "Copy" assignment but with shallow (pointer) semantics. More...
 
PIMPLHandlecopyAssign (const Constraint &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 ConstraintImpl & getImpl () const
 Get a const reference to the implementation associated with this Handle. More...
 
ConstraintImpl & 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

- Protected Member Functions inherited from SimTK::PIMPLHandle< Constraint, ConstraintImpl, true >
 PIMPLHandle ()
 The default constructor makes this an empty handle. More...
 
 PIMPLHandle (ConstraintImpl *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 (ConstraintImpl *p)
 Set the implementation for this empty handle. More...
 
bool hasSameImplementation (const Constraint &other) const
 Determine whether the supplied handle is a reference to the same implementation object as is referenced by "this" PIMPLHandle. More...
 

Detailed Description

This is the base class for all Constraint classes, which is just a handle for the underlying hidden implementation.

There is a set of built-in constraints and a generic "Custom" constraint (an abstract base class) from which advanced users may derive their own constraints. Each built-in constraint type is a local subclass within Constraint, and is also derived from Constraint.

Constraint is a PIMPL-style abstract base class, with concrete classes defined for each kind of constraint.

Member Typedef Documentation

◆ ConstantDistance

Synonym for Rod constraint.

◆ CoincidentPoints

Synonym for Ball constraint.

◆ Spherical

Synonym for Ball constraint.

◆ CoincidentFrames

Constructor & Destructor Documentation

◆ Constraint() [1/2]

SimTK::Constraint::Constraint ( )
inline

Default constructor creates an empty Constraint handle that can be used to reference any Constraint.

◆ Constraint() [2/2]

SimTK::Constraint::Constraint ( ConstraintImpl *  r)
inlineexplicit

For internal use: construct a new Constraint handle referencing a particular implementation object.

Member Function Documentation

◆ disable()

void SimTK::Constraint::disable ( State ) const

Disable this Constraint, effectively removing it from the system.

This is an Instance-stage change and affects the allocation of Constraint- related resources in the supplied State.

◆ enable()

void SimTK::Constraint::enable ( State ) const

Enable this Constraint, without necessarily satisfying it.

This is an Instance-stage change and affects the allocation of Constraint-related
resources in the supplied State. Note that merely enabling a constraint does not ensure that the State's positions and velocities satisfy that constraint; initial satisfaction requires use of an appropriate project() solver.

See also
SimTK::System::project()

◆ isDisabled()

bool SimTK::Constraint::isDisabled ( const State ) const

Test whether this constraint is currently disabled in the supplied State.

◆ isDisabledByDefault()

bool SimTK::Constraint::isDisabledByDefault ( ) const

Test whether this Constraint is disabled by default in which case it must be explicitly enabled before it will take effect.

See also
setDisabledByDefault(), enable()

◆ setDisabledByDefault()

void SimTK::Constraint::setDisabledByDefault ( bool  shouldBeDisabled)

Normally Constraints are enabled when defined and can be disabled later.

If you want to define this constraint but have it be off by default, use this method.

See also
isDisabledByDefault(), enable(), disable(), isDisabled()

◆ operator ConstraintIndex()

SimTK::Constraint::operator ConstraintIndex ( ) const
inline

This is an implicit conversion from Constraint to ConstraintIndex when needed.

This will fail if the Constraint is not contained in a subsystem.

◆ getMatterSubsystem()

const SimbodyMatterSubsystem& SimTK::Constraint::getMatterSubsystem ( ) const

Get a const reference to the matter subsystem that contains this Constraint.

This will throw an exception if the Constraint has not yet been added to any subsystem; if you aren't sure use isInSubsystem() first to check.

See also
updMatterSubsystem(), isInSubsystem(), getConstraintIndex()

◆ updMatterSubsystem()

SimbodyMatterSubsystem& SimTK::Constraint::updMatterSubsystem ( )

Assuming you have writable access to this Constraint, get a writable reference to the containing matter subsystem.

This will throw an exception if the Constraint has not yet been added to any subsystem; if you aren't sure use isInSubsystem() first to check.

See also
getMatterSubsystem(), isInSubsystem(), getConstraintIndex()

◆ getConstraintIndex()

ConstraintIndex SimTK::Constraint::getConstraintIndex ( ) const

Get the ConstraintIndex that was assigned to this Constraint when it was added to the matter subsystem.

This will throw an exception if the Constraint has not yet been added to any subsystem; if you aren't sure use isInSubsystem() first to check. There is also an implicit conversion from Constraint to ConstraintIndex, so you don't normally need to call this directly.

See also
getMatterSubsystem(), isInSubsystem()

◆ isInSubsystem()

bool SimTK::Constraint::isInSubsystem ( ) const

Test whether this Constraint is contained within a matter subsystem.

◆ isInSameSubsystem()

bool SimTK::Constraint::isInSameSubsystem ( const MobilizedBody mobod) const

Test whether the supplied MobilizedBody is in the same matter subsystem as this Constraint.

Also returns false if either the Constraint or the MobilizedBody is not in any subsystem, or if neither is.

◆ getNumConstrainedBodies()

int SimTK::Constraint::getNumConstrainedBodies ( ) const

Return the number of unique bodies directly restricted by this constraint.

Included are any bodies to which this Constraint may apply a body force (i.e., torque or point force). The Ancestor body is not included unless it was specified as a Constrained Body. This is the length of the bodyForces array for this Constraint.

◆ getMobilizedBodyFromConstrainedBody()

const MobilizedBody& SimTK::Constraint::getMobilizedBodyFromConstrainedBody ( ConstrainedBodyIndex  consBodyIx) const

Return a const reference to the actual MobilizedBody corresponding to one of the Constrained Bodies included in the count returned by getNumConstrainedBodies().

The index must be in the range 0 <= consBodyIx < getNumConstrainedBodies().

◆ getAncestorMobilizedBody()

const MobilizedBody& SimTK::Constraint::getAncestorMobilizedBody ( ) const

Return a const reference to the actual MobilizedBody which is serving as the Ancestor body for the constrained bodies in this Constraint.

This will fail if there are no constrained bodies (i.e., if getNumConstrainedBodies()==0).

◆ getNumConstrainedMobilizers()

int SimTK::Constraint::getNumConstrainedMobilizers ( ) const

Return the number of unique mobilizers directly restricted by this Constraint.

Included are any mobilizers to which the Constraint may apply any mobility force. Like bodies, mobilizers are referenced using the MobilizedBody containing them. Note that all the mobilities of a Constrained Mobilizer are included in the set of constrainable Qs or constrainable Us for this Constraint even if not all of them are constrained.

◆ getMobilizedBodyFromConstrainedMobilizer()

const MobilizedBody& SimTK::Constraint::getMobilizedBodyFromConstrainedMobilizer ( ConstrainedMobilizerIndex  consMobilizerIx) const

Return a const reference to the actual MobilizedBody corresponding to one of the Constrained Mobilizers included in the count returned by getNumConstrainedMobilizers().

The index must be in the range 0 <= consMobilizerIx < getNumConstrainedMobilizers().

◆ getSubtree()

const SimbodyMatterSubtree& SimTK::Constraint::getSubtree ( ) const

Return a subtree object indicating which parts of the multibody tree are potentially affected by this Constraint.

◆ getNumConstrainedQ() [1/2]

int SimTK::Constraint::getNumConstrainedQ ( const State ,
ConstrainedMobilizerIndex   
) const

Return the number of constrainable generalized coordinates q associated with a particular constrained mobilizer.

This is just the number of generalized coordinates for that mobilizer; any or all of them may actually be unconstrained.

◆ getNumConstrainedU() [1/2]

int SimTK::Constraint::getNumConstrainedU ( const State ,
ConstrainedMobilizerIndex   
) const

Return the number of constrainable mobilities u associated with a particular constrained mobilizer.

This is just the number of generalized speeds for that mobilizer; any or all of them may actually be unconstrained. The number of constrainable udots is the same.

◆ getConstrainedUIndex()

ConstrainedUIndex SimTK::Constraint::getConstrainedUIndex ( const State ,
ConstrainedMobilizerIndex  ,
MobilizerUIndex  which 
) const

Return the index into the constrained mobilities u array corresponding to a particular mobility of the indicated ConstrainedMobilizer.

Don't confuse this with the set of participating mobilities which also includes all mobilities on each branch between the ancestor and a constrained body. The constrained mobilities are just those belonging to the mobilizers which are directly constrained.

◆ getConstrainedQIndex()

ConstrainedQIndex SimTK::Constraint::getConstrainedQIndex ( const State ,
ConstrainedMobilizerIndex  ,
MobilizerQIndex  which 
) const

Return the index into the constrained coordinates q array corresponding to a particular coordinate of the indicated ConstrainedMobilizer.

Don't confuse this with the set of participating coordinates which also includes all coordinates on each branch between the ancestor and a constrained body. The constrained coordinates are just those belonging to the mobilizers which are directly constrained.

◆ getNumConstrainedQ() [2/2]

int SimTK::Constraint::getNumConstrainedQ ( const State ) const

Return the sum of the number of coordinates q associated with each of the constrained mobilizers.

◆ getNumConstrainedU() [2/2]

int SimTK::Constraint::getNumConstrainedU ( const State ) const

Return the sum of the number of mobilities u associated with each of the constrained mobilizers.

These are the only mobilities to which the constraint may directly apply a force, so this is also the dimension of the mobilityForces array.

◆ getQIndexOfConstrainedQ()

QIndex SimTK::Constraint::getQIndexOfConstrainedQ ( const State state,
ConstrainedQIndex  consQIndex 
) const

Map one of this Constraint's constrained q's to the corresponding index within the matter subsystem's whole q vector.

◆ getUIndexOfConstrainedU()

UIndex SimTK::Constraint::getUIndexOfConstrainedU ( const State state,
ConstrainedUIndex  consUIndex 
) const

Map one of this Constraint's constrained U's (or mobilities) to the corresponding index within the matter subsystem's whole u vector.

◆ getNumConstraintEquationsInUse()

void SimTK::Constraint::getNumConstraintEquationsInUse ( const State state,
int &  mp,
int &  mv,
int &  ma 
) const

Find out how many holonomic (position), nonholonomic (velocity), and acceleration-only constraint equations are currently being generated by this Constraint.

Parameters
[in]stateThe State from which the current status of this Constraint is obtained. Must have been realized through Instance stage.
[out]mpThe number of holonomic constraint equations.
[out]mvThe number of nonholonomic constraint equations.
[out]maThe number of acceleration-only constraint equations.

Note that the counts here do not include the derivatives of the higher-order constraint equations, just the number at the level they were defined.

◆ getIndexOfMultipliersInUse()

void SimTK::Constraint::getIndexOfMultipliersInUse ( const State state,
MultiplierIndex px0,
MultiplierIndex vx0,
MultiplierIndex ax0 
) const

Return the start of the blocks of multipliers (or acceleration errors) assigned to this Constraint.

Separate blocks are allocated for holonomic (position), nonholonomic (velocity), and acceleration-only constraint equations. The size of each block is given by getNumConstraintEquationsInUse(); this Constraint's multipliers are assigned contiguously within each block. If any size is zero, the corresponding index is returned invalid.

Parameters
[in]stateThe State from which the current status of this Constraint is obtained. Must have been realized through Instance stage.
[out]px0
The index of the first slot for the second time derivatives of position (holonomic) constraint equations.
[out]vx0The index of the first slot for the time derivatives of velocity (nonholonomic) constraint equations.
[out]ax0The index of the first slot for the acceleration-only constraint equations.

For position and velocity constraints, the multiplier slots correspond to the time derivatives of these constraints that are used to create acceleration constraints from them.

◆ setMyPartInConstraintSpaceVector()

void SimTK::Constraint::setMyPartInConstraintSpaceVector ( const State state,
const Vector myPart,
Vector constraintSpace 
) const

Set the part of a complete constraint-space vector that belongs to this constraint.

The full vector has dimension m=mp+mv+ma, that is, one entry per acceleration-level constraint equation.

Parameters
[in]stateThe State from which the current status of this Constraint is obtained. Must have been realized through Instance stage.
[in]myPartThe constraint-space scalars for this Constraint in the order position, velocity, acceleration if this Constraint produces constraint equations of different types. The number of entries must match the number of constraint equations generated by this Constraint.
[in,out]constraintSpaceAn array of full constraint space dimension m. If it has length zero on entry we'll resize it to m and initialize it to zero, otherwise the size must be exactly m and we'll only modify the slots that belong to this Constraint.

Note that we're writing only to the output argument; this method does not calculate or modify anything else.

See also
getMyPartFromConstraintSpaceVector(), getIndexOfMultipliersInUse()

◆ getMyPartFromConstraintSpaceVector()

void SimTK::Constraint::getMyPartFromConstraintSpaceVector ( const State state,
const Vector constraintSpace,
Vector myPart 
) const

Get the part of a complete constraint-space vector that belongs to this constraint.

The full vector has dimension m=mp+mv+ma, that is, one entry per acceleration-level constraint equation.

Parameters
[in]stateThe State from which the current status of this Constraint is obtained. Must have been realized through Instance stage.
[in]constraintSpaceAn array of full constraint space dimension m. We will only examine the entries belonging to this Constraint.
[out]myPartThe constraint-space scalars for this Constraint in the order position, velocity, acceleration if this Constraint produces constraint equations of different types. The number of entries will match the number of constraint equations generated by this Constraint and the argument will be resized if necessary.
See also
setMyPartInConstraintSpaceVector(), getIndexOfMultipliersInUse()

◆ getPositionErrorsAsVector()

Vector SimTK::Constraint::getPositionErrorsAsVector ( const State ) const

Get a Vector containing the position errors.

Many subclasses provide their own methods for getting this information in a more specific form.

◆ calcPositionErrorFromQ()

Vector SimTK::Constraint::calcPositionErrorFromQ ( const State ,
const Vector q 
) const

◆ calcPositionConstraintMatrixP()

Matrix SimTK::Constraint::calcPositionConstraintMatrixP ( const State ) const

◆ calcPositionConstraintMatrixPt()

Matrix SimTK::Constraint::calcPositionConstraintMatrixPt ( const State ) const

◆ calcPositionConstraintMatrixPNInv()

Matrix SimTK::Constraint::calcPositionConstraintMatrixPNInv ( const State ) const

◆ calcConstraintForcesFromMultipliers()

void SimTK::Constraint::calcConstraintForcesFromMultipliers ( const State ,
const Vector lambda,
Vector_< SpatialVec > &  bodyForcesInA,
Vector mobilityForces 
) const

This operator calculates this constraint's body and mobility forces given the complete set of multipliers lambda for this Constraint.

We expect that lambda has been packed to include multipliers associated with the second time derivatives of the position (holonomic) constraints, the first time derivatives of the velocity (nonholonomic) constraints, and the acceleration-only constraints, in that order.

The state must be realized already to Stage::Velocity. Returned body forces correspond only to the constrained bodies and the mobility forces correspond only to the constrained mobilities; they must be unpacked by the caller into the actual system mobilized bodies and actual system mobilities. Note that the body forces are in the ancestor body frame A, not necessarily the Ground frame G, and that they are opposite in sign from applied forces. If you want to calculate forces you can treat as applied forces, negate lambda before the call.

◆ getVelocityErrorsAsVector()

Vector SimTK::Constraint::getVelocityErrorsAsVector ( const State ) const

Get a Vector containing the velocity errors.

Many subclasses provide their own methods for getting this information in a more specific form.

◆ calcVelocityErrorFromU()

Vector SimTK::Constraint::calcVelocityErrorFromU ( const State ,
const Vector u 
) const

◆ calcVelocityConstraintMatrixV()

Matrix SimTK::Constraint::calcVelocityConstraintMatrixV ( const State ) const

◆ calcVelocityConstraintMatrixVt()

Matrix SimTK::Constraint::calcVelocityConstraintMatrixVt ( const State ) const

◆ getAccelerationErrorsAsVector()

Vector SimTK::Constraint::getAccelerationErrorsAsVector ( const State ) const

Get a Vector containing the acceleration errors.

Many subclasses provide their own methods for getting this information in a more specific form.

◆ calcAccelerationErrorFromUDot()

Vector SimTK::Constraint::calcAccelerationErrorFromUDot ( const State ,
const Vector udot 
) const

◆ getMultipliersAsVector()

Vector SimTK::Constraint::getMultipliersAsVector ( const State ) const

Get a Vector containing the Lagrange multipliers.

Many subclasses provide their own methods for getting this information in a more specific form.

◆ getConstraintForcesAsVectors()

void SimTK::Constraint::getConstraintForcesAsVectors ( const State state,
Vector_< SpatialVec > &  bodyForcesInG,
Vector mobilityForces 
) const

Given a State realized through Acceleration stage, return the forces that were applied to the system by this Constraint, with body forces expressed in Ground.

Note that the sign convention for constraint forces is opposite that of applied forces, because constraints appear on the left hand side in Simbody's equations of motion, while applied forces are on the right hand side.

These forces are the same as what you would get if you get the multipliers from this state using getMultipliersAsVector(), call calcConstraintForcesFromMultipliers(), and re-express the constrained body forces in the Ground frame. However, the ones returned here are already calculated so require only copying out of the state cache.

◆ getConstrainedBodyForcesAsVector()

Vector_<SpatialVec> SimTK::Constraint::getConstrainedBodyForcesAsVector ( const State state) const
inline

For convenience, returns constrained body forces as the function return.

See also
getConstraintForcesAsVectors()

◆ getConstrainedMobilityForcesAsVector()

Vector SimTK::Constraint::getConstrainedMobilityForcesAsVector ( const State state) const
inline

For convenience, returns constrained mobility forces as the function return.

See also
getConstraintForcesAsVectors()

◆ calcPower()

Real SimTK::Constraint::calcPower ( const State state) const

Calculate the power being applied by this Constraint to the system.

The state must be realized through Acceleration stage so that the applied constraint forces are known. Then power is calculated as the dot product of the applied body spatial forces and body spatial velocities, plus the dot product of the applied mobility forces and corresponding mobilities (generalized speeds) u. I emphasized applied here because the sign convention is opposite for constraint forces, so the power calculation requires negating the constraint forces.

For any non-working Constraint, power should always be within machine precision of zero. This is a very useful test when debugging new Constraints. For working Constraints, you can calculate work done as the time integral of the power. Then if you embed the Constraint in an otherwise conservative system, the sum of system potential and kinetic energy, minus the work done by this constraint, should be constant to within integration accuracy. Power and work here are signed quantities with positive sign meaning that the Constraint is adding energy to the system and negative meaning it is removing energy from the system.

Computational cost here is low because the forces and velocities are already known. Only the dot product need be computed, at a cost of about 11 ncb + 2 ncu flops, where ncb is the number of constrained bodies and ncu is the number of constrained mobilities for this Constraint.

◆ calcAccelerationConstraintMatrixA()

Matrix SimTK::Constraint::calcAccelerationConstraintMatrixA ( const State ) const

◆ calcAccelerationConstraintMatrixAt()

Matrix SimTK::Constraint::calcAccelerationConstraintMatrixAt ( const State ) const

◆ setIsConditional()

void SimTK::Constraint::setIsConditional ( bool  isConditional)

(Advanced) Mark this constraint as one that is only conditionally active.

The conditions under which it is active must be evaluated elsewhere. This should be set immediately after construction of the Constraint and invalidates Stage::Topology.

◆ isConditional()

bool SimTK::Constraint::isConditional ( ) const

(Advanced) Get the value of the isConditional flag.


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