OpenSim Moco  0.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OpenSim::MocoMarkerTrackingGoal Class Reference

Description

The squared difference between a model marker location and an experimental reference marker location, summed over the markers for which an experimental data location is provided, and integrated over the phase.

The reference can be provided as a file name to a TRC file, or programmatically as a TimeSeriesTable.

Examples:
exampleMarkerTracking.cpp.
Inheritance diagram for OpenSim::MocoMarkerTrackingGoal:
OpenSim::MocoGoal

#include <Moco/Moco/MocoGoal/MocoMarkerTrackingGoal.h>

Public Member Functions

 MocoMarkerTrackingGoal (std::string name)
 
 MocoMarkerTrackingGoal (std::string name, double weight)
 
void setMarkersReference (const MarkersReference &ref)
 Provide a MarkersReference object containing the marker trajectories to be tracked by a model. More...
 
MarkersReference getMarkersReference () const
 If no MarkersReference has been specified, this returns an empty MarkersReference object. More...
 
void setAllowUnusedReferences (bool tf)
 Specify if the markers_reference can contain marker data for a marker not in the model. More...
 
- Public Member Functions inherited from OpenSim::MocoGoal
 MocoGoal (std::string name)
 
 MocoGoal (std::string name, double weight)
 
void setEnabled (bool enabled)
 Set whether this goal is used in the problem.
 
bool getEnabled () const
 
void setWeight (double weight)
 In cost mode, the goal is multiplied by this weight. More...
 
double getWeight () const
 
void setMode (std::string mode)
 Set the mode property to either 'cost' or 'endpoint_constraint'. More...
 
std::string getModeAsString () const
 This returns the default mode of the goal, unless the user overrode the default using setMode(). More...
 
Mode getMode () const
 
bool getModeIsCost () const
 
bool getModeIsEndpointConstraint () const
 
Mode getDefaultMode () const
 Types of goals have a class-level default for whether they are enforced as a cost or endpoint constraint. More...
 
bool getSupportsEndpointConstraint () const
 Can this constraint be used in endpoint constraint mode?
 
const MocoConstraintInfogetConstraintInfo () const
 Get bounds for the constraints when using this goal in endpoint constraint mode. More...
 
MocoConstraintInfoupdConstraintInfo ()
 
int getNumOutputs () const
 Get the length of the return value of calcGoal().
 
int getNumIntegrals () const
 Get the number of integrals required by this cost. More...
 
SimTK::Real calcIntegrand (const SimTK::State &state) const
 Calculate the integrand that should be integrated and passed to calcCost(). More...
 
void calcGoal (const GoalInput &input, SimTK::Vector &goal) const
 In cost mode, the returned cost includes the weight, and the elements of the returned vector should be summed by the caller to obtain the total cost. More...
 
void initializeOnModel (const Model &model) const
 For use by solvers. This also performs error checks on the Problem.
 
void printDescription (std::ostream &stream=std::cout) const
 Print the name type and mode of this goal. More...
 

Protected Member Functions

void initializeOnModelImpl (const Model &) const override
 Perform any caching before the problem is solved. More...
 
void calcIntegrandImpl (const SimTK::State &state, double &integrand) const override
 
void calcGoalImpl (const GoalInput &input, SimTK::Vector &cost) const override
 The Lagrange multipliers for kinematic constraints are not available.
 
void printDescriptionImpl (std::ostream &stream=std::cout) const override
 Print a more detailed description unique to each goal.
 
 OpenSim_DECLARE_PROPERTY (markers_reference, MarkersReference, "MarkersReference object containing the marker trajectories to be " "tracked by a model. Marker weights can be optionally specified " "to weight the tracking of individual markers in the cost " "function. Names of markers in the reference desired to be track " "should match the names of corresponding model markers.")
 
 OpenSim_DECLARE_PROPERTY (allow_unused_references, bool, "Allow markers_reference to contain marker data for a marker " "not in the model (such data would be ignored). Default: false.")
 
- Protected Member Functions inherited from OpenSim::MocoGoal
void setNumIntegralsAndOutputs (int numIntegrals, int numOutputs) const
 Set the number of integral terms required by this goal and the length of the vector passed into calcGoalImpl(). More...
 
virtual Mode getDefaultModeImpl () const
 
virtual bool getSupportsEndpointConstraintImpl () const
 
const Model & getModel () const
 For use within virtual function implementations.
 
double calcSystemDisplacement (const SimTK::State &initial, const SimTK::State &final) const
 

Protected Attributes

GCVSplineSet m_refsplines
 
std::vector< SimTK::ReferencePtr< const Marker > > m_model_markers
 
std::vector< int > m_refindices
 
SimTK::Array_< double > m_marker_weights
 
SimTK::Array_< std::string > m_marker_names
 

Additional Inherited Members

- Public Types inherited from OpenSim::MocoGoal
enum  Mode { Cost, EndpointConstraint }
 

Member Function Documentation

◆ calcIntegrandImpl()

void OpenSim::MocoMarkerTrackingGoal::calcIntegrandImpl ( const SimTK::State &  state,
double &  integrand 
) const
overrideprotectedvirtual
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);
The Lagrange multipliers for kinematic constraints are not available.

Reimplemented from OpenSim::MocoGoal.

◆ getMarkersReference()

MarkersReference OpenSim::MocoMarkerTrackingGoal::getMarkersReference ( ) const
inline

If no MarkersReference has been specified, this returns an empty MarkersReference object.

◆ initializeOnModelImpl()

void OpenSim::MocoMarkerTrackingGoal::initializeOnModelImpl ( const Model &  ) const
overrideprotectedvirtual

Perform any caching before the problem is solved.

You must override this function and invoke setNumIntegralsAndOutputs().

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.

Implements OpenSim::MocoGoal.

◆ setAllowUnusedReferences()

void OpenSim::MocoMarkerTrackingGoal::setAllowUnusedReferences ( bool  tf)
inline

Specify if the markers_reference can contain marker data for a marker not in the model.

An exception is raised if set to false and marker data exists for a marker not included in the model.

◆ setMarkersReference()

void OpenSim::MocoMarkerTrackingGoal::setMarkersReference ( const MarkersReference &  ref)
inline

Provide a MarkersReference object containing the marker trajectories to be tracked by a model.

The MarkersReferences can be created from a file of marker trajectories (e.g. .trc) or created programmatically via a TimeSeriesTableVec3. The marker weights property can be optionally specified to weight the tracking of individual markers in the cost function. Names of markers in the reference to be tracked should match the names of corresponding model markers.

Examples:
exampleMarkerTracking.cpp.

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