Simbody  3.6
SimTK::QValue Class Reference

This AssemblyCondition requests that a particular generalized coordinate end up with a specified value. More...

+ Inheritance diagram for SimTK::QValue:

Public Member Functions

 QValue (MobilizedBodyIndex mbx, MobilizerQIndex qx, Real value)
 Construct an assembly condition that requests that the specified generalized coordinate be brought to the indicated value. More...
 
Real getValue () const
 Return the currently set value to be used for this generalized coordinate. More...
 
void setValue (Real newValue)
 Change the value to be used for this generalized coordinate; this can be done repeatedly during tracking to follow changing requirements. More...
 
int getNumEquations (const State &) const
 
int calcErrors (const State &state, Vector &error) const override
 Calculate the amount by which this assembly condition is violated by the q values in the given state, with one scalar error per assembly equation returned in err. More...
 
int calcErrorJacobian (const State &state, Matrix &J) const override
 Override to supply an analytic Jacobian for the assembly errors returned by calcErrors(). More...
 
int calcGoal (const State &state, Real &goal) const override
 Calculate the current contribution (>= 0) of this assembly condition to the goal value that is being minimized. More...
 
int calcGoalGradient (const State &state, Vector &grad) const override
 Override to supply an analytic gradient for this assembly condition's goal. More...
 
- Public Member Functions inherited from SimTK::AssemblyCondition
 AssemblyCondition (const String &name)
 Base class constructor just takes the assembly condition name and saves it. More...
 
virtual ~AssemblyCondition ()
 Destructor is virtual for use by derived classes. More...
 
virtual int initializeCondition () const
 This is called whenever the Assembler is initialized in case this assembly condition wants to do some internal work before getting started. More...
 
virtual void uninitializeCondition () const
 This is called whenever the containing Assembler is uninitialized in case this assembly condition has some cleanup to do. More...
 
virtual int getNumErrors (const State &state) const
 Override to supply an efficient method for determining how many errors will be returned by calcErrors(). More...
 
const char * getName () const
 Return the name assigned to this AssemblyCondition on construction. More...
 
bool isInAssembler () const
 Test whether this AssemblyCondition has already been adopted by an Assembler. More...
 
const AssemblergetAssembler () const
 Return the Assembler that has adopted this AssemblyCondition. More...
 
AssemblyConditionIndex getAssemblyConditionIndex () const
 Return the AssemblyConditionIndex of this concrete AssemblyCondition within the Assembler that has adopted it. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SimTK::AssemblyCondition
int getNumFreeQs () const
 Ask the assembler how many free q's there are; only valid after initialization but does not invoke initialization. More...
 
QIndex getQIndexOfFreeQ (Assembler::FreeQIndex fx) const
 Ask the assembler where to find the actual q in the State that corresponds to a given free q; only valid after initialization but does not invoke initialization. More...
 
Assembler::FreeQIndex getFreeQIndexOfQ (QIndex qx) const
 Ask the assembler where to find the free q (if any) that corresponds to a given q in the State; only valid after initialization but does not invoke initialization. More...
 
const MultibodySystemgetMultibodySystem () const
 Ask the assembler for the MultibodySystem with which it is associated. More...
 
const SimbodyMatterSubsystemgetMatterSubsystem () const
 Ask the assembler for the MultibodySystem with which it is associated and extract the SimbodyMatterSubsystem contained therein. More...
 
void initializeAssembler () const
 Call this method before doing anything that logically requires the Assembler, or at least this AssemblyCondition, to have been initialized. More...
 
void uninitializeAssembler () const
 Call this when modifying any parameter of the concrete AssemblyCondition that would require reinitialization of the Assembler or the AssemblyCondition. More...
 

Detailed Description

This AssemblyCondition requests that a particular generalized coordinate end up with a specified value.

You can use this as a goal or a constraint, depending on how serious you are about this requirement.

Constructor & Destructor Documentation

◆ QValue()

SimTK::QValue::QValue ( MobilizedBodyIndex  mbx,
MobilizerQIndex  qx,
Real  value 
)
inline

Construct an assembly condition that requests that the specified generalized coordinate be brought to the indicated value.

The value can be changed subsequently using setValue().

Member Function Documentation

◆ getValue()

Real SimTK::QValue::getValue ( ) const
inline

Return the currently set value to be used for this generalized coordinate.

◆ setValue()

void SimTK::QValue::setValue ( Real  newValue)
inline

Change the value to be used for this generalized coordinate; this can be done repeatedly during tracking to follow changing requirements.

◆ getNumEquations()

int SimTK::QValue::getNumEquations ( const State ) const
inline

◆ calcErrors()

int SimTK::QValue::calcErrors ( const State state,
Vector err 
) const
inlineoverridevirtual

Calculate the amount by which this assembly condition is violated by the q values in the given state, with one scalar error per assembly equation returned in err.

The functional return should be zero if successful; negative values are reserved with -1 meaning "not implemented"; return a positive value if your implementation is unable to evaluate the error at the current state. If this method is not implemented then you must implement calcGoal() and this assembly condition may only be used as a goal, not a requirement.

Reimplemented from SimTK::AssemblyCondition.

◆ calcErrorJacobian()

int SimTK::QValue::calcErrorJacobian ( const State state,
Matrix jacobian 
) const
inlineoverridevirtual

Override to supply an analytic Jacobian for the assembly errors returned by calcErrors().

The returned Jacobian must be nErr X nFreeQs; that is, if there is only one assembly error equation the returned matrix is a single row (that's the transpose of the gradient). The functional return should be zero if this succeeds; negative values are reserved with the default implementation returning -1 which indicates that the Jacobian must be calculated numerically using the calcErrors() method. Return a positive value if your implementation is unable to evaluate the Jacobian at the current state.

Reimplemented from SimTK::AssemblyCondition.

◆ calcGoal()

int SimTK::QValue::calcGoal ( const State state,
Real goal 
) const
inlineoverridevirtual

Calculate the current contribution (>= 0) of this assembly condition to the goal value that is being minimized.

If this isn't overridden we'll generate it by combining the m errors returned by calcErrors() in a mean sum of squares: goal = err^2/m.

Reimplemented from SimTK::AssemblyCondition.

◆ calcGoalGradient()

int SimTK::QValue::calcGoalGradient ( const State state,
Vector gradient 
) const
inlineoverridevirtual

Override to supply an analytic gradient for this assembly condition's goal.

The returned gradient must be nFreeQ X 1; that is, it is a column vector giving the partial derivative of the goal with respect to each of the free q's in order. The functional return should be zero if this succeeds. The default implementation return -1 which indicates that the gradient must be calculated numerically using the calcGoal() method.

Reimplemented from SimTK::AssemblyCondition.


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