API  4.5
For C++ developers
Moco Examples

Moco's examples are categorized as beginner, intermediate, and advanced.

Some examples are available from multiple interfaces. Use the links in the Interfaces column to view the code. In the OpenSim distribution, all examples are in the Resources/Code/ folder.

Note
The intent of all examples is to demonstrate Moco's interface. We do not validate the results of these examples. Users are responsible for validating their results before making any scientific claims.

Beginner

name model/motion description interfaces
SlidingMass point mass Moco's simplest example; MocoFinalTimeGoal MATLAB, Python, C++
SlidingMassAdvanced point mass MocoFinalTimeGoal, solver settings, customizing the initial guess C++
Tracking double pendulum Using MocoStateTrackingGoal C++
MarkerTracking double pendulum Using MocoMarkerTrackingGoal C++
HangingMuscle point mass with muscle DeGrooteFregly2016Muscle, Umberger2010MuscleMetabolicsProbe, AnalyzeTool, MocoInitialActivationGoal, MocoInitialVelocityEquilibriumDGFGoal, plotting a TimeSeriesTable Python, C++
OptimizeMass point mass Parameter optimization with MocoMarkerFinalGoal and MocoParameter MATLAB, Python
MinimizeJointReaction pendulum MocoJointReactionGoal, MocoControlGoal, prescribeControlsToModel MATLAB
exampleKinematicConstraints point mass Point mass constrained to a parabola Python

Intermediate

name model/motion description interfaces
MocoTrack lower-limb Using the MocoTrack tool for walking with marker tracking and state tracking; generating a PDF report MATLAB, Python, C++
MocoInverse lower-limb Using the MocoInverse tool for walking; MocoControlTrackingGoal; generating a PDF report MATLAB, Python, C++
2DWalking walking MocoTrack, MocoStudy prediction, MocoControlGoal, MocoAverageSpeedGoal, MocoPeriodicityGoal, MocoContactTrackingGoal, createPeriodicSolution MATLAB, C++
2DWalkingMetabolics walking MocoTrack, MocoControlGoal, MocoPeriodicityGoal, Bhargava2004SmoothedMuscleMetabolics C++
MarkerTracking10DOF walking MocoControlGoal, MocoMarkerTrackingGoal MATLAB
SquatToStand torque-driven single leg MocoStudy motion prediction, MocoInverse MATLAB Python
IMUTracking torque-driven single leg MocoStudy motion prediction, MocoAccelerationTrackingGoal MATLAB Python
EMGTracking lower-limb MocoInverse, MocoControlTrackingGoal MATLAB Python
PredictAndTrack double pendulum MocoMarkerFinalGoal, MocoFinalTimeGoal, MocoMarkerTrackingGoal, MocoStateTrackingGoal Python
PrototypeCustomGoal N/A Sandbox for defining a custom MocoGoal MATLAB
PolynomialPathFitter N/A Fit FunctionBasedPaths to a model MATLAB Python

Advanced

name model/motion description interfaces
CustomImplicitAuxiliaryDynamics N/A Creating a component with implicit auxiliary dynamics (like muscle tendon compliance) C++
CustomEffortGoal N/A Creating a plugin for a custom goal C++