<NME> README.md
<BEF> OpenSim Core
============
![continuous-integration](https://github.com/opensim-org/opensim-core/workflows/continuous-integration/badge.svg)[![ZenHub][zenhub_image]][zenhub]

**NOTE: This repository cannot be used to build OpenSim 3.x or earlier. For OpenSim 3.x, see [here](http://simtk-confluence.stanford.edu:8080/display/OpenSim/Building+OpenSim+from+Source).**

OpenSim is software that lets users develop models of musculoskeletal
structures and create dynamic simulations of movement, such as this one:

![Simulation of human running by Sam Hamner (doi:
10.1016/j.jbiomech.2010.06.025)][running_gif]

More information can be found at our websites:

* [OpenSim website](http://opensim.stanford.edu); in particular, the [support
  page](http://opensim.stanford.edu/support/index.html).
* [SimTK project website](https://simtk.org/home/opensim)

This repository contains the source code for OpenSim's C++ libraries, C++
examples, command-line applications (inverse kinematics, computed muscle
control, etc.), and Java and Python wrapping. This repository does *not*
include source code for the OpenSim GUI.


Table of contents
-----------------
- [Simple Example](#simple-example)
- [Building from the source code](#building-from-the-source-code)
  - [On Windows using Microsoft Visual Studio](#on-windows-using-visual-studio).
  - [On Mac OSX using Xcode](#on-mac-osx-using-xcode).
  - [On Ubuntu using Unix Makefiles](#on-ubuntu-using-unix-makefiles).


Simple example
--------------
Let's simulate a simple arm whose elbow is actuated by a muscle, using
the C++ interface 

<details open>
<summary>C++</summary>

```cpp
#include <OpenSim/OpenSim.h>
using namespace SimTK;
using namespace OpenSim;

int main() {
    Model model;
    model.setName("bicep_curl");
    model.setUseVisualizer(true);

    // Create two links, each with a mass of 1 kg, center of mass at the body's
    // origin, and moments and products of inertia corresponding to an
    // ellipsoid with radii of 0.1, 0.5 and 0.1, in the x, y and z directions,
    // respectively.
    OpenSim::Body* humerus = new OpenSim::Body(
        "humerus", 1.0, Vec3(0), Inertia(0.052, 0.004, 0.052));
    OpenSim::Body* radius  = new OpenSim::Body(
        "radius",  1.0, Vec3(0), Inertia(0.052, 0.004, 0.052));

    // Connect the bodies with pin joints. Assume each body is 1 m long.
    PinJoint* shoulder = new PinJoint("shoulder",
            // Parent body, location in parent, orientation in parent.
            model.getGround(), Vec3(0), Vec3(0),
            // Child body, location in child, orientation in child.
            *humerus, Vec3(0, 0.5, 0), Vec3(0));
    PinJoint* elbow = new PinJoint("elbow",
            *humerus, Vec3(0, -0.5, 0), Vec3(0),
            *radius, Vec3(0, 0.5, 0), Vec3(0));

    // Add a muscle that flexes the elbow.
    Millard2012EquilibriumMuscle* biceps = new
        Millard2012EquilibriumMuscle("biceps", 200, 0.6, 0.55, 0);
    biceps->addNewPathPoint("origin",    *humerus, Vec3(0, 0.3, 0));
    biceps->addNewPathPoint("insertion", *radius,  Vec3(0, 0.2, 0));

    // Add a controller that specifies the excitation of the muscle.
    PrescribedController* brain = new PrescribedController();
    brain->addActuator(*biceps);
    // Muscle excitation is 0.3 for the first 0.5 seconds, then increases to 1.
    brain->prescribeControlForActuator("biceps",
            new StepFunction(0.5, 3, 0.3, 1));

    // Add components to the model.
    model.addBody(humerus);    model.addBody(radius);
    model.addJoint(shoulder);  model.addJoint(elbow);
    model.addForce(biceps);
    model.addController(brain);

    // Add a console reporter to print the muscle fiber force and elbow angle.
    ConsoleReporter* reporter = new ConsoleReporter();
    reporter->set_report_time_interval(1.0);
    reporter->addToReport(biceps->getOutput("fiber_force"));
    reporter->addToReport(
        elbow->getCoordinate(PinJoint::Coord::RotationZ).getOutput("value"),
        "elbow_angle");
    model.addComponent(reporter);

    // Add display geometry.
    Ellipsoid bodyGeometry(0.1, 0.5, 0.1);
    bodyGeometry.setColor(Gray);
    // Attach an ellipsoid to a frame located at the center of each body.
    PhysicalOffsetFrame* humerusCenter = new PhysicalOffsetFrame(
        "humerusCenter", *humerus, Transform(Vec3(0)));
    humerus->addComponent(humerusCenter);
    humerusCenter->attachGeometry(bodyGeometry.clone());
    PhysicalOffsetFrame* radiusCenter = new PhysicalOffsetFrame(
        "radiusCenter", *radius, Transform(Vec3(0)));
    radius->addComponent(radiusCenter);
    radiusCenter->attachGeometry(bodyGeometry.clone());

    // Configure the model.
    State& state = model.initSystem();
    // Fix the shoulder at its default angle and begin with the elbow flexed.
    shoulder->getCoordinate().setLocked(state, true);
    elbow->getCoordinate().setValue(state, 0.5 * Pi);
    model.equilibrateMuscles(state);

    // Configure the visualizer.
    model.updMatterSubsystem().setShowDefaultGeometry(true);
    Visualizer& viz = model.updVisualizer().updSimbodyVisualizer();
    viz.setBackgroundType(viz.SolidColor);
    viz.setBackgroundColor(White);

    // Simulate.
    simulate(model, state, 5.0);

    return 0;
};
```
</details>


This code produces the following animation:

![Simulation of an arm actuated by a muscle][simple_example_gif]

and prints the following information to the console:
```
[reporter]
              | /forceset/bice|               |
          time| ps|fiber_force|    elbow_angle|
--------------| --------------| --------------|
           0.0|     0.59048448|      1.5707963|
           1.0|      24.574034|     0.91820573|
           2.0|      21.418144|      1.4289945|
           3.0|      17.584893|      1.5105765|
           4.0|      17.688588|      1.5090021|
           5.0|      17.590774|      1.5067387| 
```

Expand to see Python and Matlab versions of the above example example:

<details>
<summary>Python</summary>
 
```py
import opensim as osim 

arm = osim.Model()
arm.setName("bicep_curl")
arm.setUseVisualizer(True)

# ---------------------------------------------------------------------------
# Create two links, each with a mass of 1 kg, center of mass at the body's
# origin, and moments and products of inertia corresponding to an ellipsoid
# with radii of 0.1, 0.5 and 0.1, in the x, y and z directions, respectively.
# ---------------------------------------------------------------------------

humerus = osim.Body("humerus",
                    1.0,
                    osim.Vec3(0),
                    osim.Inertia(0.052, 0.004, 0.052))
radius = osim.Body("radius",
                   1.0,
                   osim.Vec3(0),
                   osim.Inertia(0.052, 0.004, 0.052))

# ---------------------------------------------------------------------------
# Connect the bodies with pin joints. Assume each body is 1m long.
# ---------------------------------------------------------------------------

shoulder = osim.PinJoint("shoulder",
                         arm.getGround(), # PhysicalFrame
                         osim.Vec3(0),
                         osim.Vec3(0),
                         humerus, # PhysicalFrame
                         osim.Vec3(0, 0.5, 0),
                         osim.Vec3(0))

elbow = osim.PinJoint("elbow",
                      humerus, # PhysicalFrame
                      osim.Vec3(0, -0.5, 0),
                      osim.Vec3(0),
                      radius, # PhysicalFrame
                      osim.Vec3(0, 0.5, 0),
                      osim.Vec3(0))

# ---------------------------------------------------------------------------
# Add a muscle that flexes the elbow (actuator for robotics people).
# ---------------------------------------------------------------------------

biceps = osim.Millard2012EquilibriumMuscle("biceps",  # Muscle name
                                           100.0,  # Max isometric force
                                           0.6,  # Optimal fibre length
                                           0.55,  # Tendon slack length
                                           0.0)  # Pennation angle
biceps.addNewPathPoint("origin",
                       humerus,
                       osim.Vec3(0, 0.3, 0))

biceps.addNewPathPoint("insertion",
                       radius,
                       osim.Vec3(0, 0.2, 0))

# ---------------------------------------------------------------------------
# Add a controller that specifies the excitation of the muscle.
# ---------------------------------------------------------------------------

brain = osim.PrescribedController()
brain.addActuator(biceps)
brain.prescribeControlForActuator("biceps",
                                  osim.StepFunction(0.5, 3.0, 0.3, 1.0))

# ---------------------------------------------------------------------------
# Build model with components created above.
# ---------------------------------------------------------------------------

arm.addBody(humerus)
arm.addBody(radius)
arm.addJoint(shoulder) # Now required in OpenSim4.0
arm.addJoint(elbow)
arm.addForce(biceps)
arm.addController(brain)

# ---------------------------------------------------------------------------
# Add a console reporter to print the muscle fibre force and elbow angle.
# ---------------------------------------------------------------------------

# We want to write our simulation results to the console.
reporter = osim.ConsoleReporter()
reporter.set_report_time_interval(1.0)
reporter.addToReport(biceps.getOutput("fiber_force"))
elbow_coord = elbow.getCoordinate().getOutput("value")
reporter.addToReport(elbow_coord, "elbow_angle")
arm.addComponent(reporter)

# ---------------------------------------------------------------------------
# Add display geometry. 
# ---------------------------------------------------------------------------

bodyGeometry = osim.Ellipsoid(0.1, 0.5, 0.1)
bodyGeometry.setColor(osim.Vec3(0.5)) # Gray
humerusCenter = osim.PhysicalOffsetFrame()
humerusCenter.setName("humerusCenter")
humerusCenter.setParentFrame(humerus)
humerusCenter.setOffsetTransform(osim.Transform(osim.Vec3(0)))
humerus.addComponent(humerusCenter)
humerusCenter.attachGeometry(bodyGeometry.clone())

radiusCenter = osim.PhysicalOffsetFrame()
radiusCenter.setName("radiusCenter")
radiusCenter.setParentFrame(radius)
radiusCenter.setOffsetTransform(osim.Transform(osim.Vec3(0)))
radius.addComponent(radiusCenter)
radiusCenter.attachGeometry(bodyGeometry.clone())

   with OpenSim (see below). You should run this command for the release
   configuration *last* to ensure that you use the release version of the
   command-line applications instead of the slow debug versions.
   
   * Note: Superbuild attempts to determine when dependencies are out of date
     but is not always successful. It is therefore recommended to build all
     dependencies from scratch when updating your installation.
elbow.getCoordinate().setValue(state, 0.5 * osim.SimTK_PI)
arm.equilibrateMuscles(state)

# ---------------------------------------------------------------------------
# Configure the visualizer.
# ---------------------------------------------------------------------------

viz = arm.updVisualizer().updSimbodyVisualizer()
viz.setBackgroundColor(osim.Vec3(0)) # white
viz.setGroundHeight(-2)

# ---------------------------------------------------------------------------
# Simulate.
# ---------------------------------------------------------------------------

manager = osim.Manager(arm)
state.setTime(0)
manager.initialize(state)
state = manager.integrate(5.0)
```

</details>
<details>
<summary>Matlab</summary>

``` Matlab
%% Import Java libraries
import org.opensim.modeling.*

arm = Model();
arm.setName('bicep_curl');
arm.setUseVisualizer(true);

% ---------------------------------------------------------------------------
% Create two links, each with a mass of 1 kg, center of mass at the body's
% origin, and moments and products of inertia corresponding to an ellipsoid
% with radii of 0.1, 0.5 and 0.1, in the x, y and z directions, respectively.
% ---------------------------------------------------------------------------

humerus = Body('humerus',...
                    1.0,...
                    Vec3(0),...
                    Inertia(0.052, 0.004, 0.052));
radius = Body('radius',...
                   1.0,...
                   Vec3(0),...
                   Inertia(0.052, 0.004, 0.052));

% ---------------------------------------------------------------------------
% Connect the bodies with pin joints. Assume each body is 1m long.
% ---------------------------------------------------------------------------

shoulder = PinJoint('shoulder',...
                         arm.getGround(),... % PhysicalFrame
                         Vec3(0),...
                         Vec3(0),...
                         humerus,... % PhysicalFrame
                         Vec3(0, 0.5, 0),...
                         Vec3(0));

elbow = PinJoint('elbow',...
                      humerus,... % PhysicalFrame
                      Vec3(0, -0.5, 0),...
                      Vec3(0),...
                      radius,... % PhysicalFrame
                      Vec3(0, 0.5, 0),...
                      Vec3(0));

% ---------------------------------------------------------------------------
% Add a muscle that flexes the elbow (actuator for robotics people).
% ---------------------------------------------------------------------------

biceps = Millard2012EquilibriumMuscle('biceps',...  % Muscle name
                                           100.0,...  % Max isometric force
                                           0.6,...  % Optimal fibre length
                                           0.55,...  % Tendon slack length
                                           0.0);  % Pennation angle
biceps.addNewPathPoint('origin',...
                       humerus,...
                       Vec3(0, 0.3, 0));

biceps.addNewPathPoint('insertion',...
                       radius,...
                       Vec3(0, 0.2, 0));

% ---------------------------------------------------------------------------
% Add a controller that specifies the excitation of the muscle.
% ---------------------------------------------------------------------------

brain = PrescribedController();
brain.addActuator(biceps);
brain.prescribeControlForActuator('biceps',...
                                  StepFunction(0.5, 3.0, 0.3, 1.0));

% ---------------------------------------------------------------------------
% Build model with components created above.
% ---------------------------------------------------------------------------

arm.addBody(humerus);
arm.addBody(radius);
arm.addJoint(shoulder); % Now required in OpenSim4.0
arm.addJoint(elbow);
arm.addForce(biceps);
arm.addController(brain);

% ---------------------------------------------------------------------------
% Add a console reporter to print the muscle fibre force and elbow angle.
% ---------------------------------------------------------------------------

% We want to write our simulation results to the console.
reporter = ConsoleReporter();
reporter.set_report_time_interval(1.0);
reporter.addToReport(biceps.getOutput('fiber_force'));
elbow_coord = elbow.getCoordinate().getOutput('value');
reporter.addToReport(elbow_coord, 'elbow_angle');
arm.addComponent(reporter);

% ---------------------------------------------------------------------------
% Add display geometry. 
% ---------------------------------------------------------------------------

bodyGeometry = Ellipsoid(0.1, 0.5, 0.1);
bodyGeometry.setColor(Vec3(0.5)); % Gray
humerusCenter = PhysicalOffsetFrame();
humerusCenter.setName('humerusCenter');
humerusCenter.setParentFrame(humerus);
humerusCenter.setOffsetTransform(Transform(Vec3(0)));
humerus.addComponent(humerusCenter);
humerusCenter.attachGeometry(bodyGeometry.clone());

radiusCenter = PhysicalOffsetFrame();
radiusCenter.setName('radiusCenter');
radiusCenter.setParentFrame(radius);
radiusCenter.setOffsetTransform(Transform(Vec3(0)));
radius.addComponent(radiusCenter);
radiusCenter.attachGeometry(bodyGeometry.clone());

% ---------------------------------------------------------------------------
% Configure the model.
% ---------------------------------------------------------------------------

state = arm.initSystem();
% Fix the shoulder at its default angle and begin with the elbow flexed.
shoulder.getCoordinate().setLocked(state, true);
elbow.getCoordinate().setValue(state, 0.5 * pi);
arm.equilibrateMuscles(state);

% ---------------------------------------------------------------------------
% Configure the visualizer
% ---------------------------------------------------------------------------

viz = arm.updVisualizer().updSimbodyVisualizer();
viz.setBackgroundColor(Vec3(0)); % white
viz.setGroundHeight(-2)

% ---------------------------------------------------------------------------
% Simulate.
% ---------------------------------------------------------------------------

manager = Manager(arm);
state.setTime(0);
manager.initialize(state);
state = manager.integrate(5.0);
```

</details>

Building from the source code
-----------------------------

**NOTE**: On all platforms (Windows, OSX, Linux), you should
build all OpenSim dependencies (Simbody, etc) with the
same *CMAKE_BUILD_TYPE* (Linux) / *CONFIGURATION*
(MSVC/Xcode) (e.g., Release, Debug) as OpenSim. Failing to
do so *may* result in mysterious runtime errors like
segfaults.

We support a few ways of building OpenSim:

1. [On Windows using Microsoft Visual Studio](#on-windows-using-visual-studio). In a rush? Use [these instructions](#for-the-impatient-windows).
2. [On Mac OSX using Xcode](#on-mac-osx-using-xcode). Need extended instructions? Use [these instructions](#extended-instructions-for-osx).
3. [On Ubuntu using Unix Makefiles](#on-ubuntu-using-unix-makefiles). In a rush? Use [these instructions](#for-the-impatient-ubuntu).


On Windows using Visual Studio
------------------------------

#### Get the dependencies

* **operating system**: Windows 7, 8, or 10.
* **cross-platform build system**:
  [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.2
* **compiler / IDE**: Visual Studio [2019](https://visualstudio.microsoft.com/vs/) 
    * The *Community* variant is sufficient and is free for everyone.
    * Visual Studio 2019 may not install C++ support by default.
      * During the installation, select the workload
        *Desktop Development with C++*.
      * If Visual Studio is installed without C++ support, CMake will report
        the following errors:
        ```
        The C compiler identification is unknown
        The CXX compiler identification is unknown
        ```    
* **physics engine**: 
    * Let OpenSim get this for you using superbuild (see below), or
    * [Build on your own from latest master branch](
      https://github.com/simbody).
* **C3D file support**: Biomechanical-ToolKit Core or EZC3D, we use the latter by default. 
    * Let OpenSim get this for you using superbuild (see below).
* **command-line argument parsing**: docopt.cpp. Two options:
    * Let OpenSim get this for you using superbuild (see below); much easier!
    * [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).
* **logging**: spdlog. Two options:
    * Let OpenSim get this for you using superbuild (see below); much easier!
    * [Build on your own](https://github.com/gabime/spdlog).
* **Moco optimal control solvers**: Solving optimal control problems with 
    OpenSim's Moco module requires either CasADi or Tropter. Use superbuild for
    all these dependencies (except for Tropter, which is part of this
    repository).
    * **MocoCasADiSolver** (optional): [CasADi](https://web.casadi.org) (LGPL).
    * **MocoTropterSolver** (optional): Tropter.
        * **matrix library**: [Eigen](http://eigen.tuxfamily.org) >= 3.3.7
        * **sparse matrix algorithms**: [ColPack](https://github.com/CSCsw/ColPack).
        * **automatic differentiation**: [ADOL-C](https://github.com/coin-or/ADOL-C) >= 2.6.3.
    * **nonlinear optimizer** (required if building with CasADi or Tropter): 
        [IPOPT](https://github.com/coin-or/Ipopt) >= 3.12.8.
* **API documentation** (optional):
  [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6
* **version control** (optional): git. There are many options:
    * [Git for Windows](http://msysgit.github.io/), most advanced;
    * [TortoiseGit](https://code.google.com/p/tortoisegit/wiki/Download),
      intermediate; good for TortoiseSVN users;
    * [GitHub for Windows](https://windows.github.com/), easiest.
* **Bindings** (optional): [SWIG](http://www.swig.org/) 4.0.2
    * **MATLAB scripting** (optional): [Java development kit][java] >= 1.8.
        * Note: Older versions of MATLAB may use an older version of JVM. Run
                'ver' in MATLAB to check MATLAB's JVM version (must be >= 1.8).
        * Note: Java development kit >= 9 requires CMake >= 3.10.
    * **Python scripting** (optional): Python 2 >= 2.7 or Python 3 >= 3.5
        * [Anaconda](https://www.anaconda.com/distribution/)
        * Must provide the NumPy package; this should come with Anaconda.
    * The choice between 32-bit/64-bit must be the same between Java, Python,
      and OpenSim, we only build/test/support 64-bit platforms.

#### Download the OpenSim-Core source code

* Method 1: If you want to get going quickly, download the source code from
  https://github.com/opensim-org/opensim-core/releases, for the version of
  OpenSim you want. We'll assume you unzipped the source code into
  `C:/opensim-core-source`.
* Method 2: If you plan on updating your OpenSim installation or you want to
  contribute back to the project, clone the opensim-core git repository into
  `C:/opensim-core-source`. If using TortoiseGit, open Windows Explorer,
  right-click in the window, select **Git Clone...**, and provide the
  following:
    below). You should install the release configuration *last* to ensure that
    you use the release version of the command-line applications instead of the
    slow debug versions.

    * Note: Superbuild attempts to determine when dependencies are out of date
      but is not always successful. It is therefore recommended to build all
      dependencies from scratch when updating your installation.
10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the
   upper left. If necessary, change the build configuration (previous step) and
   run **ALL_BUILD** again.

#### Configure and generate project files

3. In the field **Where to build the binaries**, specify a directory under
   which to build dependencies. Let's say this is
   `C:/opensim-core-dependencies-build`.
4. Click the **Configure** button.
    1. Visual Studio 2019: Choose the *Visual Studio 16 2019* generator.
    2. Need to build as 64-bit, select the generator with *Win64* in the name.
    3. Click **Finish**.
5. Where do you want to install OpenSim dependencies on your computer? Set this
   by changing the `CMAKE_INSTALL_PREFIX` variable. Let's say this is
   `C:/opensim-core-dependencies-install`.
6. Variables named `SUPERBUILD_<dependency-name>` allow you to selectively
   download dependencies. By default, all dependencies are downloaded,
   configured and built.
7. Click the **Configure** button again. Then, click **Generate** to make
   Visual Studio project files in the build directory.
8. Go to the build directory you specified in step 3 using the command:

        cd C:/opensim-core-dependencies-build

9. Use CMake to download, compile and install the dependencies:

        cmake --build . --config RelWithDebInfo

   Alternative values for `--config` in this command are:

   * **Debug**: debugger symbols; no optimizations (more than 10x slower).
     Library names end with `_d`.
   * **Release**: no debugger symbols; optimized.
   * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower
     than Release; choose this if unsure.
   * **MinSizeRel**: minimum size; optimized.

   You must run this command for each of the configurations you plan to use
   with OpenSim (see below). You should run this command for the release
   configuration *last* to ensure that you use the release version of the
   command-line applications instead of the slow debug versions.

   * Note: Superbuild attempts to determine when dependencies are out of date
     but is not always successful. It is therefore recommended to build all
     dependencies from scratch when updating your installation.
10. If you like, you can now remove the directory used for building
    dependencies (`c:/opensim-core-dependencies-build`).

#### Configure and generate project files

1. Open the CMake GUI.
2. In the field **Where is the source code**, specify `C:/opensim-core-source`.
3. In the field **Where to build the binaries**, specify something like
   `C:/opensim-core-build`, or some other path that is not inside your source
   directory. This is *not* where we are installing OpenSim-Core; see below.
4. Click the **Configure** button.
    1. Visual Studio 2019: Choose the *Visual Studio 16* generator.
    2. To build as 64-bit, select the generator with *Win64* in the name.
       The choice between 32-bit/64-bit must be the same across all dependencies.
    3. Click **Finish**.
5. Where do you want to install OpenSim-Core on your computer? Set this by
   changing the `CMAKE_INSTALL_PREFIX` variable. We'll assume you set it to
   `C:/opensim-core`. If you choose a different installation location, make
   sure to use *yours* where we use `C:/opensim-core` below.
6. Tell CMake where to find dependencies. This depends on how you got them.
    * Superbuild: Set the variable `OPENSIM_DEPENDENCIES_DIR` to the root
      directory you specified with superbuild for installation of dependencies.
      In our example, it would be `c:/opensim-core-dependencies-install`.
    * Obtained on your own:
        1. Simbody: Set the `SIMBODY_HOME` variable to where you installed
           Simbody (e.g., `C:/Simbody`).
        2. docopt.cpp: Set the variable `docopt_DIR` to the directory
           containing `docopt-config.cmake`. If the root directory of your
           docopt.cpp installation is `C:/docopt.cpp-install`, then set this
           variable to `C:/docopt.cpp-install/lib/cmake`.
        3. spdlog: Set the variable `spdlog_DIR` to the directory containing
           `spdlogConfig.cmake`. If the root directory of your spdlog 
           installation is `C:/spdlog-install`, then set this variable to
           `C:/spdlog-install/lib/spdlog/cmake`.
7. Set the remaining configuration options.
    * `BUILD_API_EXAMPLES` to compile C++ API examples.
    * `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a
      while to build; if you want to build OpenSim quickly, you can turn this
      off.
    * `BUILD_JAVA_WRAPPING` if you want to access OpenSim through MATLAB or
      Java; see dependencies above.
    * `BUILD_PYTHON_WRAPPING` if you want to access OpenSim through Python; see
      dependencies above. CMake sets `PYTHON_*` variables to tell you the
      Python version used when building the wrappers.
    * `OPENSIM_PYTHON_VERSION` to choose if the Python wrapping is built for
      Python 2 or Python 3.
    * `BUILD_API_ONLY` if you don't want to build the command-line applications.
    * `OPENSIM_WITH_CASADI` if you want support for MocoCasADiSolver.
    * `OPENSIM_WITH_TROPTER` if you want support for MocoTropterSolver.
8. Click the **Configure** button again. Then, click **Generate** to make
   Visual Studio project files in the build directory.

#### Build and install

1. Open `C:/opensim-core-build/OpenSim.sln` in Visual Studio.
2. Select your desired *Solution configuration* from the drop-down at the top.
    * **Debug**: debugger symbols; no optimizations (more than 10x slower).
      Library names end with `_d`.
    * **Release**: no debugger symbols; optimized.
    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower
      than Release; choose this if unsure.
    * **MinSizeRel**: minimum size; optimized.

    You at least want release libraries (the last 3 count as release), but you
    can have debug libraries coexist with them. To do this, go through the
    installation process twice, once for each of the two configurations. You
    should install the release configuration *last* to ensure that you use the
    release version of the command-line applications instead of the slow debug
    versions.
3. Build the API documentation. This is optional, and you can only do this if
   you have Doxygen. Build the documentation by right-clicking **doxygen** and
   selecting **Build**.
4. Build the libraries, etc. by right-clicking  **ALL_BUILD** and selecting
   **Build**.
5. Run the tests by right-clicking **RUN_TESTS_PARALLEL** and selecting
   **Build**.
6. Install OpenSim-Core by right-clicking **INSTALL** and selecting **Build**.

#### Set environment variables

In order to use the OpenSim-Core command-line applications or use OpenSim-Core
libraries in your own application, you must add the OpenSim-Core `bin/`
directory to your `PATH` environment variable.

1. In the Windows toolbar (Windows 10), Start screen (Windows 8) or Start menu
   (Windows 7), search `environment`.
2. Select **Edit the system environment variables**.
3. Click **Environment Variables...**.
4. Under **System variables**, click **Path**, then click **Edit**.
5. Add **C:/opensim-core/bin;** to the front of of the text field. Don't forget
   the semicolon!

#### For the impatient (Windows)

* Get **Visual Studio Community**
  [2019](https://www.visualstudio.com/vs/)
  * Choose *Custom installation*, then choose
    *Programming Languages* -> *Visual C++*.
* Get **git** from [here](https://git-scm.com/downloads).
  * Choose *Use Git from the Windows Command Prompt*.
* Get **CMake** from [here](https://cmake.org/download/).
  * Choose *Add CMake to the system PATH for all users*.
* Get **Chocolatey** from [here](https://chocolatey.org/).
* In **PowerShell**, *run as Administrator*:

  ```powershell
  choco install python2 jdk8 swig
  ```
* In **PowerShell**:

  ```powershell
  git clone https://github.com/opensim-org/opensim-core.git
  mkdir opensim_dependencies_build
  cd .\opensim_dependencies_build
  cmake ..\opensim-core\dependencies                             `
        -G"Visual Studio 16 2019 Win64"                          `
        -DCMAKE_INSTALL_PREFIX="..\opensim_dependencies_install"
  cmake --build . --config RelWithDebInfo -- /maxcpucount:8
  cd ..
  mkdir opensim_build
  cd .\opensim_build
  cmake ..\opensim-core                                              `
        -G"Visual Studio 16 2019 Win64"                              `
        -DCMAKE_INSTALL_PREFIX="..\opensim_install"                  `
        -DOPENSIM_DEPENDENCIES_DIR="..\opensim_dependencies_install" `
        -DBUILD_JAVA_WRAPPING=ON                                     `
        -DBUILD_PYTHON_WRAPPING=ON
  cmake --build . --config RelWithDebInfo -- /maxcpucount:8
    the same install directory for all build types. You should install the
    release build type *last* to ensure that you use the release version of
    the command-line applications instead of the slow debug versions.
    
    * Note: Superbuild attempts to determine when dependencies are out of date
      but is not always successful. It is therefore recommended to build all
      dependencies from scratch when updating your installation.
8. Click the **Configure** button again. Then, click **Generate** to make Unix
   Makefiles in the build directory.
9. Open a terminal and navigate to the build directory.

On Mac OSX using Xcode
======================

   in parallel); this will greatly speed up your build. For example:

        $ make -j8
11. If necessary, repeat this whole procedure for other build types.

#### Configure and generate project files
brew install cmake swig gcc pkgconfig autoconf libtool automake wget doxygen
brew cask install java
git clone https://github.com/opensim-org/opensim-core.git
mkdir opensim_dependencies_build
cd opensim_dependencies_build
cmake ../opensim-core/dependencies \
      -DCMAKE_INSTALL_PREFIX="~/opensim_dependencies_install" \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j8
cd ..
mkdir opensim_build
cd opensim_build
cmake ../opensim-core \
      -DCMAKE_INSTALL_PREFIX="~/opensim_install" \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DBUILD_PYTHON_WRAPPING=ON \
      -DBUILD_JAVA_WRAPPING=ON \
      -DOPENSIM_DEPENDENCIES_DIR="~/opensim_dependencies_install"
make -j8
ctest -j8
```


### Extended Instructions for OSX

#### Get the dependencies

* **operating system**: Mac OSX 10.11 El Capitan or newer.
* **cross-platform build system**:
  [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.2
* **compiler / IDE**: [Xcode](https://developer.apple.com/xcode/) >= 7.3 (the latest version), through
  the Mac App Store.
* **physics engine**: Simbody latest. Two options:
  * Let OpenSim get this for you using superbuild (see below).
  * [Build on your own](https://github.com/simbody/simbody#installing).
* **C3D file support**: EZC3D or Biomechanical-ToolKit Core. 
  * Let OpenSim get this for you using superbuild (see below).
* **command-line argument parsing**: docopt.cpp. Two options:
    * Let OpenSim get this for you using superbuild (see below); much easier!
    * [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).
* **logging**: spdlog. Two options:
    * Let OpenSim get this for you using superbuild (see below); much easier!
    * [Build on your own](https://github.com/gabime/spdlog).
* **Moco optimal control solvers**: Solving optimal control problems with 
    OpenSim's Moco module requires either CasADi or Tropter. Use superbuild for
    all these dependencies (except for Tropter, which is part of this
    repository).
    * **MocoCasADiSolver** (optional): [CasADi](https://web.casadi.org) (LGPL).
    * **MocoTropterSolver** (optional): Tropter.
        * **matrix library**: [Eigen](http://eigen.tuxfamily.org) >= 3.3.7
        * **sparse matrix algorithms**: [ColPack](https://github.com/CSCsw/ColPack).
        * **automatic differentiation**: [ADOL-C](https://github.com/coin-or/ADOL-C) >= 2.6.3.
    * **nonlinear optimizer** (required if building with CasADi or Tropter): 
        [IPOPT](https://github.com/coin-or/Ipopt) >= 3.12.8.
* **API documentation** (optional):
  [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6
* **version control** (optional): git.
    * Xcode Command Line Tools gives you git on the command line.
    * [GitHub for Mac](https://mac.github.com), for a simple-to-use GUI.
* **Bindings** (optional): [SWIG](http://www.swig.org/) 4.0.2
    * **MATLAB scripting** (optional): [Java development kit][java] >= 1.7.
        * Note: Older versions of MATLAB may use an older version of JVM. Run
                'ver' in MATLAB to check MATLAB's JVM version (must be >= 1.7).
        * Note: Java development kit >= 9 requires CMake >= 3.10.
    * **Python scripting** (optional): Python 2 >= 2.7 or Python 3 >= 3.5
        * Mac OSX comes with Python, but you could also use:
        * [`brew install python`](http://brew.sh),
        * [Anaconda](https://www.anaconda.com/distribution/)
        * Must provide the NumPy package; this should come with Anaconda.

You can get most of these dependencies using [Homebrew](http://brew.sh):

    $ brew install cmake doxygen swig

#### Download the OpenSim-Core source code

* Method 1; If you want to get going quickly, download the source code from
  https://github.com/opensim-org/opensim-core/releases, for the version of
  OpenSim you want. We'll assume you unzipped the source code into
  `~/opensim-core-source`.
* Method 2: If you plan on updating your OpenSim installation or you want to
  contribute back to the project, clone the opensim-core git repository into
  `~/opensim-core-source`. Run the following in a terminal, or
  find a way to run the equivalent commands in a GUI client:

        $ git clone https://github.com/opensim-org/opensim-core.git ~/opensim-core-source

  This will give you a bleeding-edge version of OpenSim-Core.

#### [Optional] Superbuild: download and build OpenSim dependencies
1. Open the CMake GUI.
2. In the field **Where is the source code**, specify
   `~/opensim-core-source/dependencies`.
3. In the field **Where to build the binaries**, specify a directory under
   which to build dependencies. Let's say this is
   `~/opensim-core-dependencies-build`.
4. Click the **Configure** button. Choose **Xcode**. Click **Finish**.
5. Where do you want to install OpenSim dependencies on your computer? Set this
   by changing the `CMAKE_INSTALL_PREFIX` variable. Let's say this is
   `~/opensim-core-dependencies-install`.
6. Variables named `SUPERBUILD_<dependency-name>` allow you to selectively
   download dependencies. By default, all dependencies are downloaded,
   configured and built.
7. Click the **Configure** button again. Then, click **Generate** to make Xcode
   files in the build directory.
8. Open `~/opensim-core-dependencies/build/OpenSimDependencies.xcodeproj` in
   Xcode.
9. Choose your **Build Configuration** for the **ALL_BUILD** Scheme by pressing
   `Command-Shift ,` (or, `Command-LessThan`), or navigating to **Product ->
   Scheme -> Edit Scheme...**; and changing the **Build Configuration** field.
    * **Debug**: debugger symbols; no optimizations (more than 10x slower).
    Library names end with `_d`.
    * **Release**: no debugger symbols; optimized.
    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower
    than Release; choose this if unsure.
    * **MinSizeRel**: minimum size; optimized.

    You must build each of the configurations you plan to use with OpenSim (see
    below). You should install the release configuration *last* to ensure that
    you use the release version of the command-line applications instead of the
    slow debug versions.
10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the
   upper left. If necessary, change the build configuration (previous step) and
   run **ALL_BUILD** again.

    * Note: Superbuild attempts to determine when dependencies are out of date
      but is not always successful. It is therefore recommended to build all
      dependencies from scratch when updating your installation.

#### Configure and generate project files

1. Open the CMake GUI.
2. In the field **Where is the source code**, specify `~/opensim-core-source`.
3. In the field **Where to build the binaries**, specify something like
   `~/opensim-core-build`, or some other path that is not inside your source
   directory. This is *not* where we are installing OpenSim-Core; see below.
4. Click the **Configure** button. Choose **Xcode**. Click **Finish**.
5. Where do you want to install OpenSim-Core on your computer? Set this by
   changing the `CMAKE_INSTALL_PREFIX` variable. We'll assume you set it to
   `~/opensim-core`. If you choose a different installation location, make
   sure to use *yours* where we use `~/opensim-core` below. You should *not*
   use `/usr/`, `/usr/local/`, etc. (because our installation does not yet
   conform to the [FHS](http://www.pathname.com/fhs/)).
6. Tell CMake where to find dependencies. This depends on how you got them.
    * Superbuild: Set the variable `OPENSIM_DEPENDENCIES_DIR` to the root
      directory you specified with superbuild for installation of dependencies.
      In our example, it would be `~/opensim-core-dependencies-install`.
    * Obtained on your own:
        1. Simbody: Set the `SIMBODY_HOME` variable to where you installed
           Simbody (e.g., `~/simbody`). If you installed Simbody using `brew`,
           then CMake will find Simbody automatically.
        2. docopt.cpp: Set the variable `docopt_DIR` to the directory
           containing `docopt-config.cmake`. If the root directory of your
           docopt.cpp installation is `~/docopt.cpp-install`, then set this
           variable to `~/docopt.cpp-install/lib/cmake`.
        3. spdlog: Set the variable `spdlog_DIR` to the directory containing
           `spdlogConfig.cmake`. If the root directory of your spdlog 
           installation is `~/spdlog-install`, then set this variable to
           `~/spdlog-install/lib/spdlog/cmake`.
7. Set the remaining configuration options.
    * `BUILD_API_EXAMPLES` to compile C++ API examples.
    * `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a
      while to build; if you want to build OpenSim quickly, you can turn this
      off.
    * `BUILD_JAVA_WRAPPING` if you want to access OpenSim through MATLAB or
      Java; see dependencies above.
    * `BUILD_PYTHON_WRAPPING` if you want to access OpenSim through Python; see
      dependencies above. CMake sets `PYTHON_*` variables to tell you the
      Python version used when building the wrappers.
    * `OPENSIM_PYTHON_VERSION` to choose if the Python wrapping is built for
      Python 2 or Python 3.
    * `BUILD_API_ONLY` if you don't want to build the command-line applications.
8. Click the **Configure** button again. Then, click **Generate** to create
   Xcode project files in the build directory.

#### Build and install

1. Open `~/opensim-core-build/OpenSim.xcodeproj` in Xcode.
2. Choose your **Build Configuration** for the **ALL_BUILD** Scheme by pressing
   `Command-Shift ,` (or, `Command-LessThan`), or navigating to **Product ->
   Scheme -> Edit Scheme...**; and changing the **Build Configuration** field.
    * **Debug**: debugger symbols; no optimizations (more than 10x slower).
    Library names end with `_d`.
    * **Release**: no debugger symbols; optimized.
    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower
    than Release; choose this if unsure.
    * **MinSizeRel**: minimum size; optimized.

    You at least want release libraries (the last 3 count as release), but you
    can have debug libraries coexist with them. To do this, go through the
    installation process twice, once for each of the two configurations. You
    should install the release configuration *last* to ensure that you use the
    release version of the command-line applications instead of the slow debug
    versions.

3. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the
   upper left.
4. Test. Click on **ALL_BUILD** in the upper left, and select
   **RUN_TESTS_PARALLEL**. Change the **Build Configuration** of this Scheme to
   the same as you used for **ALL_BUILD** (using the same instructions as
   above). Click the play button.
5. Build the API documentation. This is optional, and you can only do this if
   you have Doxygen. Click on the current Scheme (**RUN_TESTS_PARALLEL**) and
   select **doxygen**. Click the play button.
6. Install. Click on the current Scheme (**RUN_TESTS_PARALLEL** or
   **doxygen**), and select **install**. Click the play button.

#### Set environment variables

1. **Executables**. If you want to run OpenSim-Core's executables from
   anywhere on your computer, you must update your PATH. Open a terminal and
   type:

        $ echo 'export PATH=~/opensim-core/bin:$PATH' >> ~/.bash_profile

Your changes will only take effect in new terminal windows.


On Ubuntu using Unix Makefiles
==============================

#### Get the dependencies

Most dependencies can be obtained via the Ubuntu software repositories;
especially if you are using Ubuntu 16.04 or later. On each line below, we show
the Ubuntu package names for the dependencies. You can find instructions for
specific Ubuntu versions under 'For the impatient' below.

* **cross-platform build system**:
  [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.2;
  `cmake-gui`.
* **compiler**: [gcc](http://gcc.gnu.org) >= 4.9; `g++-4.9`, or
  [Clang](http://clang.llvm.org) >= 3.4; `clang-3.4`.
* **physics engine**: Simbody >= 3.7. Two options:
  * Let OpenSim get this for you using superbuild (see below).
  * [Build on your own](https://github.com/simbody/simbody#installing).
* **C3D file support**: Biomechanical-ToolKit Core. Two options:
  * Let OpenSim get this for you using superbuild (see below).
* **command-line argument parsing**: docopt.cpp. Two options:
    * Let OpenSim get this for you using superbuild (see below); much easier!
    * [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).
* **logging**: spdlog. Two options:
    * Let OpenSim get this for you using superbuild (see below); much easier!
    * [Build on your own](https://github.com/gabime/spdlog).
* **Moco optimal control solvers**: Solving optimal control problems with 
    OpenSim's Moco module requires either CasADi or Tropter. Use superbuild for
    all these dependencies (except for Tropter, which is part of this
    repository).
    * **MocoCasADiSolver** (optional): [CasADi](https://web.casadi.org) (LGPL).
    * **MocoTropterSolver** (optional): Tropter.
        * **matrix library**: [Eigen](http://eigen.tuxfamily.org) >= 3.3.7
        * **sparse matrix algorithms**: [ColPack](https://github.com/CSCsw/ColPack).
        * **automatic differentiation**: [ADOL-C](https://github.com/coin-or/ADOL-C) >= 2.6.3.
    * **nonlinear optimizer** (required if building with CasADi or Tropter): 
        [IPOPT](https://github.com/coin-or/Ipopt) >= 3.12.8.
* **API documentation** (optional):
  [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6;
  `doxygen`.
* **version control** (optional): git; `git`.
* **Bindings** (optional): [SWIG](http://www.swig.org/) 4.0.2; `swig`.
    * **MATLAB scripting** (optional): [Java development kit][java] >= 1.7;
      `openjdk-7-jdk`.
        * Note: Older versions of MATLAB may use an older version of JVM. Run
                'ver' in MATLAB to check MATLAB's JVM version (must be >= 1.7).
        * Note: Java development kit >= 9 requires CMake >= 3.10.
    * **Python scripting** (optional): Python 2 >= 2.7 or Python 3 >= 3.5; `python-dev`.
        * Must provide the NumPy package; `python-numpy`.

For example, you could get the required dependencies (except Simbody) via:

    $ sudo apt-get install cmake-gui g++-4.9

And you could get all the optional dependencies via:

    $ sudo apt-get install doxygen git swig openjdk-7-jdk python-dev python-numpy wget build-essential libtool autoconf pkg-config gfortran

#### Download the OpenSim-Core source code

* Method 1; If you want to get going quickly, download the source code from
  https://github.com/opensim-org/opensim-core/releases, for the version of
  OpenSim you want. We'll assume you unzipped the source code into
  `~/opensim-core-source`.
* Method 2: If you plan on updating your OpenSim installation or you want to
  contribute back to the project, clone the opensim-core git repository into
  `C:/opensim-core-source`. Run the following in a terminal:

        $ git clone https://github.com/opensim-org/opensim-core.git ~/opensim-core-source

  This will give you a bleeding-edge version of OpenSim-Core.

#### [Optional] Superbuild: download and build OpenSim dependencies
1. Open the CMake GUI.
2. In the field **Where is the source code**, specify
   `~/opensim-core-source/dependencies`.
3. In the field **Where to build the binaries**, specify a directory under
   which to build dependencies. Let's say this is
   `~/opensim-core-dependencies-build`.
4. Click the **Configure** button. Choose *Unix Makefiles*. Click **Finish**.
5. Where do you want to install OpenSim dependencies on your computer? Set this
   by changing the `CMAKE_INSTALL_PREFIX` variable. Let's say this is
   `~/opensim-core-dependencies-install`.
6. Variables named `SUPERBUILD_<dependency-name>` allow you to selectively
   download dependencies. By default, all dependencies are downloaded,
   configured and built.
7. Choose your build type by setting `CMAKE_BUILD_TYPE` to one of the following:
    * **Debug**: debugger symbols; no optimizations (more than 10x slower).
    Library names end with `_d`.
    * **Release**: no debugger symbols; optimized.
    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower
    than Release; choose this if unsure.
    * **MinSizeRel**: minimum size; optimized.

    You must perform the superbuild procedure for each of the
    build types you plan to use with OpenSim (see below). You might want to
    use different build directories for each build type, though you can use
    the same install directory for all build types. You should install the
    release build type *last* to ensure that you use the release version of
    the command-line applications instead of the slow debug versions.
8. Click the **Configure** button again. Then, click **Generate** to make Unix
   Makefiles in the build directory.
9. Open a terminal and navigate to the build directory.

        $ cd ~/opensim-core-dependencies-build

3. Compile. Use the `-jn` flag to build using `n` concurrent jobs (potentially
   in parallel); this will greatly speed up your build. For example:

        $ make -j8

    * Note: Superbuild attempts to determine when dependencies are out of date
      but is not always successful. It is therefore recommended to build all
      dependencies from scratch when updating your installation.
11. If necessary, repeat this whole procedure for other build types.

#### Configure and generate project files

1. Open the CMake GUI.
2. In the field **Where is the source code**, specify `~/opensim-core-source`.
3. In the field **Where to build the binaries**, specify something like
   `~/opensim-core-build`, or some other path that is not inside your source
   directory. This is *not* where we are installing OpenSim-Core; see below.
4. Click the **Configure** button. Choose *Unix Makefiles*. Click **Finish**.
5. Where do you want to install OpenSim-Core on your computer? Set this by
   changing the `CMAKE_INSTALL_PREFIX` variable. We'll assume you set it to
   `~/opensim-core`. If you choose a different installation location, make
   sure to use *yours* where we use `~/opensim-core` below. You should *not*
   use `/usr/`, `/usr/local/`, etc. (because our installation does not yet
   conform to the [FHS](http://www.pathname.com/fhs/)), but
   [`/opt/`](http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/opt.html)
   is okay.
6. Tell CMake where to find dependencies. This depends on how you got them.
    * Superbuild: Set the variable `OPENSIM_DEPENDENCIES_DIR` to the root
      directory you specified with superbuild for installation of dependencies.
      In our example, it would be `~/opensim-core-dependencies-install`.
    * Obatained on your own:
        1. Simbody: Set the `SIMBODY_HOME` variable to where you installed
           Simbody (e.g., `~/simbody`).
        2. docopt.cpp: Set the variable `docopt_DIR` to the directory
           containing `docopt-config.cmake`. If the root directory of your
           docopt.cpp installation is `~/docopt.cpp-install`, then set this
           variable to `~/docopt.cpp-install/lib/cmake`.
        3. spdlog: Set the variable `spdlog_DIR` to the directory containing
           `spdlogConfig.cmake`. If the root directory of your spdlog 
           installation is `~/spdlog-install`, then set this variable to
           `~/spdlog-install/lib/spdlog/cmake`.
7. Choose your build type by setting `CMAKE_BUILD_TYPE` to one of the following:
    * **Debug**: debugger symbols; no optimizations (more than 10x slower).
    Library names end with `_d`.
    * **Release**: no debugger symbols; optimized.
    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower
    than Release; choose this if unsure.
    * **MinSizeRel**: minimum size; optimized.

    You at least want release libraries (the last 3 count as release), but you
    can have debug libraries coexist with them. To do this, go through the
    installation process twice, once for each of the two build types. It is
    typical to use a different build directory for each build type (e.g.,
    `~/opensim-core-build-debug` and `~/opensim-core-build-release`). You
    should install the release build type *last* to ensure that you use the
    release version of the command-line applications instead of the slow debug
    versions.
8. Set the remaining configuration options.
    * `BUILD_API_EXAMPLES` to compile C++ API examples.
    * `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a
      while to build; if you want to build OpenSim quickly, you can turn this
      off.
    * `BUILD_JAVA_WRAPPING` if you want to access OpenSim through MATLAB or
      Java; see dependencies above.
    * `BUILD_PYTHON_WRAPPING` if you want to access OpenSim through Python; see
      dependencies above.
    * `OPENSIM_PYTHON_VERSION` to choose if the Python wrapping is built for
      Python 2 or Python 3.
    * `BUILD_API_ONLY` if you don't want to build the command-line applications.
    * `OPENSIM_COPY_DEPENDENCIES` to decide if Simbody is copied into
      the OpenSim installation; you want this off if you're installing OpenSim
      into `/usr/` or `/usr/local/`.
9. Click the **Configure** button again. Then, click **Generate** to create
   Makefiles in the build directory.

#### Build and install

1. Open a terminal and navigate to the build directory.

        $ cd ~/opensim-core-build

2. Build the API documentation. This is optional, and you can only do this if
   you have Doxygen.

        $ make doxygen

3. Compile. Use the `-jn` flag to build using `n` concurrent jobs (potentially
   in parallel); this will greatly speed up your build. For example:

        $ make -j8

4. Run the tests.

        $ ctest -j8

5. Install (to `~/opensim-core`).

        $ make -j8 install

#### Set environment variables

1. **Executables**. Add OpenSim-Core's executables to the path so you can
   access them from any directory on your computer.

        $ echo 'export PATH=~/opensim-core/bin:$PATH' >> ~/.bashrc

Your changes will only take effect in new terminal windows.

#### For the impatient (Ubuntu)
##### Ubuntu 18.0
In **Terminal** --

```shell
sudo add-apt-repository --yes ppa:george-edison55/cmake-3.x
sudo apt-add-repository --yes ppa:fenics-packages/fenics-exp
sudo apt-get update
sudo apt-get --yes install git cmake cmake-curses-gui clang-3.6 \
                           freeglut3-dev libxi-dev libxmu-dev \
                           liblapack-dev swig3.0 python-dev \
                           openjdk-7-jdk
sudo rm -f /usr/bin/cc /usr/bin/c++
sudo ln -s /usr/bin/clang-3.6 /usr/bin/cc
sudo ln -s /usr/bin/clang++-3.6 /usr/bin/c++
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
git clone https://github.com/opensim-org/opensim-core.git
mkdir opensim_dependencies_build
cd opensim_dependencies_build
cmake ../opensim-core/dependencies/ \
      -DCMAKE_INSTALL_PREFIX='~/opensim_dependencies_install' \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j8
cd ..
mkdir opensim_build
cd opensim_build
cmake ../opensim-core \
      -DCMAKE_INSTALL_PREFIX="~/opensim_install" \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DOPENSIM_DEPENDENCIES_DIR="~/opensim_dependencies_install" \
      -DBUILD_PYTHON_WRAPPING=ON \
      -DBUILD_JAVA_WRAPPING=ON
make -j8
ctest -j8
make -j8 install
 ```

Note: You may need to add `<FULL-DIR>/opensim_install/bin` to your PATH variable as per [these instructions](#set-environment-variables-2).  
Example: If opensim_install is in your home directory:

        $ echo 'export PATH=~/opensim_install/bin:$PATH' >> ~/.bashrc


[buildstatus_image_travis]: https://travis-ci.org/opensim-org/opensim-core.svg?branch=master
[travisci]: https://travis-ci.org/opensim-org/opensim-core
[buildstatus_image_appveyor]: https://ci.appveyor.com/api/projects/status/i4wxnmx9jlk69kge/branch/master?svg=true
[appveyorci]: https://ci.appveyor.com/project/opensim-org/opensim-core/branch/master
[zenhub_image]: https://dxssrr2j0sq4w.cloudfront.net/3.2.0/img/external/zenhub-badge.png
[zenhub]: https://zenhub.com

[running_gif]: doc/images/opensim_running.gif
[simple_example_gif]: doc/images/opensim_double_pendulum_muscle.gif
[java]: http://www.oracle.com/technetwork/java/javase/downloads/index.html

<MSG> Relocate notes about rebuilding. [ci skip]

<DFF> @@ -268,7 +268,7 @@ On Windows using Visual Studio
    with OpenSim (see below). You should run this command for the release
    configuration *last* to ensure that you use the release version of the
    command-line applications instead of the slow debug versions.
-   
+
    * Note: Superbuild attempts to determine when dependencies are out of date
      but is not always successful. It is therefore recommended to build all
      dependencies from scratch when updating your installation.
@@ -530,13 +530,13 @@ You can get most of these dependencies using [Homebrew](http://brew.sh):
     below). You should install the release configuration *last* to ensure that
     you use the release version of the command-line applications instead of the
     slow debug versions.
+10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the
+   upper left. If necessary, change the build configuration (previous step) and
+   run **ALL_BUILD** again.
 
     * Note: Superbuild attempts to determine when dependencies are out of date
       but is not always successful. It is therefore recommended to build all
       dependencies from scratch when updating your installation.
-10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the
-   upper left. If necessary, change the build configuration (previous step) and
-   run **ALL_BUILD** again.
 
 #### Configure and generate project files
 
@@ -711,10 +711,6 @@ And you could get all the optional dependencies via:
     the same install directory for all build types. You should install the
     release build type *last* to ensure that you use the release version of
     the command-line applications instead of the slow debug versions.
-    
-    * Note: Superbuild attempts to determine when dependencies are out of date
-      but is not always successful. It is therefore recommended to build all
-      dependencies from scratch when updating your installation.
 8. Click the **Configure** button again. Then, click **Generate** to make Unix
    Makefiles in the build directory.
 9. Open a terminal and navigate to the build directory.
@@ -725,6 +721,10 @@ And you could get all the optional dependencies via:
    in parallel); this will greatly speed up your build. For example:
 
         $ make -j8
+
+    * Note: Superbuild attempts to determine when dependencies are out of date
+      but is not always successful. It is therefore recommended to build all
+      dependencies from scratch when updating your installation.
 11. If necessary, repeat this whole procedure for other build types.
 
 #### Configure and generate project files

{'commit': 'diff --git a/README.md b/README.md\nindex 0341f4a64..333827412 100644\n--- a/README.md\n+++ b/README.md\n@@ -268,7 +268,7 @@ On Windows using Visual Studio\n    with OpenSim (see below). You should run this command for the release\n    configuration *last* to ensure that you use the release version of the\n    command-line applications instead of the slow debug versions.\n-   \n+\n    * Note: Superbuild attempts to determine when dependencies are out of date\n      but is not always successful. It is therefore recommended to build all\n      dependencies from scratch when updating your installation.\n@@ -530,13 +530,13 @@ You can get most of these dependencies using [Homebrew](http://brew.sh):\n     below). You should install the release configuration *last* to ensure that\n     you use the release version of the command-line applications instead of the\n     slow debug versions.\n+10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the\n+   upper left. If necessary, change the build configuration (previous step) and\n+   run **ALL_BUILD** again.\n \n     * Note: Superbuild attempts to determine when dependencies are out of date\n       but is not always successful. It is therefore recommended to build all\n       dependencies from scratch when updating your installation.\n-10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the\n-   upper left. If necessary, change the build configuration (previous step) and\n-   run **ALL_BUILD** again.\n \n #### Configure and generate project files\n \n@@ -711,10 +711,6 @@ And you could get all the optional dependencies via:\n     the same install directory for all build types. You should install the\n     release build type *last* to ensure that you use the release version of\n     the command-line applications instead of the slow debug versions.\n-    \n-    * Note: Superbuild attempts to determine when dependencies are out of date\n-      but is not always successful. It is therefore recommended to build all\n-      dependencies from scratch when updating your installation.\n 8. Click the **Configure** button again. Then, click **Generate** to make Unix\n    Makefiles in the build directory.\n 9. Open a terminal and navigate to the build directory.\n@@ -725,6 +721,10 @@ And you could get all the optional dependencies via:\n    in parallel); this will greatly speed up your build. For example:\n \n         $ make -j8\n+\n+    * Note: Superbuild attempts to determine when dependencies are out of date\n+      but is not always successful. It is therefore recommended to build all\n+      dependencies from scratch when updating your installation.\n 11. If necessary, repeat this whole procedure for other build types.\n \n #### Configure and generate project files\n', 'commit_subject': 'Relocate notes about rebuilding. [ci skip]', 'repo_name': 'opensim-org/opensim-core', 'committer': {'name': 'Tom Uchida', 'email': 'e5a9f087e6112d34b8b71a2bd0996bfe1bbd2e15@gmail.com', 'time_sec': '1506715682', 'tz_offset': '-420', 'date': {'seconds': '1506715682'}}, 'commit_tree': '6c0dddea44e0b4d6c64f81b3b06ef8e142e8c942', 'commit_message': 'Relocate notes about rebuilding. [ci skip]\n', 'language_name': 'C', 'license': 'apache-2.0', 'hunks': '@@ -268,7 +268,7 @@ On Windows using Visual Studio\n    with OpenSim (see below). You should run this command for the release\n    configuration *last* to ensure that you use the release version of the\n    command-line applications instead of the slow debug versions.\n-   \n+\n    * Note: Superbuild attempts to determine when dependencies are out of date\n      but is not always successful. It is therefore recommended to build all\n      dependencies from scratch when updating your installation.\n@@ -530,13 +530,13 @@ You can get most of these dependencies using [Homebrew](http://brew.sh):\n     below). You should install the release configuration *last* to ensure that\n     you use the release version of the command-line applications instead of the\n     slow debug versions.\n+10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the\n+   upper left. If necessary, change the build configuration (previous step) and\n+   run **ALL_BUILD** again.\n \n     * Note: Superbuild attempts to determine when dependencies are out of date\n       but is not always successful. It is therefore recommended to build all\n       dependencies from scratch when updating your installation.\n-10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the\n-   upper left. If necessary, change the build configuration (previous step) and\n-   run **ALL_BUILD** again.\n \n #### Configure and generate project files\n \n@@ -711,10 +711,6 @@ And you could get all the optional dependencies via:\n     the same install directory for all build types. You should install the\n     release build type *last* to ensure that you use the release version of\n     the command-line applications instead of the slow debug versions.\n-    \n-    * Note: Superbuild attempts to determine when dependencies are out of date\n-      but is not always successful. It is therefore recommended to build all\n-      dependencies from scratch when updating your installation.\n 8. Click the **Configure** button again. Then, click **Generate** to make Unix\n    Makefiles in the build directory.\n 9. Open a terminal and navigate to the build directory.\n@@ -725,6 +721,10 @@ And you could get all the optional dependencies via:\n    in parallel); this will greatly speed up your build. For example:\n \n         $ make -j8\n+\n+    * Note: Superbuild attempts to determine when dependencies are out of date\n+      but is not always successful. It is therefore recommended to build all\n+      dependencies from scratch when updating your installation.\n 11. If necessary, repeat this whole procedure for other build types.\n \n #### Configure and generate project files\n', 'addition_count': 8, 'deletion_count': 8, 'src_file': 'a/README.md', 'tgt_file': 'b/README.md', 'file_extension': '.md', 'before_file': 'OpenSim Core\n============\n![continuous-integration](https://github.com/opensim-org/opensim-core/workflows/continuous-integration/badge.svg)[![ZenHub][zenhub_image]][zenhub]\n\n**NOTE: This repository cannot be used to build OpenSim 3.x or earlier. For OpenSim 3.x, see [here](http://simtk-confluence.stanford.edu:8080/display/OpenSim/Building+OpenSim+from+Source).**\n\nOpenSim is software that lets users develop models of musculoskeletal\nstructures and create dynamic simulations of movement, such as this one:\n\n![Simulation of human running by Sam Hamner (doi:\n10.1016/j.jbiomech.2010.06.025)][running_gif]\n\nMore information can be found at our websites:\n\n* [OpenSim website](http://opensim.stanford.edu); in particular, the [support\n  page](http://opensim.stanford.edu/support/index.html).\n* [SimTK project website](https://simtk.org/home/opensim)\n\nThis repository contains the source code for OpenSim\'s C++ libraries, C++\nexamples, command-line applications (inverse kinematics, computed muscle\ncontrol, etc.), and Java and Python wrapping. This repository does *not*\ninclude source code for the OpenSim GUI.\n\n\nTable of contents\n-----------------\n- [Simple Example](#simple-example)\n- [Building from the source code](#building-from-the-source-code)\n  - [On Windows using Microsoft Visual Studio](#on-windows-using-visual-studio).\n  - [On Mac OSX using Xcode](#on-mac-osx-using-xcode).\n  - [On Ubuntu using Unix Makefiles](#on-ubuntu-using-unix-makefiles).\n\n\nSimple example\n--------------\nLet\'s simulate a simple arm whose elbow is actuated by a muscle, using\nthe C++ interface \n\n<details open>\n<summary>C++</summary>\n\n```cpp\n#include <OpenSim/OpenSim.h>\nusing namespace SimTK;\nusing namespace OpenSim;\n\nint main() {\n    Model model;\n    model.setName("bicep_curl");\n    model.setUseVisualizer(true);\n\n    // Create two links, each with a mass of 1 kg, center of mass at the body\'s\n    // origin, and moments and products of inertia corresponding to an\n    // ellipsoid with radii of 0.1, 0.5 and 0.1, in the x, y and z directions,\n    // respectively.\n    OpenSim::Body* humerus = new OpenSim::Body(\n        "humerus", 1.0, Vec3(0), Inertia(0.052, 0.004, 0.052));\n    OpenSim::Body* radius  = new OpenSim::Body(\n        "radius",  1.0, Vec3(0), Inertia(0.052, 0.004, 0.052));\n\n    // Connect the bodies with pin joints. Assume each body is 1 m long.\n    PinJoint* shoulder = new PinJoint("shoulder",\n            // Parent body, location in parent, orientation in parent.\n            model.getGround(), Vec3(0), Vec3(0),\n            // Child body, location in child, orientation in child.\n            *humerus, Vec3(0, 0.5, 0), Vec3(0));\n    PinJoint* elbow = new PinJoint("elbow",\n            *humerus, Vec3(0, -0.5, 0), Vec3(0),\n            *radius, Vec3(0, 0.5, 0), Vec3(0));\n\n    // Add a muscle that flexes the elbow.\n    Millard2012EquilibriumMuscle* biceps = new\n        Millard2012EquilibriumMuscle("biceps", 200, 0.6, 0.55, 0);\n    biceps->addNewPathPoint("origin",    *humerus, Vec3(0, 0.3, 0));\n    biceps->addNewPathPoint("insertion", *radius,  Vec3(0, 0.2, 0));\n\n    // Add a controller that specifies the excitation of the muscle.\n    PrescribedController* brain = new PrescribedController();\n    brain->addActuator(*biceps);\n    // Muscle excitation is 0.3 for the first 0.5 seconds, then increases to 1.\n    brain->prescribeControlForActuator("biceps",\n            new StepFunction(0.5, 3, 0.3, 1));\n\n    // Add components to the model.\n    model.addBody(humerus);    model.addBody(radius);\n    model.addJoint(shoulder);  model.addJoint(elbow);\n    model.addForce(biceps);\n    model.addController(brain);\n\n    // Add a console reporter to print the muscle fiber force and elbow angle.\n    ConsoleReporter* reporter = new ConsoleReporter();\n    reporter->set_report_time_interval(1.0);\n    reporter->addToReport(biceps->getOutput("fiber_force"));\n    reporter->addToReport(\n        elbow->getCoordinate(PinJoint::Coord::RotationZ).getOutput("value"),\n        "elbow_angle");\n    model.addComponent(reporter);\n\n    // Add display geometry.\n    Ellipsoid bodyGeometry(0.1, 0.5, 0.1);\n    bodyGeometry.setColor(Gray);\n    // Attach an ellipsoid to a frame located at the center of each body.\n    PhysicalOffsetFrame* humerusCenter = new PhysicalOffsetFrame(\n        "humerusCenter", *humerus, Transform(Vec3(0)));\n    humerus->addComponent(humerusCenter);\n    humerusCenter->attachGeometry(bodyGeometry.clone());\n    PhysicalOffsetFrame* radiusCenter = new PhysicalOffsetFrame(\n        "radiusCenter", *radius, Transform(Vec3(0)));\n    radius->addComponent(radiusCenter);\n    radiusCenter->attachGeometry(bodyGeometry.clone());\n\n    // Configure the model.\n    State& state = model.initSystem();\n    // Fix the shoulder at its default angle and begin with the elbow flexed.\n    shoulder->getCoordinate().setLocked(state, true);\n    elbow->getCoordinate().setValue(state, 0.5 * Pi);\n    model.equilibrateMuscles(state);\n\n    // Configure the visualizer.\n    model.updMatterSubsystem().setShowDefaultGeometry(true);\n    Visualizer& viz = model.updVisualizer().updSimbodyVisualizer();\n    viz.setBackgroundType(viz.SolidColor);\n    viz.setBackgroundColor(White);\n\n    // Simulate.\n    simulate(model, state, 5.0);\n\n    return 0;\n};\n```\n</details>\n\n\nThis code produces the following animation:\n\n![Simulation of an arm actuated by a muscle][simple_example_gif]\n\nand prints the following information to the console:\n```\n[reporter]\n              | /forceset/bice|               |\n          time| ps|fiber_force|    elbow_angle|\n--------------| --------------| --------------|\n           0.0|     0.59048448|      1.5707963|\n           1.0|      24.574034|     0.91820573|\n           2.0|      21.418144|      1.4289945|\n           3.0|      17.584893|      1.5105765|\n           4.0|      17.688588|      1.5090021|\n           5.0|      17.590774|      1.5067387| \n```\n\nExpand to see Python and Matlab versions of the above example example:\n\n<details>\n<summary>Python</summary>\n \n```py\nimport opensim as osim \n\narm = osim.Model()\narm.setName("bicep_curl")\narm.setUseVisualizer(True)\n\n# ---------------------------------------------------------------------------\n# Create two links, each with a mass of 1 kg, center of mass at the body\'s\n# origin, and moments and products of inertia corresponding to an ellipsoid\n# with radii of 0.1, 0.5 and 0.1, in the x, y and z directions, respectively.\n# ---------------------------------------------------------------------------\n\nhumerus = osim.Body("humerus",\n                    1.0,\n                    osim.Vec3(0),\n                    osim.Inertia(0.052, 0.004, 0.052))\nradius = osim.Body("radius",\n                   1.0,\n                   osim.Vec3(0),\n                   osim.Inertia(0.052, 0.004, 0.052))\n\n# ---------------------------------------------------------------------------\n# Connect the bodies with pin joints. Assume each body is 1m long.\n# ---------------------------------------------------------------------------\n\nshoulder = osim.PinJoint("shoulder",\n                         arm.getGround(), # PhysicalFrame\n                         osim.Vec3(0),\n                         osim.Vec3(0),\n                         humerus, # PhysicalFrame\n                         osim.Vec3(0, 0.5, 0),\n                         osim.Vec3(0))\n\nelbow = osim.PinJoint("elbow",\n                      humerus, # PhysicalFrame\n                      osim.Vec3(0, -0.5, 0),\n                      osim.Vec3(0),\n                      radius, # PhysicalFrame\n                      osim.Vec3(0, 0.5, 0),\n                      osim.Vec3(0))\n\n# ---------------------------------------------------------------------------\n# Add a muscle that flexes the elbow (actuator for robotics people).\n# ---------------------------------------------------------------------------\n\nbiceps = osim.Millard2012EquilibriumMuscle("biceps",  # Muscle name\n                                           100.0,  # Max isometric force\n                                           0.6,  # Optimal fibre length\n                                           0.55,  # Tendon slack length\n                                           0.0)  # Pennation angle\nbiceps.addNewPathPoint("origin",\n                       humerus,\n                       osim.Vec3(0, 0.3, 0))\n\nbiceps.addNewPathPoint("insertion",\n                       radius,\n                       osim.Vec3(0, 0.2, 0))\n\n# ---------------------------------------------------------------------------\n# Add a controller that specifies the excitation of the muscle.\n# ---------------------------------------------------------------------------\n\nbrain = osim.PrescribedController()\nbrain.addActuator(biceps)\nbrain.prescribeControlForActuator("biceps",\n                                  osim.StepFunction(0.5, 3.0, 0.3, 1.0))\n\n# ---------------------------------------------------------------------------\n# Build model with components created above.\n# ---------------------------------------------------------------------------\n\narm.addBody(humerus)\narm.addBody(radius)\narm.addJoint(shoulder) # Now required in OpenSim4.0\narm.addJoint(elbow)\narm.addForce(biceps)\narm.addController(brain)\n\n# ---------------------------------------------------------------------------\n# Add a console reporter to print the muscle fibre force and elbow angle.\n# ---------------------------------------------------------------------------\n\n# We want to write our simulation results to the console.\nreporter = osim.ConsoleReporter()\nreporter.set_report_time_interval(1.0)\nreporter.addToReport(biceps.getOutput("fiber_force"))\nelbow_coord = elbow.getCoordinate().getOutput("value")\nreporter.addToReport(elbow_coord, "elbow_angle")\narm.addComponent(reporter)\n\n# ---------------------------------------------------------------------------\n# Add display geometry. \n# ---------------------------------------------------------------------------\n\nbodyGeometry = osim.Ellipsoid(0.1, 0.5, 0.1)\nbodyGeometry.setColor(osim.Vec3(0.5)) # Gray\nhumerusCenter = osim.PhysicalOffsetFrame()\nhumerusCenter.setName("humerusCenter")\nhumerusCenter.setParentFrame(humerus)\nhumerusCenter.setOffsetTransform(osim.Transform(osim.Vec3(0)))\nhumerus.addComponent(humerusCenter)\nhumerusCenter.attachGeometry(bodyGeometry.clone())\n\nradiusCenter = osim.PhysicalOffsetFrame()\nradiusCenter.setName("radiusCenter")\nradiusCenter.setParentFrame(radius)\nradiusCenter.setOffsetTransform(osim.Transform(osim.Vec3(0)))\nradius.addComponent(radiusCenter)\nradiusCenter.attachGeometry(bodyGeometry.clone())\n\n   with OpenSim (see below). You should run this command for the release\n   configuration *last* to ensure that you use the release version of the\n   command-line applications instead of the slow debug versions.\n   \n   * Note: Superbuild attempts to determine when dependencies are out of date\n     but is not always successful. It is therefore recommended to build all\n     dependencies from scratch when updating your installation.\nelbow.getCoordinate().setValue(state, 0.5 * osim.SimTK_PI)\narm.equilibrateMuscles(state)\n\n# ---------------------------------------------------------------------------\n# Configure the visualizer.\n# ---------------------------------------------------------------------------\n\nviz = arm.updVisualizer().updSimbodyVisualizer()\nviz.setBackgroundColor(osim.Vec3(0)) # white\nviz.setGroundHeight(-2)\n\n# ---------------------------------------------------------------------------\n# Simulate.\n# ---------------------------------------------------------------------------\n\nmanager = osim.Manager(arm)\nstate.setTime(0)\nmanager.initialize(state)\nstate = manager.integrate(5.0)\n```\n\n</details>\n<details>\n<summary>Matlab</summary>\n\n``` Matlab\n%% Import Java libraries\nimport org.opensim.modeling.*\n\narm = Model();\narm.setName(\'bicep_curl\');\narm.setUseVisualizer(true);\n\n% ---------------------------------------------------------------------------\n% Create two links, each with a mass of 1 kg, center of mass at the body\'s\n% origin, and moments and products of inertia corresponding to an ellipsoid\n% with radii of 0.1, 0.5 and 0.1, in the x, y and z directions, respectively.\n% ---------------------------------------------------------------------------\n\nhumerus = Body(\'humerus\',...\n                    1.0,...\n                    Vec3(0),...\n                    Inertia(0.052, 0.004, 0.052));\nradius = Body(\'radius\',...\n                   1.0,...\n                   Vec3(0),...\n                   Inertia(0.052, 0.004, 0.052));\n\n% ---------------------------------------------------------------------------\n% Connect the bodies with pin joints. Assume each body is 1m long.\n% ---------------------------------------------------------------------------\n\nshoulder = PinJoint(\'shoulder\',...\n                         arm.getGround(),... % PhysicalFrame\n                         Vec3(0),...\n                         Vec3(0),...\n                         humerus,... % PhysicalFrame\n                         Vec3(0, 0.5, 0),...\n                         Vec3(0));\n\nelbow = PinJoint(\'elbow\',...\n                      humerus,... % PhysicalFrame\n                      Vec3(0, -0.5, 0),...\n                      Vec3(0),...\n                      radius,... % PhysicalFrame\n                      Vec3(0, 0.5, 0),...\n                      Vec3(0));\n\n% ---------------------------------------------------------------------------\n% Add a muscle that flexes the elbow (actuator for robotics people).\n% ---------------------------------------------------------------------------\n\nbiceps = Millard2012EquilibriumMuscle(\'biceps\',...  % Muscle name\n                                           100.0,...  % Max isometric force\n                                           0.6,...  % Optimal fibre length\n                                           0.55,...  % Tendon slack length\n                                           0.0);  % Pennation angle\nbiceps.addNewPathPoint(\'origin\',...\n                       humerus,...\n                       Vec3(0, 0.3, 0));\n\nbiceps.addNewPathPoint(\'insertion\',...\n                       radius,...\n                       Vec3(0, 0.2, 0));\n\n% ---------------------------------------------------------------------------\n% Add a controller that specifies the excitation of the muscle.\n% ---------------------------------------------------------------------------\n\nbrain = PrescribedController();\nbrain.addActuator(biceps);\nbrain.prescribeControlForActuator(\'biceps\',...\n                                  StepFunction(0.5, 3.0, 0.3, 1.0));\n\n% ---------------------------------------------------------------------------\n% Build model with components created above.\n% ---------------------------------------------------------------------------\n\narm.addBody(humerus);\narm.addBody(radius);\narm.addJoint(shoulder); % Now required in OpenSim4.0\narm.addJoint(elbow);\narm.addForce(biceps);\narm.addController(brain);\n\n% ---------------------------------------------------------------------------\n% Add a console reporter to print the muscle fibre force and elbow angle.\n% ---------------------------------------------------------------------------\n\n% We want to write our simulation results to the console.\nreporter = ConsoleReporter();\nreporter.set_report_time_interval(1.0);\nreporter.addToReport(biceps.getOutput(\'fiber_force\'));\nelbow_coord = elbow.getCoordinate().getOutput(\'value\');\nreporter.addToReport(elbow_coord, \'elbow_angle\');\narm.addComponent(reporter);\n\n% ---------------------------------------------------------------------------\n% Add display geometry. \n% ---------------------------------------------------------------------------\n\nbodyGeometry = Ellipsoid(0.1, 0.5, 0.1);\nbodyGeometry.setColor(Vec3(0.5)); % Gray\nhumerusCenter = PhysicalOffsetFrame();\nhumerusCenter.setName(\'humerusCenter\');\nhumerusCenter.setParentFrame(humerus);\nhumerusCenter.setOffsetTransform(Transform(Vec3(0)));\nhumerus.addComponent(humerusCenter);\nhumerusCenter.attachGeometry(bodyGeometry.clone());\n\nradiusCenter = PhysicalOffsetFrame();\nradiusCenter.setName(\'radiusCenter\');\nradiusCenter.setParentFrame(radius);\nradiusCenter.setOffsetTransform(Transform(Vec3(0)));\nradius.addComponent(radiusCenter);\nradiusCenter.attachGeometry(bodyGeometry.clone());\n\n% ---------------------------------------------------------------------------\n% Configure the model.\n% ---------------------------------------------------------------------------\n\nstate = arm.initSystem();\n% Fix the shoulder at its default angle and begin with the elbow flexed.\nshoulder.getCoordinate().setLocked(state, true);\nelbow.getCoordinate().setValue(state, 0.5 * pi);\narm.equilibrateMuscles(state);\n\n% ---------------------------------------------------------------------------\n% Configure the visualizer\n% ---------------------------------------------------------------------------\n\nviz = arm.updVisualizer().updSimbodyVisualizer();\nviz.setBackgroundColor(Vec3(0)); % white\nviz.setGroundHeight(-2)\n\n% ---------------------------------------------------------------------------\n% Simulate.\n% ---------------------------------------------------------------------------\n\nmanager = Manager(arm);\nstate.setTime(0);\nmanager.initialize(state);\nstate = manager.integrate(5.0);\n```\n\n</details>\n\nBuilding from the source code\n-----------------------------\n\n**NOTE**: On all platforms (Windows, OSX, Linux), you should\nbuild all OpenSim dependencies (Simbody, etc) with the\nsame *CMAKE_BUILD_TYPE* (Linux) / *CONFIGURATION*\n(MSVC/Xcode) (e.g., Release, Debug) as OpenSim. Failing to\ndo so *may* result in mysterious runtime errors like\nsegfaults.\n\nWe support a few ways of building OpenSim:\n\n1. [On Windows using Microsoft Visual Studio](#on-windows-using-visual-studio). In a rush? Use [these instructions](#for-the-impatient-windows).\n2. [On Mac OSX using Xcode](#on-mac-osx-using-xcode). Need extended instructions? Use [these instructions](#extended-instructions-for-osx).\n3. [On Ubuntu using Unix Makefiles](#on-ubuntu-using-unix-makefiles). In a rush? Use [these instructions](#for-the-impatient-ubuntu).\n\n\nOn Windows using Visual Studio\n------------------------------\n\n#### Get the dependencies\n\n* **operating system**: Windows 7, 8, or 10.\n* **cross-platform build system**:\n  [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.2\n* **compiler / IDE**: Visual Studio [2019](https://visualstudio.microsoft.com/vs/) \n    * The *Community* variant is sufficient and is free for everyone.\n    * Visual Studio 2019 may not install C++ support by default.\n      * During the installation, select the workload\n        *Desktop Development with C++*.\n      * If Visual Studio is installed without C++ support, CMake will report\n        the following errors:\n        ```\n        The C compiler identification is unknown\n        The CXX compiler identification is unknown\n        ```    \n* **physics engine**: \n    * Let OpenSim get this for you using superbuild (see below), or\n    * [Build on your own from latest master branch](\n      https://github.com/simbody).\n* **C3D file support**: Biomechanical-ToolKit Core or EZC3D, we use the latter by default. \n    * Let OpenSim get this for you using superbuild (see below).\n* **command-line argument parsing**: docopt.cpp. Two options:\n    * Let OpenSim get this for you using superbuild (see below); much easier!\n    * [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).\n* **logging**: spdlog. Two options:\n    * Let OpenSim get this for you using superbuild (see below); much easier!\n    * [Build on your own](https://github.com/gabime/spdlog).\n* **Moco optimal control solvers**: Solving optimal control problems with \n    OpenSim\'s Moco module requires either CasADi or Tropter. Use superbuild for\n    all these dependencies (except for Tropter, which is part of this\n    repository).\n    * **MocoCasADiSolver** (optional): [CasADi](https://web.casadi.org) (LGPL).\n    * **MocoTropterSolver** (optional): Tropter.\n        * **matrix library**: [Eigen](http://eigen.tuxfamily.org) >= 3.3.7\n        * **sparse matrix algorithms**: [ColPack](https://github.com/CSCsw/ColPack).\n        * **automatic differentiation**: [ADOL-C](https://github.com/coin-or/ADOL-C) >= 2.6.3.\n    * **nonlinear optimizer** (required if building with CasADi or Tropter): \n        [IPOPT](https://github.com/coin-or/Ipopt) >= 3.12.8.\n* **API documentation** (optional):\n  [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6\n* **version control** (optional): git. There are many options:\n    * [Git for Windows](http://msysgit.github.io/), most advanced;\n    * [TortoiseGit](https://code.google.com/p/tortoisegit/wiki/Download),\n      intermediate; good for TortoiseSVN users;\n    * [GitHub for Windows](https://windows.github.com/), easiest.\n* **Bindings** (optional): [SWIG](http://www.swig.org/) 4.0.2\n    * **MATLAB scripting** (optional): [Java development kit][java] >= 1.8.\n        * Note: Older versions of MATLAB may use an older version of JVM. Run\n                \'ver\' in MATLAB to check MATLAB\'s JVM version (must be >= 1.8).\n        * Note: Java development kit >= 9 requires CMake >= 3.10.\n    * **Python scripting** (optional): Python 2 >= 2.7 or Python 3 >= 3.5\n        * [Anaconda](https://www.anaconda.com/distribution/)\n        * Must provide the NumPy package; this should come with Anaconda.\n    * The choice between 32-bit/64-bit must be the same between Java, Python,\n      and OpenSim, we only build/test/support 64-bit platforms.\n\n#### Download the OpenSim-Core source code\n\n* Method 1: If you want to get going quickly, download the source code from\n  https://github.com/opensim-org/opensim-core/releases, for the version of\n  OpenSim you want. We\'ll assume you unzipped the source code into\n  `C:/opensim-core-source`.\n* Method 2: If you plan on updating your OpenSim installation or you want to\n  contribute back to the project, clone the opensim-core git repository into\n  `C:/opensim-core-source`. If using TortoiseGit, open Windows Explorer,\n  right-click in the window, select **Git Clone...**, and provide the\n  following:\n    below). You should install the release configuration *last* to ensure that\n    you use the release version of the command-line applications instead of the\n    slow debug versions.\n\n    * Note: Superbuild attempts to determine when dependencies are out of date\n      but is not always successful. It is therefore recommended to build all\n      dependencies from scratch when updating your installation.\n10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the\n   upper left. If necessary, change the build configuration (previous step) and\n   run **ALL_BUILD** again.\n\n#### Configure and generate project files\n\n3. In the field **Where to build the binaries**, specify a directory under\n   which to build dependencies. Let\'s say this is\n   `C:/opensim-core-dependencies-build`.\n4. Click the **Configure** button.\n    1. Visual Studio 2019: Choose the *Visual Studio 16 2019* generator.\n    2. Need to build as 64-bit, select the generator with *Win64* in the name.\n    3. Click **Finish**.\n5. Where do you want to install OpenSim dependencies on your computer? Set this\n   by changing the `CMAKE_INSTALL_PREFIX` variable. Let\'s say this is\n   `C:/opensim-core-dependencies-install`.\n6. Variables named `SUPERBUILD_<dependency-name>` allow you to selectively\n   download dependencies. By default, all dependencies are downloaded,\n   configured and built.\n7. Click the **Configure** button again. Then, click **Generate** to make\n   Visual Studio project files in the build directory.\n8. Go to the build directory you specified in step 3 using the command:\n\n        cd C:/opensim-core-dependencies-build\n\n9. Use CMake to download, compile and install the dependencies:\n\n        cmake --build . --config RelWithDebInfo\n\n   Alternative values for `--config` in this command are:\n\n   * **Debug**: debugger symbols; no optimizations (more than 10x slower).\n     Library names end with `_d`.\n   * **Release**: no debugger symbols; optimized.\n   * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower\n     than Release; choose this if unsure.\n   * **MinSizeRel**: minimum size; optimized.\n\n   You must run this command for each of the configurations you plan to use\n   with OpenSim (see below). You should run this command for the release\n   configuration *last* to ensure that you use the release version of the\n   command-line applications instead of the slow debug versions.\n\n   * Note: Superbuild attempts to determine when dependencies are out of date\n     but is not always successful. It is therefore recommended to build all\n     dependencies from scratch when updating your installation.\n10. If you like, you can now remove the directory used for building\n    dependencies (`c:/opensim-core-dependencies-build`).\n\n#### Configure and generate project files\n\n1. Open the CMake GUI.\n2. In the field **Where is the source code**, specify `C:/opensim-core-source`.\n3. In the field **Where to build the binaries**, specify something like\n   `C:/opensim-core-build`, or some other path that is not inside your source\n   directory. This is *not* where we are installing OpenSim-Core; see below.\n4. Click the **Configure** button.\n    1. Visual Studio 2019: Choose the *Visual Studio 16* generator.\n    2. To build as 64-bit, select the generator with *Win64* in the name.\n       The choice between 32-bit/64-bit must be the same across all dependencies.\n    3. Click **Finish**.\n5. Where do you want to install OpenSim-Core on your computer? Set this by\n   changing the `CMAKE_INSTALL_PREFIX` variable. We\'ll assume you set it to\n   `C:/opensim-core`. If you choose a different installation location, make\n   sure to use *yours* where we use `C:/opensim-core` below.\n6. Tell CMake where to find dependencies. This depends on how you got them.\n    * Superbuild: Set the variable `OPENSIM_DEPENDENCIES_DIR` to the root\n      directory you specified with superbuild for installation of dependencies.\n      In our example, it would be `c:/opensim-core-dependencies-install`.\n    * Obtained on your own:\n        1. Simbody: Set the `SIMBODY_HOME` variable to where you installed\n           Simbody (e.g., `C:/Simbody`).\n        2. docopt.cpp: Set the variable `docopt_DIR` to the directory\n           containing `docopt-config.cmake`. If the root directory of your\n           docopt.cpp installation is `C:/docopt.cpp-install`, then set this\n           variable to `C:/docopt.cpp-install/lib/cmake`.\n        3. spdlog: Set the variable `spdlog_DIR` to the directory containing\n           `spdlogConfig.cmake`. If the root directory of your spdlog \n           installation is `C:/spdlog-install`, then set this variable to\n           `C:/spdlog-install/lib/spdlog/cmake`.\n7. Set the remaining configuration options.\n    * `BUILD_API_EXAMPLES` to compile C++ API examples.\n    * `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a\n      while to build; if you want to build OpenSim quickly, you can turn this\n      off.\n    * `BUILD_JAVA_WRAPPING` if you want to access OpenSim through MATLAB or\n      Java; see dependencies above.\n    * `BUILD_PYTHON_WRAPPING` if you want to access OpenSim through Python; see\n      dependencies above. CMake sets `PYTHON_*` variables to tell you the\n      Python version used when building the wrappers.\n    * `OPENSIM_PYTHON_VERSION` to choose if the Python wrapping is built for\n      Python 2 or Python 3.\n    * `BUILD_API_ONLY` if you don\'t want to build the command-line applications.\n    * `OPENSIM_WITH_CASADI` if you want support for MocoCasADiSolver.\n    * `OPENSIM_WITH_TROPTER` if you want support for MocoTropterSolver.\n8. Click the **Configure** button again. Then, click **Generate** to make\n   Visual Studio project files in the build directory.\n\n#### Build and install\n\n1. Open `C:/opensim-core-build/OpenSim.sln` in Visual Studio.\n2. Select your desired *Solution configuration* from the drop-down at the top.\n    * **Debug**: debugger symbols; no optimizations (more than 10x slower).\n      Library names end with `_d`.\n    * **Release**: no debugger symbols; optimized.\n    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower\n      than Release; choose this if unsure.\n    * **MinSizeRel**: minimum size; optimized.\n\n    You at least want release libraries (the last 3 count as release), but you\n    can have debug libraries coexist with them. To do this, go through the\n    installation process twice, once for each of the two configurations. You\n    should install the release configuration *last* to ensure that you use the\n    release version of the command-line applications instead of the slow debug\n    versions.\n3. Build the API documentation. This is optional, and you can only do this if\n   you have Doxygen. Build the documentation by right-clicking **doxygen** and\n   selecting **Build**.\n4. Build the libraries, etc. by right-clicking  **ALL_BUILD** and selecting\n   **Build**.\n5. Run the tests by right-clicking **RUN_TESTS_PARALLEL** and selecting\n   **Build**.\n6. Install OpenSim-Core by right-clicking **INSTALL** and selecting **Build**.\n\n#### Set environment variables\n\nIn order to use the OpenSim-Core command-line applications or use OpenSim-Core\nlibraries in your own application, you must add the OpenSim-Core `bin/`\ndirectory to your `PATH` environment variable.\n\n1. In the Windows toolbar (Windows 10), Start screen (Windows 8) or Start menu\n   (Windows 7), search `environment`.\n2. Select **Edit the system environment variables**.\n3. Click **Environment Variables...**.\n4. Under **System variables**, click **Path**, then click **Edit**.\n5. Add **C:/opensim-core/bin;** to the front of of the text field. Don\'t forget\n   the semicolon!\n\n#### For the impatient (Windows)\n\n* Get **Visual Studio Community**\n  [2019](https://www.visualstudio.com/vs/)\n  * Choose *Custom installation*, then choose\n    *Programming Languages* -> *Visual C++*.\n* Get **git** from [here](https://git-scm.com/downloads).\n  * Choose *Use Git from the Windows Command Prompt*.\n* Get **CMake** from [here](https://cmake.org/download/).\n  * Choose *Add CMake to the system PATH for all users*.\n* Get **Chocolatey** from [here](https://chocolatey.org/).\n* In **PowerShell**, *run as Administrator*:\n\n  ```powershell\n  choco install python2 jdk8 swig\n  ```\n* In **PowerShell**:\n\n  ```powershell\n  git clone https://github.com/opensim-org/opensim-core.git\n  mkdir opensim_dependencies_build\n  cd .\\opensim_dependencies_build\n  cmake ..\\opensim-core\\dependencies                             `\n        -G"Visual Studio 16 2019 Win64"                          `\n        -DCMAKE_INSTALL_PREFIX="..\\opensim_dependencies_install"\n  cmake --build . --config RelWithDebInfo -- /maxcpucount:8\n  cd ..\n  mkdir opensim_build\n  cd .\\opensim_build\n  cmake ..\\opensim-core                                              `\n        -G"Visual Studio 16 2019 Win64"                              `\n        -DCMAKE_INSTALL_PREFIX="..\\opensim_install"                  `\n        -DOPENSIM_DEPENDENCIES_DIR="..\\opensim_dependencies_install" `\n        -DBUILD_JAVA_WRAPPING=ON                                     `\n        -DBUILD_PYTHON_WRAPPING=ON\n  cmake --build . --config RelWithDebInfo -- /maxcpucount:8\n    the same install directory for all build types. You should install the\n    release build type *last* to ensure that you use the release version of\n    the command-line applications instead of the slow debug versions.\n    \n    * Note: Superbuild attempts to determine when dependencies are out of date\n      but is not always successful. It is therefore recommended to build all\n      dependencies from scratch when updating your installation.\n8. Click the **Configure** button again. Then, click **Generate** to make Unix\n   Makefiles in the build directory.\n9. Open a terminal and navigate to the build directory.\n\nOn Mac OSX using Xcode\n======================\n\n   in parallel); this will greatly speed up your build. For example:\n\n        $ make -j8\n11. If necessary, repeat this whole procedure for other build types.\n\n#### Configure and generate project files\nbrew install cmake swig gcc pkgconfig autoconf libtool automake wget doxygen\nbrew cask install java\ngit clone https://github.com/opensim-org/opensim-core.git\nmkdir opensim_dependencies_build\ncd opensim_dependencies_build\ncmake ../opensim-core/dependencies \\\n      -DCMAKE_INSTALL_PREFIX="~/opensim_dependencies_install" \\\n      -DCMAKE_BUILD_TYPE=RelWithDebInfo\nmake -j8\ncd ..\nmkdir opensim_build\ncd opensim_build\ncmake ../opensim-core \\\n      -DCMAKE_INSTALL_PREFIX="~/opensim_install" \\\n      -DCMAKE_BUILD_TYPE=RelWithDebInfo \\\n      -DBUILD_PYTHON_WRAPPING=ON \\\n      -DBUILD_JAVA_WRAPPING=ON \\\n      -DOPENSIM_DEPENDENCIES_DIR="~/opensim_dependencies_install"\nmake -j8\nctest -j8\n```\n\n\n### Extended Instructions for OSX\n\n#### Get the dependencies\n\n* **operating system**: Mac OSX 10.11 El Capitan or newer.\n* **cross-platform build system**:\n  [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.2\n* **compiler / IDE**: [Xcode](https://developer.apple.com/xcode/) >= 7.3 (the latest version), through\n  the Mac App Store.\n* **physics engine**: Simbody latest. Two options:\n  * Let OpenSim get this for you using superbuild (see below).\n  * [Build on your own](https://github.com/simbody/simbody#installing).\n* **C3D file support**: EZC3D or Biomechanical-ToolKit Core. \n  * Let OpenSim get this for you using superbuild (see below).\n* **command-line argument parsing**: docopt.cpp. Two options:\n    * Let OpenSim get this for you using superbuild (see below); much easier!\n    * [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).\n* **logging**: spdlog. Two options:\n    * Let OpenSim get this for you using superbuild (see below); much easier!\n    * [Build on your own](https://github.com/gabime/spdlog).\n* **Moco optimal control solvers**: Solving optimal control problems with \n    OpenSim\'s Moco module requires either CasADi or Tropter. Use superbuild for\n    all these dependencies (except for Tropter, which is part of this\n    repository).\n    * **MocoCasADiSolver** (optional): [CasADi](https://web.casadi.org) (LGPL).\n    * **MocoTropterSolver** (optional): Tropter.\n        * **matrix library**: [Eigen](http://eigen.tuxfamily.org) >= 3.3.7\n        * **sparse matrix algorithms**: [ColPack](https://github.com/CSCsw/ColPack).\n        * **automatic differentiation**: [ADOL-C](https://github.com/coin-or/ADOL-C) >= 2.6.3.\n    * **nonlinear optimizer** (required if building with CasADi or Tropter): \n        [IPOPT](https://github.com/coin-or/Ipopt) >= 3.12.8.\n* **API documentation** (optional):\n  [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6\n* **version control** (optional): git.\n    * Xcode Command Line Tools gives you git on the command line.\n    * [GitHub for Mac](https://mac.github.com), for a simple-to-use GUI.\n* **Bindings** (optional): [SWIG](http://www.swig.org/) 4.0.2\n    * **MATLAB scripting** (optional): [Java development kit][java] >= 1.7.\n        * Note: Older versions of MATLAB may use an older version of JVM. Run\n                \'ver\' in MATLAB to check MATLAB\'s JVM version (must be >= 1.7).\n        * Note: Java development kit >= 9 requires CMake >= 3.10.\n    * **Python scripting** (optional): Python 2 >= 2.7 or Python 3 >= 3.5\n        * Mac OSX comes with Python, but you could also use:\n        * [`brew install python`](http://brew.sh),\n        * [Anaconda](https://www.anaconda.com/distribution/)\n        * Must provide the NumPy package; this should come with Anaconda.\n\nYou can get most of these dependencies using [Homebrew](http://brew.sh):\n\n    $ brew install cmake doxygen swig\n\n#### Download the OpenSim-Core source code\n\n* Method 1; If you want to get going quickly, download the source code from\n  https://github.com/opensim-org/opensim-core/releases, for the version of\n  OpenSim you want. We\'ll assume you unzipped the source code into\n  `~/opensim-core-source`.\n* Method 2: If you plan on updating your OpenSim installation or you want to\n  contribute back to the project, clone the opensim-core git repository into\n  `~/opensim-core-source`. Run the following in a terminal, or\n  find a way to run the equivalent commands in a GUI client:\n\n        $ git clone https://github.com/opensim-org/opensim-core.git ~/opensim-core-source\n\n  This will give you a bleeding-edge version of OpenSim-Core.\n\n#### [Optional] Superbuild: download and build OpenSim dependencies\n1. Open the CMake GUI.\n2. In the field **Where is the source code**, specify\n   `~/opensim-core-source/dependencies`.\n3. In the field **Where to build the binaries**, specify a directory under\n   which to build dependencies. Let\'s say this is\n   `~/opensim-core-dependencies-build`.\n4. Click the **Configure** button. Choose **Xcode**. Click **Finish**.\n5. Where do you want to install OpenSim dependencies on your computer? Set this\n   by changing the `CMAKE_INSTALL_PREFIX` variable. Let\'s say this is\n   `~/opensim-core-dependencies-install`.\n6. Variables named `SUPERBUILD_<dependency-name>` allow you to selectively\n   download dependencies. By default, all dependencies are downloaded,\n   configured and built.\n7. Click the **Configure** button again. Then, click **Generate** to make Xcode\n   files in the build directory.\n8. Open `~/opensim-core-dependencies/build/OpenSimDependencies.xcodeproj` in\n   Xcode.\n9. Choose your **Build Configuration** for the **ALL_BUILD** Scheme by pressing\n   `Command-Shift ,` (or, `Command-LessThan`), or navigating to **Product ->\n   Scheme -> Edit Scheme...**; and changing the **Build Configuration** field.\n    * **Debug**: debugger symbols; no optimizations (more than 10x slower).\n    Library names end with `_d`.\n    * **Release**: no debugger symbols; optimized.\n    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower\n    than Release; choose this if unsure.\n    * **MinSizeRel**: minimum size; optimized.\n\n    You must build each of the configurations you plan to use with OpenSim (see\n    below). You should install the release configuration *last* to ensure that\n    you use the release version of the command-line applications instead of the\n    slow debug versions.\n10. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the\n   upper left. If necessary, change the build configuration (previous step) and\n   run **ALL_BUILD** again.\n\n    * Note: Superbuild attempts to determine when dependencies are out of date\n      but is not always successful. It is therefore recommended to build all\n      dependencies from scratch when updating your installation.\n\n#### Configure and generate project files\n\n1. Open the CMake GUI.\n2. In the field **Where is the source code**, specify `~/opensim-core-source`.\n3. In the field **Where to build the binaries**, specify something like\n   `~/opensim-core-build`, or some other path that is not inside your source\n   directory. This is *not* where we are installing OpenSim-Core; see below.\n4. Click the **Configure** button. Choose **Xcode**. Click **Finish**.\n5. Where do you want to install OpenSim-Core on your computer? Set this by\n   changing the `CMAKE_INSTALL_PREFIX` variable. We\'ll assume you set it to\n   `~/opensim-core`. If you choose a different installation location, make\n   sure to use *yours* where we use `~/opensim-core` below. You should *not*\n   use `/usr/`, `/usr/local/`, etc. (because our installation does not yet\n   conform to the [FHS](http://www.pathname.com/fhs/)).\n6. Tell CMake where to find dependencies. This depends on how you got them.\n    * Superbuild: Set the variable `OPENSIM_DEPENDENCIES_DIR` to the root\n      directory you specified with superbuild for installation of dependencies.\n      In our example, it would be `~/opensim-core-dependencies-install`.\n    * Obtained on your own:\n        1. Simbody: Set the `SIMBODY_HOME` variable to where you installed\n           Simbody (e.g., `~/simbody`). If you installed Simbody using `brew`,\n           then CMake will find Simbody automatically.\n        2. docopt.cpp: Set the variable `docopt_DIR` to the directory\n           containing `docopt-config.cmake`. If the root directory of your\n           docopt.cpp installation is `~/docopt.cpp-install`, then set this\n           variable to `~/docopt.cpp-install/lib/cmake`.\n        3. spdlog: Set the variable `spdlog_DIR` to the directory containing\n           `spdlogConfig.cmake`. If the root directory of your spdlog \n           installation is `~/spdlog-install`, then set this variable to\n           `~/spdlog-install/lib/spdlog/cmake`.\n7. Set the remaining configuration options.\n    * `BUILD_API_EXAMPLES` to compile C++ API examples.\n    * `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a\n      while to build; if you want to build OpenSim quickly, you can turn this\n      off.\n    * `BUILD_JAVA_WRAPPING` if you want to access OpenSim through MATLAB or\n      Java; see dependencies above.\n    * `BUILD_PYTHON_WRAPPING` if you want to access OpenSim through Python; see\n      dependencies above. CMake sets `PYTHON_*` variables to tell you the\n      Python version used when building the wrappers.\n    * `OPENSIM_PYTHON_VERSION` to choose if the Python wrapping is built for\n      Python 2 or Python 3.\n    * `BUILD_API_ONLY` if you don\'t want to build the command-line applications.\n8. Click the **Configure** button again. Then, click **Generate** to create\n   Xcode project files in the build directory.\n\n#### Build and install\n\n1. Open `~/opensim-core-build/OpenSim.xcodeproj` in Xcode.\n2. Choose your **Build Configuration** for the **ALL_BUILD** Scheme by pressing\n   `Command-Shift ,` (or, `Command-LessThan`), or navigating to **Product ->\n   Scheme -> Edit Scheme...**; and changing the **Build Configuration** field.\n    * **Debug**: debugger symbols; no optimizations (more than 10x slower).\n    Library names end with `_d`.\n    * **Release**: no debugger symbols; optimized.\n    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower\n    than Release; choose this if unsure.\n    * **MinSizeRel**: minimum size; optimized.\n\n    You at least want release libraries (the last 3 count as release), but you\n    can have debug libraries coexist with them. To do this, go through the\n    installation process twice, once for each of the two configurations. You\n    should install the release configuration *last* to ensure that you use the\n    release version of the command-line applications instead of the slow debug\n    versions.\n\n3. Compile. Run the Scheme **ALL_BUILD** by clicking the play button in the\n   upper left.\n4. Test. Click on **ALL_BUILD** in the upper left, and select\n   **RUN_TESTS_PARALLEL**. Change the **Build Configuration** of this Scheme to\n   the same as you used for **ALL_BUILD** (using the same instructions as\n   above). Click the play button.\n5. Build the API documentation. This is optional, and you can only do this if\n   you have Doxygen. Click on the current Scheme (**RUN_TESTS_PARALLEL**) and\n   select **doxygen**. Click the play button.\n6. Install. Click on the current Scheme (**RUN_TESTS_PARALLEL** or\n   **doxygen**), and select **install**. Click the play button.\n\n#### Set environment variables\n\n1. **Executables**. If you want to run OpenSim-Core\'s executables from\n   anywhere on your computer, you must update your PATH. Open a terminal and\n   type:\n\n        $ echo \'export PATH=~/opensim-core/bin:$PATH\' >> ~/.bash_profile\n\nYour changes will only take effect in new terminal windows.\n\n\nOn Ubuntu using Unix Makefiles\n==============================\n\n#### Get the dependencies\n\nMost dependencies can be obtained via the Ubuntu software repositories;\nespecially if you are using Ubuntu 16.04 or later. On each line below, we show\nthe Ubuntu package names for the dependencies. You can find instructions for\nspecific Ubuntu versions under \'For the impatient\' below.\n\n* **cross-platform build system**:\n  [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.2;\n  `cmake-gui`.\n* **compiler**: [gcc](http://gcc.gnu.org) >= 4.9; `g++-4.9`, or\n  [Clang](http://clang.llvm.org) >= 3.4; `clang-3.4`.\n* **physics engine**: Simbody >= 3.7. Two options:\n  * Let OpenSim get this for you using superbuild (see below).\n  * [Build on your own](https://github.com/simbody/simbody#installing).\n* **C3D file support**: Biomechanical-ToolKit Core. Two options:\n  * Let OpenSim get this for you using superbuild (see below).\n* **command-line argument parsing**: docopt.cpp. Two options:\n    * Let OpenSim get this for you using superbuild (see below); much easier!\n    * [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).\n* **logging**: spdlog. Two options:\n    * Let OpenSim get this for you using superbuild (see below); much easier!\n    * [Build on your own](https://github.com/gabime/spdlog).\n* **Moco optimal control solvers**: Solving optimal control problems with \n    OpenSim\'s Moco module requires either CasADi or Tropter. Use superbuild for\n    all these dependencies (except for Tropter, which is part of this\n    repository).\n    * **MocoCasADiSolver** (optional): [CasADi](https://web.casadi.org) (LGPL).\n    * **MocoTropterSolver** (optional): Tropter.\n        * **matrix library**: [Eigen](http://eigen.tuxfamily.org) >= 3.3.7\n        * **sparse matrix algorithms**: [ColPack](https://github.com/CSCsw/ColPack).\n        * **automatic differentiation**: [ADOL-C](https://github.com/coin-or/ADOL-C) >= 2.6.3.\n    * **nonlinear optimizer** (required if building with CasADi or Tropter): \n        [IPOPT](https://github.com/coin-or/Ipopt) >= 3.12.8.\n* **API documentation** (optional):\n  [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6;\n  `doxygen`.\n* **version control** (optional): git; `git`.\n* **Bindings** (optional): [SWIG](http://www.swig.org/) 4.0.2; `swig`.\n    * **MATLAB scripting** (optional): [Java development kit][java] >= 1.7;\n      `openjdk-7-jdk`.\n        * Note: Older versions of MATLAB may use an older version of JVM. Run\n                \'ver\' in MATLAB to check MATLAB\'s JVM version (must be >= 1.7).\n        * Note: Java development kit >= 9 requires CMake >= 3.10.\n    * **Python scripting** (optional): Python 2 >= 2.7 or Python 3 >= 3.5; `python-dev`.\n        * Must provide the NumPy package; `python-numpy`.\n\nFor example, you could get the required dependencies (except Simbody) via:\n\n    $ sudo apt-get install cmake-gui g++-4.9\n\nAnd you could get all the optional dependencies via:\n\n    $ sudo apt-get install doxygen git swig openjdk-7-jdk python-dev python-numpy wget build-essential libtool autoconf pkg-config gfortran\n\n#### Download the OpenSim-Core source code\n\n* Method 1; If you want to get going quickly, download the source code from\n  https://github.com/opensim-org/opensim-core/releases, for the version of\n  OpenSim you want. We\'ll assume you unzipped the source code into\n  `~/opensim-core-source`.\n* Method 2: If you plan on updating your OpenSim installation or you want to\n  contribute back to the project, clone the opensim-core git repository into\n  `C:/opensim-core-source`. Run the following in a terminal:\n\n        $ git clone https://github.com/opensim-org/opensim-core.git ~/opensim-core-source\n\n  This will give you a bleeding-edge version of OpenSim-Core.\n\n#### [Optional] Superbuild: download and build OpenSim dependencies\n1. Open the CMake GUI.\n2. In the field **Where is the source code**, specify\n   `~/opensim-core-source/dependencies`.\n3. In the field **Where to build the binaries**, specify a directory under\n   which to build dependencies. Let\'s say this is\n   `~/opensim-core-dependencies-build`.\n4. Click the **Configure** button. Choose *Unix Makefiles*. Click **Finish**.\n5. Where do you want to install OpenSim dependencies on your computer? Set this\n   by changing the `CMAKE_INSTALL_PREFIX` variable. Let\'s say this is\n   `~/opensim-core-dependencies-install`.\n6. Variables named `SUPERBUILD_<dependency-name>` allow you to selectively\n   download dependencies. By default, all dependencies are downloaded,\n   configured and built.\n7. Choose your build type by setting `CMAKE_BUILD_TYPE` to one of the following:\n    * **Debug**: debugger symbols; no optimizations (more than 10x slower).\n    Library names end with `_d`.\n    * **Release**: no debugger symbols; optimized.\n    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower\n    than Release; choose this if unsure.\n    * **MinSizeRel**: minimum size; optimized.\n\n    You must perform the superbuild procedure for each of the\n    build types you plan to use with OpenSim (see below). You might want to\n    use different build directories for each build type, though you can use\n    the same install directory for all build types. You should install the\n    release build type *last* to ensure that you use the release version of\n    the command-line applications instead of the slow debug versions.\n8. Click the **Configure** button again. Then, click **Generate** to make Unix\n   Makefiles in the build directory.\n9. Open a terminal and navigate to the build directory.\n\n        $ cd ~/opensim-core-dependencies-build\n\n3. Compile. Use the `-jn` flag to build using `n` concurrent jobs (potentially\n   in parallel); this will greatly speed up your build. For example:\n\n        $ make -j8\n\n    * Note: Superbuild attempts to determine when dependencies are out of date\n      but is not always successful. It is therefore recommended to build all\n      dependencies from scratch when updating your installation.\n11. If necessary, repeat this whole procedure for other build types.\n\n#### Configure and generate project files\n\n1. Open the CMake GUI.\n2. In the field **Where is the source code**, specify `~/opensim-core-source`.\n3. In the field **Where to build the binaries**, specify something like\n   `~/opensim-core-build`, or some other path that is not inside your source\n   directory. This is *not* where we are installing OpenSim-Core; see below.\n4. Click the **Configure** button. Choose *Unix Makefiles*. Click **Finish**.\n5. Where do you want to install OpenSim-Core on your computer? Set this by\n   changing the `CMAKE_INSTALL_PREFIX` variable. We\'ll assume you set it to\n   `~/opensim-core`. If you choose a different installation location, make\n   sure to use *yours* where we use `~/opensim-core` below. You should *not*\n   use `/usr/`, `/usr/local/`, etc. (because our installation does not yet\n   conform to the [FHS](http://www.pathname.com/fhs/)), but\n   [`/opt/`](http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/opt.html)\n   is okay.\n6. Tell CMake where to find dependencies. This depends on how you got them.\n    * Superbuild: Set the variable `OPENSIM_DEPENDENCIES_DIR` to the root\n      directory you specified with superbuild for installation of dependencies.\n      In our example, it would be `~/opensim-core-dependencies-install`.\n    * Obatained on your own:\n        1. Simbody: Set the `SIMBODY_HOME` variable to where you installed\n           Simbody (e.g., `~/simbody`).\n        2. docopt.cpp: Set the variable `docopt_DIR` to the directory\n           containing `docopt-config.cmake`. If the root directory of your\n           docopt.cpp installation is `~/docopt.cpp-install`, then set this\n           variable to `~/docopt.cpp-install/lib/cmake`.\n        3. spdlog: Set the variable `spdlog_DIR` to the directory containing\n           `spdlogConfig.cmake`. If the root directory of your spdlog \n           installation is `~/spdlog-install`, then set this variable to\n           `~/spdlog-install/lib/spdlog/cmake`.\n7. Choose your build type by setting `CMAKE_BUILD_TYPE` to one of the following:\n    * **Debug**: debugger symbols; no optimizations (more than 10x slower).\n    Library names end with `_d`.\n    * **Release**: no debugger symbols; optimized.\n    * **RelWithDebInfo**: debugger symbols; optimized. Bigger but not slower\n    than Release; choose this if unsure.\n    * **MinSizeRel**: minimum size; optimized.\n\n    You at least want release libraries (the last 3 count as release), but you\n    can have debug libraries coexist with them. To do this, go through the\n    installation process twice, once for each of the two build types. It is\n    typical to use a different build directory for each build type (e.g.,\n    `~/opensim-core-build-debug` and `~/opensim-core-build-release`). You\n    should install the release build type *last* to ensure that you use the\n    release version of the command-line applications instead of the slow debug\n    versions.\n8. Set the remaining configuration options.\n    * `BUILD_API_EXAMPLES` to compile C++ API examples.\n    * `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a\n      while to build; if you want to build OpenSim quickly, you can turn this\n      off.\n    * `BUILD_JAVA_WRAPPING` if you want to access OpenSim through MATLAB or\n      Java; see dependencies above.\n    * `BUILD_PYTHON_WRAPPING` if you want to access OpenSim through Python; see\n      dependencies above.\n    * `OPENSIM_PYTHON_VERSION` to choose if the Python wrapping is built for\n      Python 2 or Python 3.\n    * `BUILD_API_ONLY` if you don\'t want to build the command-line applications.\n    * `OPENSIM_COPY_DEPENDENCIES` to decide if Simbody is copied into\n      the OpenSim installation; you want this off if you\'re installing OpenSim\n      into `/usr/` or `/usr/local/`.\n9. Click the **Configure** button again. Then, click **Generate** to create\n   Makefiles in the build directory.\n\n#### Build and install\n\n1. Open a terminal and navigate to the build directory.\n\n        $ cd ~/opensim-core-build\n\n2. Build the API documentation. This is optional, and you can only do this if\n   you have Doxygen.\n\n        $ make doxygen\n\n3. Compile. Use the `-jn` flag to build using `n` concurrent jobs (potentially\n   in parallel); this will greatly speed up your build. For example:\n\n        $ make -j8\n\n4. Run the tests.\n\n        $ ctest -j8\n\n5. Install (to `~/opensim-core`).\n\n        $ make -j8 install\n\n#### Set environment variables\n\n1. **Executables**. Add OpenSim-Core\'s executables to the path so you can\n   access them from any directory on your computer.\n\n        $ echo \'export PATH=~/opensim-core/bin:$PATH\' >> ~/.bashrc\n\nYour changes will only take effect in new terminal windows.\n\n#### For the impatient (Ubuntu)\n##### Ubuntu 18.0\nIn **Terminal** --\n\n```shell\nsudo add-apt-repository --yes ppa:george-edison55/cmake-3.x\nsudo apt-add-repository --yes ppa:fenics-packages/fenics-exp\nsudo apt-get update\nsudo apt-get --yes install git cmake cmake-curses-gui clang-3.6 \\\n                           freeglut3-dev libxi-dev libxmu-dev \\\n                           liblapack-dev swig3.0 python-dev \\\n                           openjdk-7-jdk\nsudo rm -f /usr/bin/cc /usr/bin/c++\nsudo ln -s /usr/bin/clang-3.6 /usr/bin/cc\nsudo ln -s /usr/bin/clang++-3.6 /usr/bin/c++\nexport JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64\ngit clone https://github.com/opensim-org/opensim-core.git\nmkdir opensim_dependencies_build\ncd opensim_dependencies_build\ncmake ../opensim-core/dependencies/ \\\n      -DCMAKE_INSTALL_PREFIX=\'~/opensim_dependencies_install\' \\\n      -DCMAKE_BUILD_TYPE=RelWithDebInfo\nmake -j8\ncd ..\nmkdir opensim_build\ncd opensim_build\ncmake ../opensim-core \\\n      -DCMAKE_INSTALL_PREFIX="~/opensim_install" \\\n      -DCMAKE_BUILD_TYPE=RelWithDebInfo \\\n      -DOPENSIM_DEPENDENCIES_DIR="~/opensim_dependencies_install" \\\n      -DBUILD_PYTHON_WRAPPING=ON \\\n      -DBUILD_JAVA_WRAPPING=ON\nmake -j8\nctest -j8\nmake -j8 install\n ```\n\nNote: You may need to add `<FULL-DIR>/opensim_install/bin` to your PATH variable as per [these instructions](#set-environment-variables-2).  \nExample: If opensim_install is in your home directory:\n\n        $ echo \'export PATH=~/opensim_install/bin:$PATH\' >> ~/.bashrc\n\n\n[buildstatus_image_travis]: https://travis-ci.org/opensim-org/opensim-core.svg?branch=master\n[travisci]: https://travis-ci.org/opensim-org/opensim-core\n[buildstatus_image_appveyor]: https://ci.appveyor.com/api/projects/status/i4wxnmx9jlk69kge/branch/master?svg=true\n[appveyorci]: https://ci.appveyor.com/project/opensim-org/opensim-core/branch/master\n[zenhub_image]: https://dxssrr2j0sq4w.cloudfront.net/3.2.0/img/external/zenhub-badge.png\n[zenhub]: https://zenhub.com\n\n[running_gif]: doc/images/opensim_running.gif\n[simple_example_gif]: doc/images/opensim_double_pendulum_muscle.gif\n[java]: http://www.oracle.com/technetwork/java/javase/downloads/index.html\n', 'message': 'Relocate notes about rebuilding. [ci skip]\n', 'author_name': 'Tom Uchida', 'lang': 'md'}