Simbody
3.6

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...
Public Member Functions  
Construction  
Methods in this section refer both to constructors, and to methods that can be used to set or change construction (Topologystage) parameters; these specify the values assigned by default to the corresponding state variables. Note:
The default parameters can be overridden in any given State, and modified without affecting Topology; see the "Runtime Changes" section below.  
Rod (MobilizedBody &mobod1, const Vec3 &defaultPointOnBody1, MobilizedBody &mobod2, const Vec3 &defaultPointOnBody2, Real defaultRodLength)  
Construct a Rod (constant distance) constraint as described in the Constraint::Rod class documentation. More...  
Rod (MobilizedBody &mobod1, MobilizedBody &mobod2, Real defaultRodLength)  
Construct a Rod (constant distance) constraint as described in the Constraint::Rod class documentation, but using the body origins as the Rod end points. More...  
Rod ()  
Default constructor creates an empty handle that can be used to reference any Rod Constraint. More...  
const MobilizedBody &  getMobilizedBody1 () const 
Return a reference to the first MobilizedBody given in the constructor. More...  
const MobilizedBody &  getMobilizedBody2 () const 
Return a reference to the second MobilizedBody given in the constructor. More...  
Rod &  setDefaultPointOnBody1 (const Vec3 &defaultPoint) 
Replace the default location for the point attached to the first body, mobod1, that was supplied on construction. More...  
Rod &  setDefaultPointOnBody2 (const Vec3 &defaultPoint) 
Replace the default location for the point attached to the second body, mobod2, that was supplied on construction. More...  
Rod &  setDefaultRodLength (Real defaultRodLength) 
Replace the default rod length (distance), replacing whatever value was supplied on construction. More...  
const Vec3 &  getDefaultPointOnBody1 () const 
Return the default location for the point attached to the first mobilized body, mobod1, as set during construction or by the most recent call to setDefaultPointOnBody1(). More...  
const Vec3 &  getDefaultPointOnBody2 () const 
Return the default location for the point attached to the second mobilized body, mobod2, as set during construction or by the most recent call to setDefaultPointOnBody2(). More...  
Real  getDefaultRodLength () const 
Return the default rod length (distance) as set during construction or by the most recent call to setDefaultRodLength(). More...  
Runtime Changes  
These refer to Positionstage discrete state variables that determine the sphere parameters to be used to calculate constraint forces from a given State object. If these are not set explicitly, the parameters are set to those provided in the constructor or via the corresponding setDefault...() methods. Note:
You can also modify and examine the default parameters; see the "Construction" section above.  
const Rod &  setPointOnBody1 (State &state, const Vec3 &p_B1P) const 
Modify the location of the point P on the first body, mobod1, in this state by providing a new vector p_B1P giving the location of P measured from body 1's origin, and expressed in the B1 frame. More...  
const Rod &  setPointOnBody2 (State &state, const Vec3 &p_B2Q) const 
Modify the location of the point Q on the second body, mobod2, in this state by providing a new vector p_B2Q giving the location of Q measured from body 2's origin, and expressed in the B2 frame. More...  
const Rod &  setRodLength (State &state, Real rodLength) const 
Modify the rod length (distance) in this state. More...  
const Vec3 &  getPointOnBody1 (const State &state) const 
Return the position on body 1 of the rod end point P on the first body, mobod1, as currently set in the given state. More...  
const Vec3 &  getPointOnBody2 (const State &state) const 
Return the position on body 2 of the rod end point Q attached to the second body, mobod2, as currently set in the given state. More...  
Real  getRodLength (const State &state) const 
Return the rod length (distance) as currently set in the given state. More...  
Computations  
Methods here provide access to values already calculated by this constraint element, and provide operators you can call to calculate related values.  
Real  getPositionError (const State &) const 
This is the signed violation of the position constraint, in length units. More...  
Real  getVelocityError (const State &) const 
This is the time derivative of the value returned by getPositionError(); in this case it is the relative velocity of the two points projected onto the direction of the line between them. More...  
Real  getAccelerationError (const State &) const 
This is the time derivative of the value returned by getVelocityError(). More...  
Real  getMultiplier (const State &) const 
This is the Lagrange multiplier required to enforce the constraint equation generated here. More...  
Real  getRodTension (const State &) const 
This returns the tension in the Rod being used to enforce the constraint. More...  
UnitVec3  findRodOrientationInG (const State &state) const 
Return the instantaneous orientation of the Rod in the Ground frame. More...  
Real  findLengthViolation (const State &state) const 
Calculate the amount by which this constraint is violated. More...  
Advanced/Obscure/Obsolete/Debugging  
You probably don't want to use the methods in this section.  
MobilizedBodyIndex  getBody1MobilizedBodyIndex () const 
(Obscure) Use getMobilizedBody1() instead. More...  
MobilizedBodyIndex  getBody2MobilizedBodyIndex () const 
(Obscure) Use getMobilizedBody2() instead. More...  
Public Member Functions inherited from SimTK::Constraint  
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 SimbodyMatterSubsystem &  getMatterSubsystem () const 
Get a const reference to the matter subsystem that contains this Constraint. More...  
SimbodyMatterSubsystem &  updMatterSubsystem () 
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 MobilizedBody &  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(). More...  
const MobilizedBody &  getAncestorMobilizedBody () 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 MobilizedBody &  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(). More...  
const SimbodyMatterSubtree &  getSubtree () 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 accelerationonly 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 constraintspace vector that belongs to this constraint. More...  
void  getMyPartFromConstraintSpaceVector (const State &state, const Vector &constraintSpace, Vector &myPart) const 
Get the part of a complete constraintspace 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_< SpatialVec >  getConstrainedBodyForcesAsVector (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...  
PIMPLHandle &  referenceAssign (const Constraint &source) 
"Copy" assignment but with shallow (pointer) semantics. More...  
PIMPLHandle &  copyAssign (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  
Public Types inherited from SimTK::Constraint  
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 
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 nonvirtual. More...  
PIMPLHandle &  operator= (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...  
This constraint consists of one constraint equation that enforces a constant distance between a point on one body and a point on another body.
This is like connecting them by a rigid, massless rod with ball joints at either end. The constraint is enforced by a force acting along the rod with opposite signs at either end. When positive, this represents tension in the rod pulling the points together; when negative it represents compression keeping the points separated.
SimTK::Constraint::Rod::Rod  (  MobilizedBody &  mobod1, 
const Vec3 &  defaultPointOnBody1,  
MobilizedBody &  mobod2,  
const Vec3 &  defaultPointOnBody2,  
Real  defaultRodLength  
) 
Construct a Rod (constant distance) constraint as described in the Constraint::Rod class documentation.
mobod1  The first MobilizedBody object to which one of the rod endpoints is fixed. 
defaultPointOnBody1  This is the location of a point P on mobod1, given as a vector p_B1P from the B1 frame origin to the point P, expressed in the mobod1 body frame B1. This is the point location that will be present in a default State; you can modify it later. 
mobod2  The second MobilizedBody object to which the other rod endpoint is fixed. 
defaultPointOnBody2  This is the location of a point Q on mobod2, given as a vector p_B2Q from the B2 frame origin to the point Q, expressed in the mobod2 body frame B2. This is the point location that will be present in a default State; you can modify it later. 
defaultRodLength  The rod length (required distance between points P and Q). This is the value that will be present in a default State; you can modify it later. 
SimTK::Constraint::Rod::Rod  (  MobilizedBody &  mobod1, 
MobilizedBody &  mobod2,  
Real  defaultRodLength  
) 
Construct a Rod (constant distance) constraint as described in the Constraint::Rod class documentation, but using the body origins as the Rod end points.
mobod1  The first MobilizedBody object whose origin is used as one of the end points. This is the same as specifying Vec3(0) for defaultPointOnBody1 in the preceding constructor. This is the value that will be present in a default State; you can modify it later. 
mobod2  The second MobilizedBody object whose origin is used as one of the end points. This is the same as specifying Vec3(0) for defaultPointOnBody2 in the preceding constructor. This is the value that will be present in a default State; you can modify it later. 
defaultRodLength  The rod length (required distance between points P and Q). This is the value that will be present in a default State; you can modify it later. 

inline 
Default constructor creates an empty handle that can be used to reference any Rod Constraint.
const MobilizedBody& SimTK::Constraint::Rod::getMobilizedBody1  (  )  const 
Return a reference to the first MobilizedBody given in the constructor.
This cannot be changed after construction.
const MobilizedBody& SimTK::Constraint::Rod::getMobilizedBody2  (  )  const 
Return a reference to the second MobilizedBody given in the constructor.
This cannot be changed after construction.
Replace the default location for the point attached to the first body, mobod1, that was supplied on construction.
This is a topological change; you'll have to call realizeTopology() again if you call this method.
Replace the default location for the point attached to the second body, mobod2, that was supplied on construction.
This is a topological change; you'll have to call realizeTopology() again if you call this method.
Replace the default rod length (distance), replacing whatever value was supplied on construction.
This is a topological change; you'll have to call realizeTopology() again if you call this method.
const Vec3& SimTK::Constraint::Rod::getDefaultPointOnBody1  (  )  const 
Return the default location for the point attached to the first mobilized body, mobod1, as set during construction or by the most recent call to setDefaultPointOnBody1().
const Vec3& SimTK::Constraint::Rod::getDefaultPointOnBody2  (  )  const 
Return the default location for the point attached to the second mobilized body, mobod2, as set during construction or by the most recent call to setDefaultPointOnBody2().
Real SimTK::Constraint::Rod::getDefaultRodLength  (  )  const 
Return the default rod length (distance) as set during construction or by the most recent call to setDefaultRodLength().
Modify the location of the point P on the first body, mobod1, in this state by providing a new vector p_B1P giving the location of P measured from body 1's origin, and expressed in the B1 frame.
This overrides the defaultPointOnBody1 in the given state, whose Stage::Position is invalidated.
Modify the location of the point Q on the second body, mobod2, in this state by providing a new vector p_B2Q giving the location of Q measured from body 2's origin, and expressed in the B2 frame.
This overrides the defaultPointOnBody2 in the given state, whose Stage::Position is invalidated.
Modify the rod length (distance) in this state.
This overrides the defaultRodLength in the given state, whose Stage::Position is invalidated.
Return the position on body 1 of the rod end point P on the first body, mobod1, as currently set in the given state.
The value is returned as a vector p_B1P from body 1's origin to the point P, expressed in the B1 frame.
Return the position on body 2 of the rod end point Q attached to the second body, mobod2, as currently set in the given state.
The value is returned as a vector p_B2Q from body 2's origin to the point Q, expressed in the B2 frame.
Return the rod length (distance) as currently set in the given state.
This is the signed violation of the position constraint, in length units.
It is positive when the two points are separated by more than the required distance; negative when closer than the required distance. The given state must have already been realized through Stage::Position.
This is the time derivative of the value returned by getPositionError(); in this case it is the relative velocity of the two points projected onto the direction of the line between them.
This is the time derivative of the value returned by getVelocityError().
This is the Lagrange multiplier required to enforce the constraint equation generated here.
For this Constraint it has units of force, but recall that the sign convention for multipliers is opposite that of forces. Use the other provided methods if you want to get meaningful forces. The given state must already be realized to Stage::Acceleration.
This returns the tension in the Rod being used to enforce the constraint.
It is positive if the Rod is in tension, negative if in compression. The result is zero if the constraint is currently disabled. The given state must already be realized to Stage::Acceleration.
Return the instantaneous orientation of the Rod in the Ground frame.
This is a unit vector along the direction from point1 (on body 1) to point2 (on body 2), unless the points overlap in which case it is an arbitrary direction. This method calculates a valid value even if this constraint is currently disabled. The given state must already be realized to Stage::Position.
Calculate the amount by which this constraint is violated.
It is positive when the distance between the points is greater than the specified Rod length, negative when less. If the constraint is currently enabled then this returns the same value as getPositionError(); however, this method calculates a valid value even if the constraint is currently disabled. The given state must be realized to Stage::Position.
MobilizedBodyIndex SimTK::Constraint::Rod::getBody1MobilizedBodyIndex  (  )  const 
(Obscure) Use getMobilizedBody1() instead.
MobilizedBodyIndex SimTK::Constraint::Rod::getBody2MobilizedBodyIndex  (  )  const 
(Obscure) Use getMobilizedBody2() instead.