OpenSim Moco  0.4.0
Public Member Functions | List of all members
OpenSim::MocoInverse Class Reference

Description

This tool solves problems in which the kinematics are prescribed and you seek the actuator (e.g., muscle) behavior that may have given rise to the provided kinematics.

The term "inverse" describes methods that estimate quantities from an observation; on the other hand, "forward" methods attempt to predict (unobserved) behavior. In this case, "inverse" refers to the multibody systems. This class can still be used to simulate muscles in a "forward" or predictive sense.

The kinematics file must provide values for all coordinates (even those labeled as dependent in a CoordinateCouplerConstraint); missing coordinates are set to NaN.

The provided trajectory is altered to satisfy any enabled kinematic constraints in the model.

Cost

By default, MocoInverse minimizes the sum of squared controls and constrains initial activation to be equal to initial excitation (to avoid initial activation spikes). To customize the cost, invoke initialize(), add costs manually, and solve the problem using the solver directly. Note, however, that kinematic states are not included in the solution if you use the solver directly.

Default solver settings

MocoInverse minimizes the sum of squared controls and, optionally, the sum of squared activations. Currently, the costs used by MocoInverse cannot be customized. As MocoInverse becomes more mature and general, the costs will become more flexible.

Mesh interval

A smaller mesh interval increases the convergence time, but is necessary for fast motions or problems with stiff differential equations (e.g., stiff tendons). For gait, consider using a mesh interval between 0.01 and 0.05 seconds. Try solving your problem with decreasing mesh intervals and choose a mesh interval at which the solution stops changing noticeably.

Note
This class is still under active development and should be used with caution.
Examples:
exampleMocoInverse.cpp.
Inheritance diagram for OpenSim::MocoInverse:
OpenSim::MocoTool

#include <Moco/Moco/MocoInverse.h>

Public Member Functions

 OpenSim_DECLARE_PROPERTY (kinematics, TableProcessor, "Generalized coordinate values to prescribe.")
 
 OpenSim_DECLARE_PROPERTY (kinematics_allow_extra_columns, bool, "Allow the kinematics file to contain columns that do not name " "states in the model. " "This is false by default to help you avoid accidents.")
 
 OpenSim_DECLARE_PROPERTY (minimize_sum_squared_activations, bool, "Minimize the sum of squared activations. Default: false.")
 
 OpenSim_DECLARE_OPTIONAL_PROPERTY (max_iterations, int, "Maximum number of solver iterations (default: solver default).")
 
 OpenSim_DECLARE_PROPERTY (convergence_tolerance, double, "The convergence tolerance (default: 1e-3).")
 
 OpenSim_DECLARE_PROPERTY (constraint_tolerance, double, "The constraint tolerance (default: 1e-3).")
 
 OpenSim_DECLARE_LIST_PROPERTY (output_paths, std::string, "Outputs to compute after solving the problem." " Entries can be regular expressions (e.g., '.*activation').")
 
 OpenSim_DECLARE_PROPERTY (reserves_weight, double, "The weight applied to the controls whose name includes " "'/reserve_'. This can be used with " "the model operator ModOpAddReserves, which names each appended " "actuator in this format. Default weight: 1.") MocoInverse()
 
void setKinematics (TableProcessor kinematics)
 
MocoStudy initialize () const
 
MocoInverseSolution solve () const
 Solve the problem returned by initialize() and compute the outputs listed in output_paths. More...
 
- Public Member Functions inherited from OpenSim::MocoTool
 OpenSim_DECLARE_OPTIONAL_PROPERTY (initial_time, double, "The start of the time interval. " "All data must start at or before this time. " "(default: earliest time available in all provided data)")
 
 OpenSim_DECLARE_OPTIONAL_PROPERTY (final_time, double, "The end of the time interval. " "All data must end at or after this time. " "(default: latest time available in all provided data)")
 
 OpenSim_DECLARE_PROPERTY (mesh_interval, double, "The time duration of each mesh interval " "(default: 0.020 seconds).")
 
 OpenSim_DECLARE_PROPERTY (clip_time_range, bool, "Set the time range to be 1e-3 shorter on both ends to leave space " "for finite difference estimates (default: false).")
 
 OpenSim_DECLARE_PROPERTY (model, ModelProcessor, "The musculoskeletal model to use.")
 
void setModel (ModelProcessor model)
 

Additional Inherited Members

- Protected Member Functions inherited from OpenSim::MocoTool
void updateTimeInfo (const std::string &dataLabel, const double &dataInitial, const double &dataFinal, TimeInfo &info) const
 This function updates a TimeInfo so the initial and final times are within the data times provided. More...
 
std::string getFilePath (const std::string &file) const
 Get the canonicalized absolute pathname with respect to the setup file directory from a given pathname which can be relative or absolute. More...
 
std::string getDocumentDirectory () const
 Get the (canonicalized) absolute directory containing the file from which this tool was loaded. More...
 

Member Function Documentation

◆ solve()

MocoInverseSolution OpenSim::MocoInverse::solve ( ) const

Solve the problem returned by initialize() and compute the outputs listed in output_paths.

Examples:
exampleMocoInverse.cpp.

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