• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

Platform/Windows/H03-May-2022-23599

SimTKcommon/H03-May-2022-90,71149,687

SimTKmath/H03-May-2022-183,558115,088

Simbody/H03-May-2022-183,974120,605

cmake/H03-May-2022-539450

doc/H03-May-2022-2,8502,268

examples/H03-May-2022-81,79973,881

.gitattributesH A D08-Dec-2019483 2320

.gitignoreH A D08-Dec-2019345 2120

.travis.ymlH A D08-Dec-20196.9 KiB150133

CHANGELOG.mdH A D08-Dec-201917.8 KiB250221

CONTRIBUTING.mdH A D08-Dec-201934.5 KiB415326

README.mdH A D08-Dec-201937.7 KiB752549

SimbodyMainpage.hH A D08-Dec-201911 KiB2005

appveyor.ymlH A D08-Dec-20192.3 KiB6148

README.md

1Simbody [![Travis][buildstatus_image_travis]][travisci] [![Appveyor][buildstatus_image_appveyor]][appveyorci] [![Codecov][buildstatus_image_codecov]][codecovci]
2=======
3
4Simbody is a high-performance, open-source toolkit for science- and
5engineering-quality simulation of articulated mechanisms, including
6biomechanical structures such as human and animal skeletons,
7mechanical systems like robots, vehicles, and machines, and anything
8else that can be described as a set of rigid bodies interconnected
9by joints, influenced by forces and motions, and restricted by
10constraints. Simbody includes a multibody dynamics library for
11modeling motion in [generalized/internal coordinates in O(n) time][thy].
12This is sometimes called a Featherstone-style physics engine.
13
14Simbody provides a C++ API that is used to build domain-specific applications;
15it is not a standalone application itself. For example, it is used by
16biomechanists in [OpenSim](http://opensim.stanford.edu), by roboticists in
17[Gazebo](http://gazebosim.org), and for biomolecular research in
18[MacroMoleculeBuilder (MMB)](https://simtk.org/home/rnatoolbox). Here's an
19artful simulation of several RNA molecules containing thousands of bodies,
20performed with MMB by [Samuel Flores][flores]:
21
22[![Sam Flores' Simbody RNA simulation][rna]][simbios]
23
24Read more about Simbody at the [Simbody homepage](https://simtk.org/home/simbody).
25
26
27Simple example: a double pendulum
28---------------------------------
29Here's some code to simulate and visualize a 2-link chain:
30
31```cpp
32#include "Simbody.h"
33using namespace SimTK;
34int main() {
35    // Define the system.
36    MultibodySystem system;
37    SimbodyMatterSubsystem matter(system);
38    GeneralForceSubsystem forces(system);
39    Force::Gravity gravity(forces, matter, -YAxis, 9.8);
40
41    // Describe mass and visualization properties for a generic body.
42    Body::Rigid bodyInfo(MassProperties(1.0, Vec3(0), UnitInertia(1)));
43    bodyInfo.addDecoration(Transform(), DecorativeSphere(0.1));
44
45    // Create the moving (mobilized) bodies of the pendulum.
46    MobilizedBody::Pin pendulum1(matter.Ground(), Transform(Vec3(0)),
47            bodyInfo, Transform(Vec3(0, 1, 0)));
48    MobilizedBody::Pin pendulum2(pendulum1, Transform(Vec3(0)),
49            bodyInfo, Transform(Vec3(0, 1, 0)));
50
51    // Set up visualization.
52    Visualizer viz(system);
53    system.addEventReporter(new Visualizer::Reporter(viz, 0.01));
54
55    // Initialize the system and state.
56    State state = system.realizeTopology();
57    pendulum2.setRate(state, 5.0);
58
59    // Simulate for 20 seconds.
60    RungeKuttaMersonIntegrator integ(system);
61    TimeStepper ts(system, integ);
62    ts.initialize(state);
63    ts.stepTo(20.0);
64}
65```
66
67![Double-pendulum simulation in Simbody][doublePendulum]
68
69See [Simbody's User Guide][user] for a step-by-step explanation of this
70example.
71
72
73Features
74--------
75- Wide variety of joint, constraint, and force types; easily user-extended.
76- Forward, inverse, and mixed dynamics. Motion driven by forces or
77  prescribed motion.
78- Contact (Hertz, Hunt and Crossley models).
79- Gradient descent, interior point, and global (CMA) optimizers.
80- A variety of numerical integrators with error control.
81- Visualizer, using OpenGL
82
83
84You want to...
85--------------
86* **[install Simbody](#installing)**.
87* [use Simbody in your own program][user].
88* [view API documentation](https://simbody.github.io).
89* [learn the theory behind Simbody](https://github.com/simbody/simbody/raw/master/Simbody/doc/SimbodyTheoryManual.pdf).
90* [extend Simbody](https://github.com/simbody/simbody/raw/master/Simbody/doc/SimbodyAdvancedProgrammingGuide.pdf).
91* [**get support** at the Simbody Forum](https://simtk.org/forums/viewforum.php?f=47).
92* [report a bug or suggest a feature](https://github.com/simbody/simbody/issues/new).
93
94---
95
96
97Dependencies
98------------
99
100Simbody depends on the following:
101
102* cross-platform building: [CMake](http://www.cmake.org/cmake/resources/software.html) 2.8.10 or later (3.1.3 or later for Visual Studio).
103* compiler: [Visual Studio](http://www.visualstudio.com) 2015, 2017, or 2019 (Windows only), [gcc](http://gcc.gnu.org/) 4.9.0 or later (typically on Linux), [Clang](http://clang.llvm.org/) 3.4 or later, or Apple Clang (Xcode) 8 or later.
104* linear algebra: [LAPACK](http://www.netlib.org/lapack/) 3.6.0 or later and [BLAS](http://www.netlib.org/blas/)
105* visualization (optional): [FreeGLUT](http://freeglut.sourceforge.net/), [Xi and Xmu](http://www.x.org/wiki/)
106* API documentation (optional): [Doxygen](http://www.stack.nl/~dimitri/doxygen/) 1.8.6 or later; we recommend at least 1.8.8.
107
108
109Using Simbody
110-------------
111
112* **Creating your own Simbody-using project with CMake** To get started with
113  your own Simbody-using project, check out the
114  [cmake/SampleCMakeLists.txt](cmake/SampleCMakeLists.txt) file.
115
116
117Installing
118----------
119
120Simbody works on Windows, Mac, and Linux. For each operating system, you can use a package manager or build from source. In this file, we provide instructions for 6 different ways of installing Simbody:
121
1221. [**Windows**](#windows-using-visual-studio): build from source using Microsoft Visual Studio.
1232. [**Linux or Mac (make)**](#linux-or-mac-using-make): build from source using gcc or Clang with make.
1243. [**Mac (Homebrew)**](#mac-and-homebrew): automated build/install with Homebrew.
1254. [**Ubuntu/Debian**](#ubuntu-and-apt-get): install pre-built binaries with apt-get.
1265. [**FreeBSD**](#freebsd): install pre-built binaries with pkg.
1276. [**Windows using MinGW**](#windows-using-mingw): build from source using MinGW.
1287. [**Windows/Mac/Linux**](#windows-mac-and-linux-using-conda): install pre-built binaries with the Conda package manager.
129
130If you use Linux, check [Repology](https://repology.org/project/simbody/versions) to see if your distribution provides a package for Simbody.
131
132These are not the only ways to install Simbody, however. For example, on a Mac, you could use CMake and Xcode.
133
134#### C++11 and gcc/Clang
135
136Simbody 3.6 and later uses C++11 features (the `-std=c++11` flag). Simbody 3.3
137and earlier use only C++03 features, and Simbody 3.4 and 3.5 can use either
138C++03 or C++11; see the `SIMBODY_STANDARD_11` CMake variable in these versions.
139Note that if you want to use the C++11 flag in your own project, Simbody must
140have been compiled with the C++11 flag as well.
141
142
143Windows using Visual Studio
144---------------------------
145
146#### Get the dependencies
147
148All needed library dependencies are provided with the Simbody installation on Windows, including linear algebra and visualization dependencies.
149
1501. Download and install [Microsoft Visual Studio](http://www.visualstudio.com), version [2015](https://www.visualstudio.com/vs/older-downloads/), 2017, or 2019. The Community edition is free and sufficient.
151  * 2015: By default, Visual Studio 2015 does not provide C++ support; when installing, be sure to select *Custom*, and check *Programming Languages > Visual C++ > Common Tools for Visual C++ 2015*. If you have already installed Visual Studio without C++ support, simply re-run the installer and select *Modify*.
152  * 2017 and later: In the installer, select the *Desktop development with C++* workload.
153  * Any other C++ code you plan to use with Simbody should be compiled with the
154    same compiler as used for Simbody.
1552. Download and install [CMake](http://www.cmake.org/download), version 3.1.3 or higher.
1563. (optional) If you want to build API documentation, download and install Doxygen, version 1.8.8 or higher.
157
158#### Download the Simbody source code
159
160* Method 1: Download the source code from https://github.com/simbody/simbody/releases. Look for the highest-numbered release, click on the .zip button, and unzip it on your computer. We'll assume you unzipped the source code into `C:/Simbody-source`.
161* Method 2: Clone the git repository.
162    1. Get git. There are many options:
163
164       * [Git for Windows](http://gitforwindows.org/) (most advanced),
165       * [TortoiseGit](https://tortoisegit.org/download/) (intermediate; good for TortoiseSVN users),
166       * [GitHub Desktop](https://desktop.github.com/) (easiest).
167
168    2. Clone the github repository into `C:/Simbody-source`. Run the following in a Git Bash / Git Shell, or find a way to run the equivalent commands in a GUI client:
169
170            $ git clone https://github.com/simbody/simbody.git C:/Simbody-source
171            $ git checkout Simbody-3.7
172
173    3. In the last line above, we assumed you want to build a released version.
174       Feel free to change the version you want to build.
175       If you want to build the latest development version ("bleeding edge") of
176       Simbody off the `master` branch, you can omit the `checkout` line.
177
178       To see the set of releases and checkout a specific version, you can use
179       the following commands:
180
181            $ git tag
182            $ git checkout Simbody-X.Y.Z
183
184#### Configure and generate project files
185
1861. Open CMake.
1872. In the field **Where is the source code**, specify `C:/Simbody-source`.
1883. In the field **Where to build the binaries**, specify something like `C:/Simbody-build`, just not inside your source directory. This is *not* where we will install Simbody; see below.
1894. Click the **Configure** button.
190    1. When prompted to select a *generator*, in the dropdown for *Optional platform for generator*, choose **x64** to build 64-bit binaries or leave blank to build 32-bit binaries. In older versions of CMake, select a generator ending with **Win64** to build 64-bit binaries (e.g., **Visual Studio 14 2015 Win64** or **Visual Studio 15 2017 Win64**), or select one *without* **Win64** to build 32-bit binaries (e.g., **Visual Studio 14 2015** or **Visual Studio 15 2017**).
191    2. Click **Finish**.
1925. Where do you want to install Simbody on your computer? Set this by changing the `CMAKE_INSTALL_PREFIX` variable. We'll assume you set it to `C:/Simbody`. If you choose a different installation location, make sure to use *yours* where we use `C:/Simbody` below.
1936. Play around with the other build options:
194    * `BUILD_EXAMPLES` to see what Simbody can do. On by default.
195    * `BUILD_TESTING` to ensure your Simbody works correctly. On by default.
196    * `BUILD_VISUALIZER` to be able to watch your system move about! If building remotely, you could turn this off. On by default.
197    * `BUILD_DYNAMIC_LIBRARIES` builds the three libraries as dynamic libraries. On by default. Unless you know what you're doing, leave this one on.
198    * `BUILD_STATIC_LIBRARIES` builds the three libraries as static libraries, whose names will end with `_static`. Off by default. You must activate either `BUILD_DYNAMIC_LIBRARIES`, `BUILD_STATIC_LIBRARIES`, or both.
199    * `BUILD_TESTS_AND_EXAMPLES_STATIC` if static libraries, and tests or examples are being built, creates statically-linked tests/examples. Can take a while to build, and it is unlikely you'll use the statically-linked libraries.
200    * `BUILD_TESTS_AND_EXAMPLES_SHARED` if tests or examples are being built, creates dynamically-linked tests/examples. Unless you know what you're doing, leave this one on.
2017. Click the **Configure** button again. Then, click **Generate** to make Visual Studio project files.
202
203#### Build and install
204
2051. Open `C:/Simbody-build/Simbody.sln` in Visual Studio.
2062. Select your desired *Solution configuration* from the drop-down at the top.
207    * **Debug**: debugger symbols; no optimizations (more than 10x slower). Library and visualizer names end with `_d`.
208    * **RelWithDebInfo**: debugger symbols; optimized. This is the configuration we recommend.
209    * **Release**: no debugger symbols; optimized. Generated libraries and executables are smaller but not faster than RelWithDebInfo.
210    * **MinSizeRel**: minimum size; optimized. May be slower than RelWithDebInfo or Release.
211
212    You at least want optimized libraries (all configurations but Debug are optimized), but you
213    can have Debug libraries coexist with them. To do this, go through the full
214    installation process twice, once for each configuration.
2153. Build the project **ALL_BUILD** by right-clicking it and selecting **Build**.
2164. Run the tests by right-clicking **RUN_TESTS** and selecting **Build**. Make sure all tests pass. You can use **RUN_TESTS_PARALLEL** for a faster test run if you have multiple cores.
2175. (Optional) Build the project **doxygen** to get API documentation generated from your Simbody source. You will get some warnings if your doxygen version is earlier than Doxygen 1.8.8; upgrade if you can.
2186. Install Simbody by right-clicking **INSTALL** and selecting **Build**.
219
220#### Play around with examples
221
222Within your build in Visual Studio (not the installation):
223
2241. Make sure your configuration is set to a release configuration (e.g., RelWithDebInfo).
2252. Right click on one of the targets whose name begins with `Example -` and select **Select as Startup Project**.
2263. Type **Ctrl-F5** to start the program.
227
228#### Set environment variables and test the installation
229
230If you are only building Simbody to use it with OpenSim, you can skip this section.
231
2321. Allow executables to find Simbody libraries (.dll's) by adding the Simbody `bin/` directory to your `PATH` environment variable.
233    1. In the Start menu (Windows 7 or 10) or screen (Windows 8), search `environment`.
234    2. Select **Edit the system environment variables**.
235    3. Click **Environment Variables...**.
236    4. Under **System variables**, click **Path**, then click **Edit**.
237    5. Add `C:/Simbody/bin;` to the front of the text field. Don't forget the semicolon!
2382. Allow Simbody and other projects (e.g., OpenSim) to find Simbody. In the same Environment Variables window:
239    1. Under **User variables for...**, click **New...**.
240    2. For **Variable name**, type `SIMBODY_HOME`.
241    3. For **Variable value**, type `C:/Simbody`.
2423. Changes only take effect in newly-opened windows. Close any Windows Explorer or Command Prompt windows.
2434. Test your installation by navigating to `C:/Simbody/examples/bin` and running `SimbodyInstallTest.exe` or `SimbodyInstallTestNoViz.exe`.
244
245**Note**: Example binaries are *not* installed for Debug configurations. They are present in the build environment, however, so you can run them from there. They will run *very* slowly!
246
247#### Layout of installation
248
249How is your Simbody installation organized?
250
251* `bin/` the visualizer and shared libraries (.dll's,  used at runtime).
252* `doc/` a few manuals, as well as API docs (`SimbodyAPI.html`).
253* `examples/`
254    * `src/` the source code for the examples.
255    * `bin/` the examples, compiled into executables; run them! (Not installed for Debug builds.)
256* `include/` the header (.h) files; necessary for projects that use Simbody.
257* `lib/` "import" libraries, used during linking.
258* `cmake/` CMake files that are useful for projects that use Simbody.
259
260
261Linux or Mac using make
262-----------------------
263
264These instructions are for building Simbody from source on either a Mac or on
265Ubuntu.
266
267#### Check the compiler version
268
269Simbody uses recent C++ features, that require a modern compiler.
270Before installing Simbody, check your compiler version with commands like that:
271
272- `g++ --version`
273- `clang++ --version`
274
275In case your compiler is not supported, you can upgrade your compiler.
276
277##### Upgrading GCC to 4.9 on Ubuntu 14.04
278
279Here are some instructions to upgrade GCC on a Ubuntu 14.04 distribution.
280
281    $ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
282    $ sudo apt-get update
283    $ sudo apt-get install gcc-4.9 g++-4.9
284
285If one wants to set `gcc-4.9` and `g++-4.9` as the default compilers, run the following command
286
287    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
288
289Remember that when having several compilers, CMake flags
290`CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER` can be used
291to select the ones desired. For example, Simbody can be
292configured with the following flags:
293
294    $ cmake -DCMAKE_C_COMPILER=gcc-4.9 -DCMAKE_CXX_COMPILER=g++-4.9
295
296#### Get dependencies
297
298On a Mac, the Xcode developer package gives LAPACK and BLAS to you via the Accelerate
299framework. Mac's come with the visualization dependencies.
300
301On Ubuntu, we need to get the dependencies ourselves. Open a terminal and run the following commands.
302
3031. Get the necessary dependencies: `$ sudo apt-get install cmake liblapack-dev`.
3042. If you want to use the CMake GUI, install `cmake-qt-gui`.
3053. For visualization (optional): `$ sudo apt-get install freeglut3-dev libxi-dev libxmu-dev`.
3064. For API documentation (optional): `$ sudo apt-get install doxygen`.
307
308LAPACK version 3.6.0 and higher may be required for some applications (OpenSim).
309LAPACK can be downloaded from [http://www.netlib.org/lapack/](http://www.netlib.org/lapack/),
310and compiled using the following method. It is sufficient to set `LD_LIBRARY_PATH` to your LAPACK install prefix
311and build Simbody using the `-DBUILD_USING_OTHER_LAPACK:PATH=/path/to/liblapack.so` option in cmake.
312```{bash}
313cmake ../lapack-3.6.0 -DCMAKE_INSTALL_PREFIX=/path/to/new/lapack/ -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=ON
314make
315make install
316```
317
318#### Get the Simbody source code
319
320There are two ways to get the source code.
321
322* Method 1: Download the source code from https://github.com/simbody/simbody/releases.
323  Look for the highest-numbered release, click on the .zip button, and unzip it on your computer.
324  We'll assume you unzipped the source code into `~/simbody-source`.
325* Method 2: Clone the git repository.
326    1. Get git.
327        * Mac: You might have it already, especially if you have Xcode, which
328          is free in the App Store. If not, one method is to install
329          [Homebrew](http://brew.sh/) and run `brew install git` in a
330          terminal.
331        * Ubuntu: run `sudo apt-get install git` in a terminal.
332    2. Clone the github repository into `~/simbody-source`.
333
334            $ git clone https://github.com/simbody/simbody.git ~/simbody-source
335            $ git checkout Simbody-3.7
336
337    3. In the last line above, we assumed you want to build a released version.
338       Feel free to change the version you want to build.
339       If you want to build the latest development version ("bleeding edge") of
340       Simbody off the `master` branch, you can omit the `checkout` line.
341
342       To see the set of releases and checkout a specific version, you can use
343       the following commands:
344
345            $ git tag
346            $ git checkout Simbody-X.Y.Z
347
348#### Configure and generate Makefiles
349
3501. Create a directory in which we'll build Simbody. We'll assume you choose `~/simbody-build`. Don't choose a location inside `~/simbody-source`.
351
352        $ mkdir ~/simbody-build
353        $ cd ~/simbody-build
354
3552. Configure your Simbody build with CMake. We'll use the `cmake` command but you could also use the interactive tools `ccmake` or `cmake-gui`. You have a few configuration options to play with here.
356
357    * If you don't want to fuss with any options, run:
358
359            $ cmake ~/simbody-source
360
361    * Where do you want to install Simbody? By default, it is installed to `/usr/local/`. That's a great default option, especially if you think you'll only use one version of Simbody at a time. You can change this via the `CMAKE_INSTALL_PREFIX` variable. Let's choose `~/simbody`:
362
363            $ cmake ~/simbody-source -DCMAKE_INSTALL_PREFIX=~/simbody
364
365    * Do you want the libraries to be optimized for speed, or to contain debugger symbols? You can change this via the `CMAKE_BUILD_TYPE` variable. There are 4 options:
366        - **Debug**: debugger symbols; no optimizations (more than 10x slower). Library and visualizer names end with `_d`.
367        - **RelWithDebInfo**: debugger symbols; optimized. This is the configuration we recommend.
368        - **Release**: no debugger symbols; optimized. Generated libraries and executables are smaller but not faster than RelWithDebInfo.
369        - **MinSizeRel**: minimum size; optimized. May be slower than RelWithDebInfo or Release.
370
371        You at least want optimized libraries (all configurations but Debug are optimized),
372        but you can have Debug libraries coexist with them. To do this, go through
373        the full installation process twice, once for each configuration. It is
374        typical to use a different build directory for each build type (e.g.,
375        `~/simbody-build-debug` and `~/simbody-build-release`).
376
377    * There are a few other variables you might want to play with:
378        * `BUILD_EXAMPLES` to see what Simbody can do. On by default.
379        * `BUILD_TESTING` to ensure your Simbody works
380          correctly. On by default.
381        * `BUILD_VISUALIZER` to be able to watch your system
382          move about! If building on a cluster, you could turn this off. On by
383          default.
384        * `BUILD_DYNAMIC_LIBRARIES` builds the three libraries as dynamic libraries. On by default.
385        * `BUILD_STATIC_LIBRARIES` builds the three libraries as static libraries, whose names will end with `_static`.
386        * `BUILD_TESTS_AND_EXAMPLES_STATIC` if tests or examples are being built, creates statically-linked tests/examples. Can take a while to build, and it is unlikely you'll use the statically-linked libraries.
387        * `BUILD_TESTS_AND_EXAMPLES_SHARED` if tests or examples are being built, creates dynamically-linked tests/examples. Unless you know what you're doing, leave this one on.
388
389        You can combine all these options. Here's another example:
390
391            $ cmake ~/simbody-source -DCMAKE_INSTALL_PREFIX=~/simbody -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_VISUALIZER=off
392
393#### Build and install
394
3951. Build the API documentation. This is optional, and you can only do this if
396   you have Doxygen. You will get warnings if your doxygen installation is a version older than Doxygen 1.8.8.
397
398        $ make doxygen
399
4002. Compile. Use the `-jn` flag to build using `n` processor cores. For example:
401
402        $ make -j8
403
4043. Run the tests.
405
406        $ ctest -j8
407
4084. Install. If you chose `CMAKE_INSTALL_PREFIX` to be a location which requires sudo access to write to (like `/usr/local/`, prepend this command with a `sudo `.
409
410        $ make -j8 install
411
412Just so you know, you can also uninstall (delete all files that CMake placed into `CMAKE_INSTALL_PREFIX`) if you're in `~/simbody-build`.
413
414    $ make uninstall
415
416
417#### Play around with examples
418
419From your build directory, you can run Simbody's example programs. For instance, try:
420
421        $ ./ExamplePendulum
422
423
424#### Set environment variables and test the installation
425
426If you are only building Simbody to use it with OpenSim, you can skip this section.
427
4281. Allow executables to find Simbody libraries (.dylib's or so's) by adding the
429   Simbody lib directory to your linker path. On Mac, most users can skip
430   this step.
431    * If your `CMAKE_INSTALL_PREFIX` is `/usr/local/`, run:
432
433            $ sudo ldconfig
434
435    * If your `CMAKE_INSTALL_PREFIX` is neither `/usr/` nor `/usr/local/` (e.g., `~/simbody`'):
436        * Mac:
437
438                $ echo 'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:~/simbody/lib' >> ~/.bash_profile
439        * Ubuntu:
440
441                $ echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/simbody/lib/x86_64-linux-gnu' >> ~/.bashrc
442        These commands add a line to a configuration file that is loaded every
443        time you open a new terminal. If using Ubuntu, you may need to replace
444        `x86_64-linux-gnu` with the appropriate directory on your computer.
4452. Allow Simbody and other projects (e.g., OpenSim) to find Simbody. Make sure to replace `~/simbody` with your `CMAKE_INSTALL_PREFIX`.
446    * Mac:
447
448            $ echo 'export SIMBODY_HOME=~/simbody' >> ~/.bash_profile
449    * Ubuntu:
450
451            $ echo 'export SIMBODY_HOME=~/simbody' >> ~/.bashrc
4523. Open a new terminal.
4534. Test your installation:
454
455        $ cd ~/simbody/share/doc/simbody/examples/bin
456        $ ./SimbodyInstallTest # or ./SimbodyInstallTestNoViz
457
458#### Layout of installation
459
460The installation creates the following directories in `CMAKE_INSTALL_PREFIX`. The directory `[x86_64-linux-gnu]` only exists if you did NOT install to `/usr/local/` and varies by platform. Even in that case, the name of your directory may be different.
461
462* `include/simbody/` the header (.h) files; necessary for projects that use Simbody.
463* `lib/[x86_64-linux-gnu]/` shared libraries (.dylib's or .so's).
464    * `cmake/simbody/` CMake files that are useful for projects that use Simbody.
465    * `pkgconfig/` pkg-config files useful for projects that use Simbody.
466    * `simbody/examples/` the examples, compiled into executables; run them! (Not installed for Debug builds.)
467* `libexec/simbody/` the `simbody-visualizer` executable.
468* `share/doc/simbody/` a few manuals, as well as API docs (`SimbodyAPI.html`).
469    * `examples/src` source code for the examples.
470    * `examples/bin` symbolic link to the runnable examples.
471
472
473Mac and Homebrew
474----------------
475
476If using a Mac and Homebrew, the dependencies are taken care of for you.
477
478#### Install
479
4801. Install [Homebrew](http://brew.sh/).
4812. Open a terminal.
4823. Add the Open Source Robotics Foundation's list of repositories to Homebrew:
483    ```
484    $ brew tap osrf/simulation
485    ```
486
4872. Install the latest release of Simbody.
488    ```
489    $ brew install simbody
490    ```
491    To install from the master branch instead, append ` --HEAD` to the command above.
492
493#### Where is Simbody installed?
494
495Simbody is now installed to `/usr/local/Cellar/simbody/<version>/`,
496where `<version>` is either the version number (e.g., `3.6.1`),
497or `HEAD` if you specified `--HEAD` above.
498
499Some directories are symlinked (symbolically linked) to `/usr/local/`, which is where your system typically expects to find executables, shared libraries (.dylib's), headers (.h's), etc. The following directories from the Simbody installation are symlinked:
500
501* `include/simbody   -> /usr/local/include/simbody`
502* `lib               -> /usr/local/lib`
503* `share/doc/simbody -> /usr/local/share/doc/simbody`
504
505#### Layout of installation
506
507What's in the `/usr/local/Cellar/simbody/<version>/` directory?
508
509* `include/simbody/` the header (.h) files; necessary for projects that use Simbody.
510* `lib/` shared libraries (.dylib's), used at runtime.
511    * `cmake/simbody/` CMake files that are useful for projects that use Simbody.
512    * `pkgconfig/` pkg-config files useful for projects that use Simbody.
513    * `simbody/examples/` the examples, compiled into executables; run them! (Not installed for Debug builds.)
514* `libexec/simbody/` the `simbody-visualizer` executable.
515* `share/doc/simbody/` a few manuals, as well as API docs (`SimbodyAPI.html`).
516    * `examples/src` source code for the examples.
517    * `examples/bin` symbolic link to executable examples.
518
519Ubuntu and apt-get
520------------------
521
522Starting with Ubuntu 15.04, Simbody is available in the Ubuntu (and Debian) repositories. You can see a list of all simbody packages for all Ubuntu versions at the [Ubuntu Packages website](http://packages.ubuntu.com/search?keywords=simbody&searchon=names&suite=all&section=all). The latest version of Simbody is usually not available in the Ubuntu repositories; the process for getting a new version of Simbody into the Ubuntu repositories could take up to a year.
523
524#### Install
525
5261. Open a terminal and run the following command:
527
528        $ sudo apt-get install libsimbody-dev simbody-doc
529
530#### Layout of installation
531
532Simbody is installed into the `usr/` directory.  The directory
533`[x86_64-linux-gnu]` varies by platform.
534
535* `usr/include/simbody/` the header (.h) files; necessary for projects that use Simbody.
536* `usr/lib/[x86_64-linux-gnu]` shared libraries (.so's).
537    * `cmake/simbody/` CMake files that are useful for projects that use Simbody.
538    * `pkgconfig/` pkg-config files useful for projects that use Simbody.
539* `usr/libexec/simbody/` the `simbody-visualizer` executable.
540* `usr/share/doc/simbody/` a few manuals, as well as API docs (`SimbodyAPI.html`).
541    * `examples/src` source code for the examples.
542    * `examples/bin` symbolic link to executable examples.
543
544FreeBSD and pkg
545---------------
546
547Simbody is available via the FreeBSD package repository.
548
549#### Install
550
5511. Open a terminal and run the following command:
552
553        $ sudo pkg install simbody
554
555Windows using MinGW
556-------------------
557
558Warning: The [MinGW](http://sourceforge.net/projects/mingw-w64/)
559generation and build is experimental!
560
561This build is still experimental, because of :
562
563* the various MinGW versions available (Thread model, exception mechanism)
564* the compiled libraries Simbody depends on (Blas, Lapack and optionnaly glut).
565
566Below are three sections that gives a list of supported versions, command line
567instructions, and reasons why is it not so obvious to use MinGW.
568
569#### Supported MinGW versions
570
571If you do not want to go into details, you need a MinGW version with :
572
573* a Posix thread model and Dwarf exception mechanism on a 32 bit computer
574* a Posix thread model and SJLJ exception mechanism on a 64 bit computer
575
576Other versions are supported with additional configurations.
577
578The table below lists the various versions of MinGW versions tested:
579
580|   | OS      | Thread | Exception | Comment                                                             | URL                                           |
581| - | ------- | ------ | --------- | ------------------------------------------------------------------- | --------------------------------------------- |
582| 1 | 64 Bits | Posix  | SJLJ      | All features supported, all binary included (Recommended version)   | [MinGW64 GCC 5.2.0][mingw_520_64_posix_sjlj]  |
583| 2 | 64 Bits | Posix  | SEH       | Needs to be linked against user's Blas and Lapack                   | [MinGW64 GCC 5.2.0][mingw_520_64_posix_seh]   |
584| 3 | 32 Bits | Posix  | Dwarf     | No visualization, all binary included                               | [MinGW64 GCC 5.2.0][mingw_520_32_posix_dwarf] |
585| 4 | 32 Bits | Posix  | SJLJ      | No visualization, needs to be linked against user's Blas and Lapack | [MinGW64 GCC 5.2.0][mingw_520_32_posix_sjlj]  |
586
587We recommend to use the first configuration where all features are supported and
588does not need additional libraries to compile and run.
589The URL allows to download directly this version.
590The second version needs to be linked against user's Blas and Lapack
591(A CLI example is given below).
592Blas and Lapack sources can be downloaded from
593[netlib](http://www.netlib.org/lapack/lapack-3.5.0.tgz).
594For the 3rd and 4th versions that run that target a 32 bit behaviour,
595visualization is not possible for the time being.
596(It is due to a compile and link problem with `glut`).
597Moreover for the 4th one, one needs to provide Blas and Lapack libraries.
598
599Please note that only Posix version of MinGW are supported.
600
601If your version is not supported, CMake will detect it while configuring and stops.
602
603#### Instructions
604
605Below are some examples of command line instructions for various cases.
606It is assumed you are running commands from a build directory, that can access Simbody source with a command `cd ..\simbody`.
607
608It is recommended to specify with the installation directory with flag `CMAKE_INSTALL_PREFIX`
609(e.g. `-DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody"`).
610If not used, the installation directory will be `C:\Program Files (x86)\Simbody`
611on a 64 bit computer. This might be confusing since it is the 32 bit installation location.
612
613Example of instructions where one uses Blas and Lapack libraries provided (to be used in a Windows terminal, where MinGW is in the PATH):
614
615    rem CMake configuration
616    cmake ..\simbody -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody"
617    rem Compilation
618    mingw32-make
619    rem Test
620    mingw32-make test
621    rem Installation
622    mingw32-make install
623
624Example of instructions where one uses Blas and Lapack libraries provided (to be used in a Windows terminal, where MinGW is NOT in the PATH):
625
626    rem Variable and path definition
627    set CMAKE="C:\Program Files\CMake\bin\cmake.exe"
628    set MinGWDir=C:\Program Files\mingw-w64\i686-5.2.0-posix-sjlj-rt_v4-rev0\mingw32
629    set PATH=%MinGWDir%\bin;%MinGWDir%\i686-w64-mingw32\lib
630    rem CMake configuration
631    %CMAKE% ..\simbody -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ^
632     -DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody" ^
633     -DCMAKE_C_COMPILER:PATH="%MinGWDir%\bin\gcc.exe" ^
634     -DCMAKE_CXX_COMPILER:PATH="%MinGWDir%\bin\g++.exe" ^
635     -DCMAKE_MAKE_PROGRAM:PATH="%MinGWDir%\bin\mingw32-make.exe"
636    rem Compilation
637    mingw32-make
638    rem Test
639    mingw32-make test
640    rem Installation
641    mingw32-make install
642
643Example of instructions where one uses Blas and Lapack libraries provided (to be used in a MSYS terminal with MinGW in the PATH):
644
645    # CMake configuration
646    cmake ../simbody -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody"
647    # Compilation
648    make
649    # Test
650    make test
651    # Installation
652    make install
653
654Example of instructions where one provides our own Blas and Lapack libraries (to be used in a MSYS terminal with MinGW in the PATH):
655
656    # CMake configuration
657    cmake ../simbody -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release \
658    -DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody" \
659    -DCMAKE_C_COMPILER:PATH="C:\Program Files\mingw-w64\i686-5.2.0-posix-sjlj-rt_v4-rev0\mingw32\bin\gcc.exe" \
660    -DCMAKE_CXX_COMPILER:PATH="C:\Program Files\mingw-w64\i686-5.2.0-posix-sjlj-rt_v4-rev0\mingw32\bin\g++.exe" \
661    -DBUILD_USING_OTHER_LAPACK:PATH="C:\Program Files\lapack-3.5.0\bin\liblapack.dll;C:\Program Files\lapack-3.5.0\bin\libblas.dll"
662    make
663    # Test
664    make test
665    # Installation
666    make install
667
668
669#### MinGW details
670
671This paragraph explains the reason why one can not use any MinGW version.
672
673MinGW is available with two thread models :
674
675* Win32 thread model
676* Posix thread model
677
678One has to use the Posix thread model, since all thread functionalities (e.g. `std:mutex`) are not implemented.
679
680To ease building on Windows, Simbody provides compiled libraries for Blas and Lapack :
681
682* On Windows 32 Bits, these were compiled with a Dwarf exception mechanism,
683* On Windows 64 Bits, these were compiled with a SJLJ exception mechanism.
684
685If one chooses a MinGW compilation, we need to respect this exception mechanism.
686A program can not rely on both mechanisms.
687This means that if we want to use the compiled libraries, our MinGW installation should
688have the same exception mechanism.
689Otherwise, we need to provide our own Blas and Lapack libraries.
690
691To see which exception mechanism is used, user can look at dlls located in the `bin` directory of MinGW.
692The name of mechanism is present in the file `libgcc_XXXX.dll`, where `XXXX` can be `dw`, `seh` or `sjlj`.
693For some MinGW versions, this information is also available by looking at the result of `gcc --version`.
694
695CMake will check the version of your MinGW, and if the exception mechanism is different,
696then the configuration stops because of this difference.
697If one provides Blas and Lapack libraries with the CMake variable `BUILD_USING_OTHER_LAPACK`,
698compilation with MinGW is always possible.
699
700Windows, Mac, and Linux Using Conda
701-----------------------------------
702
703[Conda](http://conda.pydata.org) is a cross platform package manager that can
704be used to install Simbody on Windows, Mac, or Linux. To install Simbody using
705Conda you must first install
706[Miniconda](http://conda.pydata.org/miniconda.html) or
707[Anaconda](https://www.continuum.io/downloads). Either of these will provide
708the `conda` command which can be invoked at the command line to install Simbody
709from the [Conda Forge](https://conda-forge.github.io/) channel as follows:
710
711```
712$ conda install -c conda-forge simbody
713```
714
715This command will install Simbody (both the libraries and headers) into
716the Miniconda or Anaconda installation directory as per the standard layout for
717each of the operating systems described above. The Conda Forge Simbody recipe
718can be found in Conda Forge's [feedstock
719repository](https://github.com/conda-forge/simbody-feedstock).
720
721Acknowledgments
722---------------
723We are grateful for past and continuing support for Simbody's development in Stanford's Bioengineering department through the following grants:
724
725- NIH U54 GM072970 (Simulation of Biological Structures)
726- NIH U54 EB020405 (Mobilize Center)
727- NIH R24 HD065690 (Simulation in Rehabilitation Research)
728- OSRF subcontract 12-006 to DARPA HR0011-12-C-0111 (Robotics Challenge)
729
730Prof. Scott Delp is the Principal Investigator on these grants and Simbody is used extensively in Scott's [Neuromuscular Biomechanics Lab](https://nmbl.stanford.edu) as the basis for the [OpenSim](http://opensim.stanford.edu) biomechanical simulation software application for medical research.
731
732
733
734[buildstatus_image_travis]: https://travis-ci.org/simbody/simbody.svg?branch=master
735[travisci]: https://travis-ci.org/simbody/simbody
736[buildstatus_image_appveyor]: https://ci.appveyor.com/api/projects/status/2dua0qna2m85fts2/branch/master?svg=true
737[appveyorci]: https://ci.appveyor.com/project/opensim-org/simbody/branch/master
738[buildstatus_image_codecov]: https://codecov.io/gh/simbody/simbody/branch/master/graph/badge.svg
739[codecovci]: https://codecov.io/gh/simbody/simbody
740[user]: https://github.com/simbody/simbody/raw/master/Simbody/doc/SimbodyAndMolmodelUserGuide.pdf
741[rna]: doc/images/simbios_11000_body_RNA.gif
742[simbios]: http://simbios.stanford.edu/
743[doublePendulum]: doc/images/doublePendulum.gif
744[thy]: https://github.com/simbody/simbody/raw/master/Simbody/doc/SimbodyTheoryManual.pdf
745[flores]: http://xray.bmc.uu.se/flores/Home.html
746[buildwin]: https://github.com/simbody/simbody/raw/master/doc/HowToBuildSimbodyFromSource_Windows.pdf
747[buildunix]: https://github.com/simbody/simbody/raw/master/doc/HowToBuildSimbodyFromSource_MacLinux.pdf
748[mingw_520_64_posix_sjlj]: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/5.2.0/threads-posix/sjlj/x86_64-5.2.0-release-posix-sjlj-rt_v4-rev0.7z/download
749[mingw_520_64_posix_seh]: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/5.2.0/threads-posix/seh/x86_64-5.2.0-release-posix-seh-rt_v4-rev0.7z/download
750[mingw_520_32_posix_dwarf]: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/5.2.0/threads-posix/dwarf/i686-5.2.0-release-posix-dwarf-rt_v4-rev0.7z/download
751[mingw_520_32_posix_sjlj]: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/5.2.0/threads-posix/sjlj/i686-5.2.0-release-posix-sjlj-rt_v4-rev0.7z/download
752