API  4.2
For MATLAB, Python, Java, and C++ users
Getting started with Moco

Obtaining Moco

Download Moco for Windows or Mac from https://simtk.org/projects/opensim-moco. The Moco distribution contains a MATLAB/Java package, a Python package, a C++ library, and a command-line tool. Currently, Moco does not have a graphical user interface.

The distribution is a ZIP file that you can place anywhere on your computer; for example, C:/Users/<username>/opensim-moco-<version> on Windows or /Users/<username>/opensim-moco-<version> on Mac. We refer to this location

Note
On Windows, set your Windows PATH environment variable to include <OpenSim-Moco-Install>/bin before any other OpenSim/OpenSense paths.

Decide which of Moco's interfaces you want to use and follow the relevant instructions below.

Building Moco from source

If you want to edit Moco's C++ code or use Moco on a platform for which we do not distribute binaries (e.g., Linux), then you must build Moco from source. Developing your own cost module does not require building Moco from source.

For instructions, visit the source code repository at https://github.com/opensim-org/opensim-core and consult the README.md file.

Using Moco in MATLAB

Follow the instructions for configuring Matlab to use OpenSim: https://simtk-confluence.stanford.edu:8443/display/OpenSim/Scripting+with+Matlab

Restart Matlab and test that Matlab is properly configured to use OpenSim by running:

>> org.opensim.modeling.opensimCommon.GetVersionAndDate();

Make sure the output is consistent with the version of OpenSim you intend to use.

The OpenSim distribution contains Matlab examples in the folder Resources/Code/Matlab/Moco. Start with exampleSlidingMass.m.

Using Moco in Python

To use the Python package that comes with the Moco distribution, you must use the same Python distribution with which Moco was built. For Windows, this is the Python 3 distribution from python.org. For Mac, this is the Python 3 package from Homebrew.

The OpenSim distribution contains Moco Python examples in the folder Resources/Code/Python/Moco. Start with exampleSlidingMass.py.

If you would prefer to use Python 2 instead of Python 3, you must build from source using the instructions in the README.md file of the opensim-core source code repository (https://github.com/opensim-org/opensim-core/blob/master/README.md).

In the future, we hope to make the Python package easier to install by distributing it through the Conda package manager.

Using Moco in C++

This section is under development.