OpenSim Moco  0.4.0
Classes | Public Member Functions | List of all members
CasOC::Problem Class Referenceabstract
Inheritance diagram for CasOC::Problem:
OpenSim::MocoCasOCProblem

Classes

struct  ContinuousInput
 
struct  CostInput
 
struct  MultibodySystemExplicitOutput
 
struct  MultibodySystemImplicitOutput
 

Public Member Functions

template<typename IterateType = Iterate>
IterateType createIterate () const
 Create an iterate with the variable names populated according to the variables added to this problem. More...
 
void initialize (const std::string &finiteDiffScheme, std::shared_ptr< const std::vector< VariablesDM >> pointsForSparsityDetection) const
 
Interface for CasOC::Transcription.
int getNumStates () const
 
int getNumControls () const
 
int getNumParameters () const
 
int getNumMultipliers () const
 
std::string getDynamicsMode () const
 
bool isDynamicsModeImplicit () const
 
int getNumDerivatives () const
 
int getNumSlacks () const
 
int getNumCoordinates () const
 This is the number of generalized coordinates, which may be greater than the number of generalized speeds. More...
 
int getNumSpeeds () const
 
int getNumAccelerations () const
 
int getNumAuxiliaryStates () const
 
int getNumCosts () const
 
bool isPrescribedKinematics () const
 
int getNumMultibodyDynamicsEquations () const
 If the coordinates are prescribed, then the number of multibody dynamics equations is not the same as the number of speeds. More...
 
const std::vector< std::string > & getAuxiliaryDerivativeNames () const
 
int getNumAuxiliaryResidualEquations () const
 
int getNumKinematicConstraintEquations () const
 
std::vector< std::string > createKinematicConstraintEquationNames () const
 Create a vector of names for scalar kinematic constraint equations. More...
 
int getNumHolonomicConstraintEquations () const
 
int getNumNonHolonomicConstraintEquations () const
 
int getNumAccelerationConstraintEquations () const
 
bool getEnforceConstraintDerivatives () const
 
const BoundsgetKinematicConstraintBounds () const
 
const BoundsgetTimeInitialBounds () const
 
const BoundsgetTimeFinalBounds () const
 
const std::vector< StateInfo > & getStateInfos () const
 
const std::vector< ControlInfo > & getControlInfos () const
 
const std::vector< MultiplierInfo > & getMultiplierInfos () const
 
const std::vector< SlackInfo > & getSlackInfos () const
 
const std::vector< ParameterInfo > & getParameterInfos () const
 
const std::vector< CostInfo > & getCostInfos () const
 
const std::vector< EndpointConstraintInfo > & getEndpointConstraintInfos () const
 
const std::vector< PathConstraintInfo > & getPathConstraintInfos () const
 
const casadi::Function & getMultibodySystem () const
 Get a function to the full multibody system (i.e. More...
 
const casadi::Function & getMultibodySystemIgnoringConstraints () const
 Get a function to the multibody system that does not compute kinematic constraint errors (if they exist). More...
 
const casadi::Function & getVelocityCorrection () const
 Get a function to compute the velocity correction to qdot when enforcing kinematic constraints and their derivatives. More...
 
const casadi::Function & getImplicitMultibodySystem () const
 
const casadi::Function & getImplicitMultibodySystemIgnoringConstraints () const
 

Interface for the user building the problem.

Call the add/set functions in the constructor for your problem.

virtual void calcMultibodySystemExplicit (const ContinuousInput &input, bool calcKCErrors, MultibodySystemExplicitOutput &output) const =0
 Kinematic constraint errors should be ordered as so: More...
 
virtual void calcMultibodySystemImplicit (const ContinuousInput &input, bool calcKCErrors, MultibodySystemImplicitOutput &output) const =0
 
virtual void calcVelocityCorrection (const double &time, const casadi::DM &multibody_states, const casadi::DM &slacks, const casadi::DM &parameters, casadi::DM &velocity_correction) const =0
 
virtual void calcCostIntegrand (int, const ContinuousInput &, double &) const
 
virtual void calcCost (int, const CostInput &, casadi::DM &) const
 
virtual void calcEndpointConstraintIntegrand (int, const ContinuousInput &, double &) const
 
virtual void calcEndpointConstraint (int, const CostInput &, casadi::DM &) const
 
virtual void calcPathConstraint (int, const ContinuousInput &, casadi::DM &) const
 
virtual std::vector< std::string > createKinematicConstraintEquationNamesImpl () const
 
void intermediateCallback () const
 
void intermediateCallbackWithIterate (const CasOC::Iterate &it) const
 
virtual void intermediateCallbackImpl () const
 This is invoked once for each iterate in the optimization process.
 
virtual void intermediateCallbackWithIterateImpl (const CasOC::Iterate &) const
 Process an intermediate iterate. More...
 
void setTimeBounds (Bounds initial, Bounds final)
 
void addState (std::string name, StateType type, Bounds bounds, Bounds initialBounds, Bounds finalBounds)
 Add a differential state. More...
 
void addControl (std::string name, Bounds bounds, Bounds initialBounds, Bounds finalBounds)
 Add an algebraic variable/"state" to the problem.
 
void addKinematicConstraint (std::string multName, Bounds multbounds, Bounds multInitialBounds, Bounds multFinalBounds, KinematicLevel kinLevel)
 
void addSlack (std::string name, Bounds bounds)
 Add a slack velocity correction variable to the problem associated with a kinematic constraint in the model. More...
 
void setPrescribedKinematics (bool tf, int numMultibodyDynamicsEquations)
 Set if all kinematics are prescribed. More...
 
void setEnforceConstraintDerivatives (bool tf)
 Set whether not constraint derivatives are to be enforced.
 
void setKinematicConstraintBounds (Bounds bounds)
 Set the bounds for all kinematic constraints in the problem.
 
void addParameter (std::string name, Bounds bounds)
 Add a constant (time-invariant) variable to the optimization problem.
 
void addCost (std::string name, int numIntegrals, int numOutputs)
 Add a cost term to the problem.
 
void addEndpointConstraint (std::string name, int numIntegrals, std::vector< Bounds > bounds)
 Add an endpoint constraint to the problem.
 
void addPathConstraint (std::string name, std::vector< Bounds > bounds)
 The size of bounds must match the number of outputs in the function. More...
 
void setDynamicsMode (std::string dynamicsMode)
 
void setAuxiliaryDerivativeNames (const std::vector< std::string > &names)
 

Member Function Documentation

◆ addPathConstraint()

void CasOC::Problem::addPathConstraint ( std::string  name,
std::vector< Bounds bounds 
)
inlineprotected

The size of bounds must match the number of outputs in the function.

Use variadic template arguments to pass arguments to the constructor of FunctionType.

◆ addSlack()

void CasOC::Problem::addSlack ( std::string  name,
Bounds  bounds 
)
inlineprotected

Add a slack velocity correction variable to the problem associated with a kinematic constraint in the model.

◆ addState()

void CasOC::Problem::addState ( std::string  name,
StateType  type,
Bounds  bounds,
Bounds  initialBounds,
Bounds  finalBounds 
)
inlineprotected

Add a differential state.

The MultibodySystem function must provide differential equations for Speed and Auxiliary states. Currently, CasOC internally handles the differential equations for the generalized coordinates. The state variables must be added in the order Coordinate, Speed, Auxiliary.

◆ calcMultibodySystemExplicit()

virtual void CasOC::Problem::calcMultibodySystemExplicit ( const ContinuousInput input,
bool  calcKCErrors,
MultibodySystemExplicitOutput output 
) const
pure virtual

Kinematic constraint errors should be ordered as so:

  • position-level constraints
  • first derivative of position-level constraints
  • velocity-level constraints
  • second derivative of position-level constraints
  • first derivative of velocity-level constraints
  • acceleration-level constraints

◆ createIterate()

template<typename IterateType = Iterate>
IterateType CasOC::Problem::createIterate ( ) const
inline

Create an iterate with the variable names populated according to the variables added to this problem.

◆ createKinematicConstraintEquationNames()

std::vector<std::string> CasOC::Problem::createKinematicConstraintEquationNames ( ) const
inline

Create a vector of names for scalar kinematic constraint equations.

The length of the vector is getNumKinematicConstraintEquations(). includeDerivatives determines if names for derivatives of position-level and velocity-level constraints should be included.

◆ getMultibodySystem()

const casadi::Function& CasOC::Problem::getMultibodySystem ( ) const
inline

Get a function to the full multibody system (i.e.

including kinematic constraints errors).

◆ getMultibodySystemIgnoringConstraints()

const casadi::Function& CasOC::Problem::getMultibodySystemIgnoringConstraints ( ) const
inline

Get a function to the multibody system that does not compute kinematic constraint errors (if they exist).

This may be necessary for computing state derivatives at grid points where we do not want to enforce kinematic constraint errors.

◆ getNumCoordinates()

int CasOC::Problem::getNumCoordinates ( ) const
inline

This is the number of generalized coordinates, which may be greater than the number of generalized speeds.

◆ getNumMultibodyDynamicsEquations()

int CasOC::Problem::getNumMultibodyDynamicsEquations ( ) const
inline

If the coordinates are prescribed, then the number of multibody dynamics equations is not the same as the number of speeds.

◆ getVelocityCorrection()

const casadi::Function& CasOC::Problem::getVelocityCorrection ( ) const
inline

Get a function to compute the velocity correction to qdot when enforcing kinematic constraints and their derivatives.

We require a separate function for this since we don't actually compute qdot within the multibody system.

◆ intermediateCallbackWithIterateImpl()

virtual void CasOC::Problem::intermediateCallbackWithIterateImpl ( const CasOC::Iterate ) const
inlinevirtual

Process an intermediate iterate.

The frequency with which this is evaluated is governed by Solver::getOutputInterval().

◆ setPrescribedKinematics()

void CasOC::Problem::setPrescribedKinematics ( bool  tf,
int  numMultibodyDynamicsEquations 
)
inlineprotected

Set if all kinematics are prescribed.

In this case, do not add state variables for coordinates or speeds. The number of multibody dynamics equations is equal to the number of speeds in the original system. But if kinematics are prescribed, you must provide the number of multibody dynamics equations directly. This is because no speed state variables are added and CasOCProblem can't obtain the number of multibody equations by counting the number of speed state variables.


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