OpenSim Moco  0.4.0
Public Member Functions | Protected Member Functions | List of all members
OpenSim::MocoPathConstraint Class Referenceabstract

Description

A path constraint to be enforced in the optimal control problem.

The use of 'path' here is unrelated to muscle paths, GeometryPath, or file system paths (e.g., Path).

For developers
Every time the problem is solved, a copy of this constraint is used. An individual instance of a constraint is only ever used in a single problem. Therefore, there is no need to clear cache variables that you create in initializeImpl(). Also, information stored in this constraint does not persist across multiple solves.
Inheritance diagram for OpenSim::MocoPathConstraint:
OpenSim::MocoControlBoundConstraint OpenSim::MocoFrameDistanceConstraint

#include <Moco/Moco/MocoConstraint.h>

Public Member Functions

const MocoConstraintInfogetConstraintInfo () const
 
MocoConstraintInfoupdConstraintInfo ()
 
void setConstraintInfo (const MocoConstraintInfo &cInfo)
 
int getPathConstraintIndex () const
 For use by solvers. More...
 
void calcPathConstraintErrors (const SimTK::State &state, SimTK::Vector &errors) const
 Calculate errors in the path constraint equations. More...
 
void initializeOnModel (const Model &model, const MocoProblemInfo &, const int &pathConstraintIndex) const
 For use by solvers. This also performs error checks on the Problem.
 

Protected Member Functions

 OpenSim_DECLARE_UNNAMED_PROPERTY (MocoConstraintInfo, "The bounds and " "labels for this MocoPathConstraint.")
 
virtual void initializeOnModelImpl (const Model &, const MocoProblemInfo &) const =0
 Perform any caching. More...
 
void setNumEquations (int numEqs) const
 Set the number of scalar equations for this MocoPathConstraint. More...
 
virtual void calcPathConstraintErrorsImpl (const SimTK::State &state, SimTK::Vector &errors) const =0
 
const Model & getModel () const
 For use within virtual function implementations.
 

Member Function Documentation

◆ calcPathConstraintErrors()

void OpenSim::MocoPathConstraint::calcPathConstraintErrors ( const SimTK::State &  state,
SimTK::Vector &  errors 
) const
inline

Calculate errors in the path constraint equations.

The errors argument represents the concatenated error vector for all path constraints in the MocoProblem. This method creates a view into errors to access the elements for this MocoPathConstraint and passes this view to calcPathConstraintErrorsImpl().

◆ calcPathConstraintErrorsImpl()

virtual void OpenSim::MocoPathConstraint::calcPathConstraintErrorsImpl ( const SimTK::State &  state,
SimTK::Vector &  errors 
) const
protectedpure virtual
Precondition(s):
The state is realized to SimTK::Stage::Position. If you need access to the controls, you must realize to Velocity:
getModel().realizeVelocity(state);

Implemented in OpenSim::MocoFrameDistanceConstraint, and OpenSim::MocoControlBoundConstraint.

◆ getPathConstraintIndex()

int OpenSim::MocoPathConstraint::getPathConstraintIndex ( ) const
inline

For use by solvers.

This index is the location of this MocoPathConstraint's first error in the MocoProblem's full path constraint errors vector. Since it is set by the MocoProblem, it is only available after initialization.

◆ initializeOnModelImpl()

virtual void OpenSim::MocoPathConstraint::initializeOnModelImpl ( const Model &  ,
const MocoProblemInfo  
) const
protectedpure virtual

Perform any caching.

The number of scalar constraint equations this MocoPathConstraint implements must be defined here (see setNumEquations() below).

Precondition(s):
The model is initialized (initSystem()) and getModel() is available. The passed-in model is equivalent to getModel(). Use this opportunity to check for errors in user input, in addition to the checks provided in initialize().

Implemented in OpenSim::MocoFrameDistanceConstraint, and OpenSim::MocoControlBoundConstraint.

◆ setNumEquations()

void OpenSim::MocoPathConstraint::setNumEquations ( int  numEqs) const
inlineprotected

Set the number of scalar equations for this MocoPathConstraint.

This must be set within initializeImpl(), otherwise an exception is thrown during initialization.


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