High-performance C++ multibody dynamics/physics library for simulating articulated biomechanical and mechanical systems like vehicles, robots, and the human skeleton.

Overview

Simbody Travis Appveyor Codecov

Simbody is a high-performance, open-source toolkit for science- and engineering-quality simulation of articulated mechanisms, including biomechanical structures such as human and animal skeletons, mechanical systems like robots, vehicles, and machines, and anything else that can be described as a set of rigid bodies interconnected by joints, influenced by forces and motions, and restricted by constraints. Simbody includes a multibody dynamics library for modeling motion in generalized/internal coordinates in O(n) time. This is sometimes called a Featherstone-style physics engine.

Simbody provides a C++ API that is used to build domain-specific applications; it is not a standalone application itself. For example, it is used by biomechanists in OpenSim, by roboticists in Gazebo, and for biomolecular research in MacroMoleculeBuilder (MMB). Here's an artful simulation of several RNA molecules containing thousands of bodies, performed with MMB by Samuel Flores:

Sam Flores' Simbody RNA simulation

Read more about Simbody at the Simbody homepage.

Simple example: a double pendulum

Here's some code to simulate and visualize a 2-link chain:

#include "Simbody.h"
using namespace SimTK;
int main() {
    // Define the system.
    MultibodySystem system;
    SimbodyMatterSubsystem matter(system);
    GeneralForceSubsystem forces(system);
    Force::Gravity gravity(forces, matter, -YAxis, 9.8);

    // Describe mass and visualization properties for a generic body.
    Body::Rigid bodyInfo(MassProperties(1.0, Vec3(0), UnitInertia(1)));
    bodyInfo.addDecoration(Transform(), DecorativeSphere(0.1));

    // Create the moving (mobilized) bodies of the pendulum.
    MobilizedBody::Pin pendulum1(matter.Ground(), Transform(Vec3(0)),
            bodyInfo, Transform(Vec3(0, 1, 0)));
    MobilizedBody::Pin pendulum2(pendulum1, Transform(Vec3(0)),
            bodyInfo, Transform(Vec3(0, 1, 0)));

    // Set up visualization.
    system.setUseUniformBackground(true);
    Visualizer viz(system);
    system.addEventReporter(new Visualizer::Reporter(viz, 0.01));

    // Initialize the system and state.
    State state = system.realizeTopology();
    pendulum2.setRate(state, 5.0);

    // Simulate for 20 seconds.
    RungeKuttaMersonIntegrator integ(system);
    TimeStepper ts(system, integ);
    ts.initialize(state);
    ts.stepTo(20.0);
}

Double-pendulum simulation in Simbody

See Simbody's User Guide for a step-by-step explanation of this example.

Features

  • Wide variety of joint, constraint, and force types; easily user-extended.
  • Forward, inverse, and mixed dynamics. Motion driven by forces or prescribed motion.
  • Contact (Hertz, Hunt and Crossley models).
  • Gradient descent, interior point, and global (CMA) optimizers.
  • A variety of numerical integrators with error control.
  • Visualizer, using OpenGL

You want to...


Dependencies

Simbody depends on the following:

  • cross-platform building: CMake 2.8.10 or later (3.1.3 or later for Visual Studio).
  • compiler: Visual Studio 2015, 2017, or 2019 (Windows only), gcc 4.9.0 or later (typically on Linux), Clang 3.4 or later, or Apple Clang (Xcode) 8 or later.
  • linear algebra: LAPACK 3.6.0 or later and BLAS
  • visualization (optional): FreeGLUT, Xi and Xmu
  • API documentation (optional): Doxygen 1.8.6 or later; we recommend at least 1.8.8.

Using Simbody

  • Creating your own Simbody-using project with CMake To get started with your own Simbody-using project, check out the cmake/SampleCMakeLists.txt file.

Installing

Simbody 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:

  1. Windows: build from source using Microsoft Visual Studio.
  2. Linux or Mac (make): build from source using gcc or Clang with make.
  3. Mac (Homebrew): automated build/install with Homebrew.
  4. Ubuntu/Debian: install pre-built binaries with apt-get.
  5. FreeBSD: install pre-built binaries with pkg.
  6. Windows using MinGW: build from source using MinGW.
  7. Windows/Mac/Linux: install pre-built binaries with the Conda package manager.

If you use Linux, check Repology to see if your distribution provides a package for Simbody.

These are not the only ways to install Simbody, however. For example, on a Mac, you could use CMake and Xcode.

C++11 and gcc/Clang

Simbody 3.6 and later uses C++11 features (the -std=c++11 flag). Simbody 3.3 and earlier use only C++03 features, and Simbody 3.4 and 3.5 can use either C++03 or C++11; see the SIMBODY_STANDARD_11 CMake variable in these versions. Note that if you want to use the C++11 flag in your own project, Simbody must have been compiled with the C++11 flag as well.

Windows using Visual Studio

Get the dependencies

All needed library dependencies are provided with the Simbody installation on Windows, including linear algebra and visualization dependencies.

  1. Download and install Microsoft Visual Studio, version 2015, 2017, or 2019. The Community edition is free and sufficient.
  • 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.
  • 2017 and later: In the installer, select the Desktop development with C++ workload.
  • Any other C++ code you plan to use with Simbody should be compiled with the same compiler as used for Simbody.
  1. Download and install CMake, version 3.1.3 or higher.
  2. (optional) If you want to build API documentation, download and install Doxygen, version 1.8.8 or higher.

Download the Simbody source code

  • 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.
  • Method 2: Clone the git repository.
    1. Get git. There are many options:

    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:

       $ git clone https://github.com/simbody/simbody.git C:/Simbody-source
       $ git checkout Simbody-3.7
      
    3. In the last line above, we assumed you want to build a released version. Feel free to change the version you want to build. If you want to build the latest development version ("bleeding edge") of Simbody off the master branch, you can omit the checkout line.

      To see the set of releases and checkout a specific version, you can use the following commands:

       $ git tag
       $ git checkout Simbody-X.Y.Z
      

Configure and generate project files

  1. Open CMake.
  2. In the field Where is the source code, specify C:/Simbody-source.
  3. 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.
  4. Click the Configure button.
    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).
    2. Click Finish.
  5. 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.
  6. Play around with the other build options:
    • BUILD_EXAMPLES to see what Simbody can do. On by default.
    • BUILD_TESTING to ensure your Simbody works correctly. On by default.
    • BUILD_VISUALIZER to be able to watch your system move about! If building remotely, you could turn this off. On by default.
    • BUILD_DYNAMIC_LIBRARIES builds the three libraries as dynamic libraries. On by default. Unless you know what you're doing, leave this one on.
    • 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.
    • 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.
    • 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.
  7. Click the Configure button again. Then, click Generate to make Visual Studio project files.

Build and install

  1. Open C:/Simbody-build/Simbody.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 and visualizer names end with _d.
    • RelWithDebInfo: debugger symbols; optimized. This is the configuration we recommend.
    • Release: no debugger symbols; optimized. Generated libraries and executables are smaller but not faster than RelWithDebInfo.
    • MinSizeRel: minimum size; optimized. May be slower than RelWithDebInfo or Release.

    You at least want optimized libraries (all configurations but Debug are optimized), but you can have Debug libraries coexist with them. To do this, go through the full installation process twice, once for each configuration.

  3. Build the project ALL_BUILD by right-clicking it and selecting Build.

  4. 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.

  5. (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.

  6. Install Simbody by right-clicking INSTALL and selecting Build.

Play around with examples

Within your build in Visual Studio (not the installation):

  1. Make sure your configuration is set to a release configuration (e.g., RelWithDebInfo).
  2. Right click on one of the targets whose name begins with Example - and select Select as Startup Project.
  3. Type Ctrl-F5 to start the program.

Set environment variables and test the installation

If you are only building Simbody to use it with OpenSim, you can skip this section.

  1. Allow executables to find Simbody libraries (.dll's) by adding the Simbody bin/ directory to your PATH environment variable.
    1. In the Start menu (Windows 7 or 10) or screen (Windows 8), 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:/Simbody/bin; to the front of the text field. Don't forget the semicolon!
  2. Allow Simbody and other projects (e.g., OpenSim) to find Simbody. In the same Environment Variables window:
    1. Under User variables for..., click New....
    2. For Variable name, type SIMBODY_HOME.
    3. For Variable value, type C:/Simbody.
  3. Changes only take effect in newly-opened windows. Close any Windows Explorer or Command Prompt windows.
  4. Test your installation by navigating to C:/Simbody/examples/bin and running SimbodyInstallTest.exe or SimbodyInstallTestNoViz.exe.

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!

Layout of installation

How is your Simbody installation organized?

  • bin/ the visualizer and shared libraries (.dll's, used at runtime).
  • doc/ a few manuals, as well as API docs (SimbodyAPI.html).
  • examples/
    • src/ the source code for the examples.
    • bin/ the examples, compiled into executables; run them! (Not installed for Debug builds.)
  • include/ the header (.h) files; necessary for projects that use Simbody.
  • lib/ "import" libraries, used during linking.
  • cmake/ CMake files that are useful for projects that use Simbody.

Linux or Mac using make

These instructions are for building Simbody from source on either a Mac or on Ubuntu.

Check the compiler version

Simbody uses recent C++ features, that require a modern compiler. Before installing Simbody, check your compiler version with commands like that:

  • g++ --version
  • clang++ --version

In case your compiler is not supported, you can upgrade your compiler.

Upgrading GCC to 4.9 on Ubuntu 14.04

Here are some instructions to upgrade GCC on a Ubuntu 14.04 distribution.

$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-4.9 g++-4.9

If one wants to set gcc-4.9 and g++-4.9 as the default compilers, run the following command

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9

Remember that when having several compilers, CMake flags CMAKE_C_COMPILER and CMAKE_CXX_COMPILER can be used to select the ones desired. For example, Simbody can be configured with the following flags:

$ cmake -DCMAKE_C_COMPILER=gcc-4.9 -DCMAKE_CXX_COMPILER=g++-4.9

Get dependencies

On a Mac, the Xcode developer package gives LAPACK and BLAS to you via the Accelerate framework. Mac's come with the visualization dependencies.

On Ubuntu, we need to get the dependencies ourselves. Open a terminal and run the following commands.

  1. Get the necessary dependencies: $ sudo apt-get install cmake liblapack-dev.
  2. If you want to use the CMake GUI, install cmake-qt-gui.
  3. For visualization (optional): $ sudo apt-get install freeglut3-dev libxi-dev libxmu-dev.
  4. For API documentation (optional): $ sudo apt-get install doxygen.

LAPACK version 3.6.0 and higher may be required for some applications (OpenSim). LAPACK can be downloaded from http://www.netlib.org/lapack/, and compiled using the following method. It is sufficient to set LD_LIBRARY_PATH to your LAPACK install prefix and build Simbody using the -DBUILD_USING_OTHER_LAPACK:PATH=/path/to/liblapack.so option in cmake.

cmake ../lapack-3.6.0 -DCMAKE_INSTALL_PREFIX=/path/to/new/lapack/ -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=ON
make
make install

Get the Simbody source code

There are two ways to get the source code.

  • 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 ~/simbody-source.
  • Method 2: Clone the git repository.
    1. Get git.

      • Mac: You might have it already, especially if you have Xcode, which is free in the App Store. If not, one method is to install Homebrew and run brew install git in a terminal.
      • Ubuntu: run sudo apt-get install git in a terminal.
    2. Clone the github repository into ~/simbody-source.

       $ git clone https://github.com/simbody/simbody.git ~/simbody-source
       $ git checkout Simbody-3.7
      
    3. In the last line above, we assumed you want to build a released version. Feel free to change the version you want to build. If you want to build the latest development version ("bleeding edge") of Simbody off the master branch, you can omit the checkout line.

      To see the set of releases and checkout a specific version, you can use the following commands:

       $ git tag
       $ git checkout Simbody-X.Y.Z
      

Configure and generate Makefiles

  1. Create a directory in which we'll build Simbody. We'll assume you choose ~/simbody-build. Don't choose a location inside ~/simbody-source.

     $ mkdir ~/simbody-build
     $ cd ~/simbody-build
    
  2. 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.

    • If you don't want to fuss with any options, run:

        $ cmake ~/simbody-source
      
    • 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:

        $ cmake ~/simbody-source -DCMAKE_INSTALL_PREFIX=~/simbody
      
    • 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:

      • Debug: debugger symbols; no optimizations (more than 10x slower). Library and visualizer names end with _d.
      • RelWithDebInfo: debugger symbols; optimized. This is the configuration we recommend.
      • Release: no debugger symbols; optimized. Generated libraries and executables are smaller but not faster than RelWithDebInfo.
      • MinSizeRel: minimum size; optimized. May be slower than RelWithDebInfo or Release.

      You at least want optimized libraries (all configurations but Debug are optimized), but you can have Debug libraries coexist with them. To do this, go through the full installation process twice, once for each configuration. It is typical to use a different build directory for each build type (e.g., ~/simbody-build-debug and ~/simbody-build-release).

    • There are a few other variables you might want to play with:

      • BUILD_EXAMPLES to see what Simbody can do. On by default.
      • BUILD_TESTING to ensure your Simbody works correctly. On by default.
      • BUILD_VISUALIZER to be able to watch your system move about! If building on a cluster, you could turn this off. On by default.
      • BUILD_DYNAMIC_LIBRARIES builds the three libraries as dynamic libraries. On by default.
      • BUILD_STATIC_LIBRARIES builds the three libraries as static libraries, whose names will end with _static.
      • 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.
      • 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.

      You can combine all these options. Here's another example:

        $ cmake ~/simbody-source -DCMAKE_INSTALL_PREFIX=~/simbody -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_VISUALIZER=off
      

Build and install

  1. Build the API documentation. This is optional, and you can only do this if you have Doxygen. You will get warnings if your doxygen installation is a version older than Doxygen 1.8.8.

     $ make doxygen
    
  2. Compile. Use the -jn flag to build using n processor cores. For example:

     $ make -j8
    
  3. Run the tests.

     $ ctest -j8
    
  4. 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 .

     $ make -j8 install
    

Just so you know, you can also uninstall (delete all files that CMake placed into CMAKE_INSTALL_PREFIX) if you're in ~/simbody-build.

$ make uninstall

Play around with examples

From your build directory, you can run Simbody's example programs. For instance, try:

    $ ./ExamplePendulum

Set environment variables and test the installation

If you are only building Simbody to use it with OpenSim, you can skip this section.

  1. Allow executables to find Simbody libraries (.dylib's or so's) by adding the Simbody lib directory to your linker path. On Mac, most users can skip this step.

    • If your CMAKE_INSTALL_PREFIX is /usr/local/, run:

        $ sudo ldconfig
      
    • If your CMAKE_INSTALL_PREFIX is neither /usr/ nor /usr/local/ (e.g., ~/simbody'):

      • Mac:

          $ echo 'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:~/simbody/lib' >> ~/.bash_profile
        
      • Ubuntu:

          $ echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/simbody/lib/x86_64-linux-gnu' >> ~/.bashrc
        

      These commands add a line to a configuration file that is loaded every time you open a new terminal. If using Ubuntu, you may need to replace x86_64-linux-gnu with the appropriate directory on your computer.

  2. Allow Simbody and other projects (e.g., OpenSim) to find Simbody. Make sure to replace ~/simbody with your CMAKE_INSTALL_PREFIX.

    • Mac:

        $ echo 'export SIMBODY_HOME=~/simbody' >> ~/.bash_profile
      
    • Ubuntu:

        $ echo 'export SIMBODY_HOME=~/simbody' >> ~/.bashrc
      
  3. Open a new terminal.

  4. Test your installation:

     $ cd ~/simbody/share/doc/simbody/examples/bin
     $ ./SimbodyInstallTest # or ./SimbodyInstallTestNoViz
    

Layout of installation

The 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.

  • include/simbody/ the header (.h) files; necessary for projects that use Simbody.
  • lib/[x86_64-linux-gnu]/ shared libraries (.dylib's or .so's).
    • cmake/simbody/ CMake files that are useful for projects that use Simbody.
    • pkgconfig/ pkg-config files useful for projects that use Simbody.
    • simbody/examples/ the examples, compiled into executables; run them! (Not installed for Debug builds.)
  • libexec/simbody/ the simbody-visualizer executable.
  • share/doc/simbody/ a few manuals, as well as API docs (SimbodyAPI.html).
    • examples/src source code for the examples.
    • examples/bin symbolic link to the runnable examples.

Mac and Homebrew

If using a Mac and Homebrew, the dependencies are taken care of for you.

Install

  1. Install Homebrew.

  2. Open a terminal.

  3. Add the Open Source Robotics Foundation's list of repositories to Homebrew:

    $ brew tap osrf/simulation
    
  4. Install the latest release of Simbody.

    $ brew install simbody
    

    To install from the master branch instead, append --HEAD to the command above.

Where is Simbody installed?

Simbody is now installed to /usr/local/Cellar/simbody/<version>/, where <version> is either the version number (e.g., 3.6.1), or HEAD if you specified --HEAD above.

Some 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:

  • include/simbody -> /usr/local/include/simbody
  • lib -> /usr/local/lib
  • share/doc/simbody -> /usr/local/share/doc/simbody

Layout of installation

What's in the /usr/local/Cellar/simbody/<version>/ directory?

  • include/simbody/ the header (.h) files; necessary for projects that use Simbody.
  • lib/ shared libraries (.dylib's), used at runtime.
    • cmake/simbody/ CMake files that are useful for projects that use Simbody.
    • pkgconfig/ pkg-config files useful for projects that use Simbody.
    • simbody/examples/ the examples, compiled into executables; run them! (Not installed for Debug builds.)
  • libexec/simbody/ the simbody-visualizer executable.
  • share/doc/simbody/ a few manuals, as well as API docs (SimbodyAPI.html).
    • examples/src source code for the examples.
    • examples/bin symbolic link to executable examples.

Ubuntu and apt-get

Starting 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. 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.

Install

  1. Open a terminal and run the following command:

     $ sudo apt-get install libsimbody-dev simbody-doc
    

Layout of installation

Simbody is installed into the usr/ directory. The directory [x86_64-linux-gnu] varies by platform.

  • usr/include/simbody/ the header (.h) files; necessary for projects that use Simbody.
  • usr/lib/[x86_64-linux-gnu] shared libraries (.so's).
    • cmake/simbody/ CMake files that are useful for projects that use Simbody.
    • pkgconfig/ pkg-config files useful for projects that use Simbody.
  • usr/libexec/simbody/ the simbody-visualizer executable.
  • usr/share/doc/simbody/ a few manuals, as well as API docs (SimbodyAPI.html).
    • examples/src source code for the examples.
    • examples/bin symbolic link to executable examples.

FreeBSD and pkg

Simbody is available via the FreeBSD package repository.

Install

  1. Open a terminal and run the following command:

     $ sudo pkg install simbody
    

Windows using MinGW

Warning: The MinGW generation and build is experimental!

This build is still experimental, because of :

  • the various MinGW versions available (Thread model, exception mechanism)
  • the compiled libraries Simbody depends on (Blas, Lapack and optionnaly glut).

Below are three sections that gives a list of supported versions, command line instructions, and reasons why is it not so obvious to use MinGW.

Supported MinGW versions

If you do not want to go into details, you need a MinGW version with :

  • a Posix thread model and Dwarf exception mechanism on a 32 bit computer
  • a Posix thread model and SJLJ exception mechanism on a 64 bit computer

Other versions are supported with additional configurations.

The table below lists the various versions of MinGW versions tested:

OS Thread Exception Comment URL
1 64 Bits Posix SJLJ All features supported, all binary included (Recommended version) MinGW64 GCC 5.2.0
2 64 Bits Posix SEH Needs to be linked against user's Blas and Lapack MinGW64 GCC 5.2.0
3 32 Bits Posix Dwarf No visualization, all binary included MinGW64 GCC 5.2.0
4 32 Bits Posix SJLJ No visualization, needs to be linked against user's Blas and Lapack MinGW64 GCC 5.2.0

We recommend to use the first configuration where all features are supported and does not need additional libraries to compile and run. The URL allows to download directly this version. The second version needs to be linked against user's Blas and Lapack (A CLI example is given below). Blas and Lapack sources can be downloaded from netlib. For the 3rd and 4th versions that run that target a 32 bit behaviour, visualization is not possible for the time being. (It is due to a compile and link problem with glut). Moreover for the 4th one, one needs to provide Blas and Lapack libraries.

Please note that only Posix version of MinGW are supported.

If your version is not supported, CMake will detect it while configuring and stops.

Instructions

Below are some examples of command line instructions for various cases. It is assumed you are running commands from a build directory, that can access Simbody source with a command cd ..\simbody.

It is recommended to specify with the installation directory with flag CMAKE_INSTALL_PREFIX (e.g. -DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody"). If not used, the installation directory will be C:\Program Files (x86)\Simbody on a 64 bit computer. This might be confusing since it is the 32 bit installation location.

Example of instructions where one uses Blas and Lapack libraries provided (to be used in a Windows terminal, where MinGW is in the PATH):

rem CMake configuration
cmake ..\simbody -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody"
rem Compilation
mingw32-make
rem Test
mingw32-make test
rem Installation
mingw32-make install

Example of instructions where one uses Blas and Lapack libraries provided (to be used in a Windows terminal, where MinGW is NOT in the PATH):

rem Variable and path definition
set CMAKE="C:\Program Files\CMake\bin\cmake.exe"
set MinGWDir=C:\Program Files\mingw-w64\i686-5.2.0-posix-sjlj-rt_v4-rev0\mingw32
set PATH=%MinGWDir%\bin;%MinGWDir%\i686-w64-mingw32\lib
rem CMake configuration
%CMAKE% ..\simbody -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ^
 -DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody" ^
 -DCMAKE_C_COMPILER:PATH="%MinGWDir%\bin\gcc.exe" ^
 -DCMAKE_CXX_COMPILER:PATH="%MinGWDir%\bin\g++.exe" ^
 -DCMAKE_MAKE_PROGRAM:PATH="%MinGWDir%\bin\mingw32-make.exe"
rem Compilation
mingw32-make
rem Test
mingw32-make test
rem Installation
mingw32-make install

Example of instructions where one uses Blas and Lapack libraries provided (to be used in a MSYS terminal with MinGW in the PATH):

# CMake configuration
cmake ../simbody -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody"
# Compilation
make
# Test
make test
# Installation
make install

Example of instructions where one provides our own Blas and Lapack libraries (to be used in a MSYS terminal with MinGW in the PATH):

# CMake configuration
cmake ../simbody -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="C:\Program Files\Simbody" \
-DCMAKE_C_COMPILER:PATH="C:\Program Files\mingw-w64\i686-5.2.0-posix-sjlj-rt_v4-rev0\mingw32\bin\gcc.exe" \
-DCMAKE_CXX_COMPILER:PATH="C:\Program Files\mingw-w64\i686-5.2.0-posix-sjlj-rt_v4-rev0\mingw32\bin\g++.exe" \
-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"
make
# Test
make test
# Installation
make install

MinGW details

This paragraph explains the reason why one can not use any MinGW version.

MinGW is available with two thread models :

  • Win32 thread model
  • Posix thread model

One has to use the Posix thread model, since all thread functionalities (e.g. std:mutex) are not implemented.

To ease building on Windows, Simbody provides compiled libraries for Blas and Lapack :

  • On Windows 32 Bits, these were compiled with a Dwarf exception mechanism,
  • On Windows 64 Bits, these were compiled with a SJLJ exception mechanism.

If one chooses a MinGW compilation, we need to respect this exception mechanism. A program can not rely on both mechanisms. This means that if we want to use the compiled libraries, our MinGW installation should have the same exception mechanism. Otherwise, we need to provide our own Blas and Lapack libraries.

To see which exception mechanism is used, user can look at dlls located in the bin directory of MinGW. The name of mechanism is present in the file libgcc_XXXX.dll, where XXXX can be dw, seh or sjlj. For some MinGW versions, this information is also available by looking at the result of gcc --version.

CMake will check the version of your MinGW, and if the exception mechanism is different, then the configuration stops because of this difference. If one provides Blas and Lapack libraries with the CMake variable BUILD_USING_OTHER_LAPACK, compilation with MinGW is always possible.

Windows, Mac, and Linux Using Conda

Conda is a cross platform package manager that can be used to install Simbody on Windows, Mac, or Linux. To install Simbody using Conda you must first install Miniconda or Anaconda. Either of these will provide the conda command which can be invoked at the command line to install Simbody from the Conda Forge channel as follows:

$ conda install -c conda-forge simbody

This command will install Simbody (both the libraries and headers) into the Miniconda or Anaconda installation directory as per the standard layout for each of the operating systems described above. The Conda Forge Simbody recipe can be found in Conda Forge's feedstock repository.

Acknowledgments

We are grateful for past and continuing support for Simbody's development in Stanford's Bioengineering department through the following grants:

  • NIH U54 GM072970 (Simulation of Biological Structures)
  • NIH U54 EB020405 (Mobilize Center)
  • NIH R24 HD065690 (Simulation in Rehabilitation Research)
  • OSRF subcontract 12-006 to DARPA HR0011-12-C-0111 (Robotics Challenge)

Prof. Scott Delp is the Principal Investigator on these grants and Simbody is used extensively in Scott's Neuromuscular Biomechanics Lab as the basis for the OpenSim biomechanical simulation software application for medical research.

Issues
  • Task space class with UR10 & Atlas examples, plus example reorganization

    Task space class with UR10 & Atlas examples, plus example reorganization

    This PR continues PR #210 but with the source moved into the simbody/simbody repo from chrisdembia/simbody. (via short-lived PR #237). This is so Chris and I can work on it together and with osrf.

    cc/ @chrisdembia @hsu @scpeters

    opened by sherm1 78
  • [WIP] Operational space ex

    [WIP] Operational space ex

    The start of an example of operational space control in Simbody. @hsu @scpeters @tkuchida @sohapouya could chime in too. I've added those 4 people and @sherm1 as collaborators on my fork; feel free to directly add commits to this branch.

    Right now, there's a reaching task with gravity compensation in its nullspace. I have coded it up inefficiently and in one method. However, I have spent time trying to do the same calculations efficiently; look at all the commented-out code.

    Possible things to do:

    • [x] Add methods/operators to Simbody to calculate things like the task space mass matrix, or the dynamically consistent jacobian inverse.
    • ~~[ ] Add a Force::OperationalSpace to Simbody that has an interface to build up an op-space controller for those who don't want to have to type out the calculations themselves.~~
    • [x] Add documentation in the example, referring people to resources about operational space control.
    • ~~[ ] Use an internal model to compute the controls.~~
    • ~~[ ] Add noise to model sensing of the state of the "actual" model.~~
    • ~~[ ] Model the actuation: model torque sensing and control.~~
    • [x] Display goemetry at the target point.
    • [x] Mouse or keyboard input to move around the target point.
    • [x] use Simbody.h instead of SimTKsimbody.h
    • [x] InertialForces should depend on Velocity stage.
    • [ ] Optimize.
    • [ ] Write test cases (using an RRR robot?).
    • [ ] Why does the simulation freeze when the target goes out of reach of the humanoid?

    I'm hoping this PR can be a place for discussing exactly what we want this example to be, what new methods we want in Simbody, and what we are doing for the September deadline.

    This code is somewhat derived from stuff Gerald Brantner did for ME 485 last Spring.

    opened by chrisdembia 69
  • Fix most warnings generated from -Wmost, for SimTKcommon.

    Fix most warnings generated from -Wmost, for SimTKcommon.

    Addresses #181.

    See travis output for the remaining warnings. So far, I only addressed warnings from SimTKcommon. SimTKcommon still has two warnings, but I don't know what to do with them.

    opened by chrisdembia 46
  • CMAES Optimizer: initial inclusion, threading, MPI, resuming an optimization

    CMAES Optimizer: initial inclusion, threading, MPI, resuming an optimization

    Sherm just got news that cmaes will be released under the Apache 2.0 license, so we will be able to include it directly in Simbody. I am willing to take the brunt of the work doing the integration, but will want help from @sherm1 and, if interested, @carmichaelong and @msdemers.

    First question:

    Since CMAES is a derivative-free optimizer, when someone creates an OptimizerSystem and they try to define a derivative function, what do we do?

    Things to keep in mind:

    • [x] How to handle constraint tolerance?
    • [x] Satisfying license requirements?
    • ~~[ ] Do all OptimizerRep subclasses need to override clone()? There's a definition in OptimizerRep.~~
    • [x] cmaes outputs to the console; should we allow this?
    • [x] Does hitting the maximum number of iterations count as finding a solution?
    • [ ] Check for memory leaks.
    • [x] Create simple CMAES example file.
    • [ ] Create example with an optimization, optimizing something about a model's behavior, using visualization to show the improvement with iterations of the optimization.
    • [ ] Allow restarts.
    • ~~[ ] Use cmaes' boundary transformation?~~
    • [ ] Allow a single parameter, but lambda >= 2 (change this line)
    • [ ] MPI: should the master run objective function evaluations? Make this an option. If master cannot run obj func, then having only one process will cause the solver to hang; prevent option=off with nproc = 1.
    • [ ] Make sure CMAES is well behaved with MPI when only using 1 proc.
    • [ ] Test that a diagnostics level of 2 causes the allcmaes.dat file to be written.
    • [ ] Make sure I only use "popsize" and "stepsize", never "lambda" or "sigma".
    • [ ] In readme, clarify how to find the MPI library with cmake.
    • [ ] SIMBODY_ENABLE_MPI - > SIMBODY_MPI.
    • [ ] Better MPI test: maybe actually run an executable using the mpi executable.
    • [ ] In SimbodyConfig.cmake, provide if mpi was used and which library was used. (use components?)
    • [ ] Diagnostics should print numbers using scientific notation.
    • [ ] Show how to use restarts in CMAESOptimization.cpp
    • [ ] processing cmaes errors (c-cmaes calls exit()?).
    • [ ] Allow turning off parallel.
    • [ ] Add MPI test to travis.
    • [ ] Document more clearly that to use MPI (0) obtain MPI, (1) compile with SIMBODY_MPI, (2) opt.setAdvancedStrOption("parallel", "mpi");, (3) execute as mpiexec -np 3 ....
    • [ ] Remove use of auto_ptr.
    • [ ] Clarify MPI diagnostics.
    • [ ] Don't include "mpi.h" in CMAESOptimizer.h?
    • [ ] Throw error if init_stepsize is not set.
    • [ ] Exception handling with MPI.
    enhancement 
    opened by chrisdembia 46
  • Standardize install paths and cmake finder

    Standardize install paths and cmake finder

    I've made some changes which should approach Simbody to the standard guidelines described by Debian policy and AFAIK they should be quite cross-platforms improvements, although testing in Windows/MacOsX would be nice. Detailed list:

    1. Use GNUInstallDirs, which should provide canonical paths aware of the platform.
    2. Change all the hardcoded paths to use the ones provided by GNUInstallDircs (CMAKE_INSTALL_DOCDIR, CMAKE_INSTALL_LIBDIR, etc).
    3. Adapt and change name to cmake finder, generate it from a .in file to be aware of CMAKE_INSTALL_LIBDIR.

    I will move the debian/ directory out of the source, but I have leaved here during the pull request so the great @thomas-moulard can review the debian metadata changes and maybe provide some feedback.

    opened by j-rivero 44
  • deconstructPathRelativeToSWD

    deconstructPathRelativeToSWD

    Addresses fixes to deconstructPathname (addresses issue #264). Introduces a new function deconstructPathRelativeToSWD that finds the absolute path to a given path name relative to a specified working directory (swd).

    opened by carmichaelong 43
  • ADOLC negator

    ADOLC negator

    [email protected], [email protected] This PR contains the changes in negator.h necessary to build Simbody with ADOLC. This PR also contains various tests in TestADOLCCommon.cpp verifying that negator<adouble> works properly. Note that this PR is based other PRs (ADOLC Ntraits #603 and ADOLC common #600) that are still in review. Changes in other files should thus disappear when those PRs are merged. Please let me know whether I should wait for the other PRs to be merged before going forward.

    One remark: as already discussed with @chrisdembia,

    negator(const adouble& t) {
                v = -N((typename NTraits<N>::Precision)NTraits<adouble>::value(t));
            }
    

    might be problematic but I could not get rid of the value() without getting errors. I have tried different options:

    • Using the following statement gives me an error (cannot convert from 'const adouble' to 'double') negator(const adouble& t) {v = -N((typename NTraits<N>::Precision)t);}

    • Using the following statement gives me an error (cannot convert from 'const adouble' to 'SimTK::conjugate) negator(const adouble& t) {v = -N(t);}

    • Using the following statement gives me a warning (conversion from 'double' to 'const std::complex::_Ty) negator(const adouble& t) {v = -N(NTraits<adouble>::value(t));}

    • Using the following statement is error and warning free negator(const adouble& t) {v = -N((typename NTraits<N>::Precision)NTraits<adouble>::value(t));}

    Here was the conclusion of @chrisdembia:

    Perhaps we can go with the last option until we run into issues with it. I like it because it is safe, as value() will give an exception if taping.


    This change is Reviewable

    opened by antoinefalisse 41
  • Allow multithreaded CMAES.

    Allow multithreaded CMAES.

    @sherm1, are you okay with my use of auto_ptr?

    opened by chrisdembia 40
  • Added the possibility to compile simbody with MinGW for Windows

    Added the possibility to compile simbody with MinGW for Windows

    These commits enable compilation with various versions of MinGW for Windows.

    Since, simbody is shipped with Blas and Lapack libraries compiled with specific versions of MinGW, some checks had to be added to verify compatibility.

    If it is possible to compile simbody, configuration and compilation run smoothly. Otherwise, user is asked to provide its own version of Blas and Lapack, or to change to its version of MinGW.

    Versions tested:

    • MinGW 32 with gcc 4.7.2 and dwarf exception mechanism
    • MinGW 64 with gcc 4.9.2 and SJLJ exception mechanism
    • MinGW 64 with gcc 5.2.0 and SEH exception mechanism with Blas and Lapack compiled manually

    Please note, that one can clean the code with the the two Python scripts:

    The Python script that has been used to remove trailing spaces from CMakeLists.txt files found recursively is:

    import os
    PATH = r'simbody'
    for path, dirs, files in os.walk(PATH):
        for f in files:
            file_name, file_extension = os.path.splitext(f)
            if file_name == 'CMakeLists' and file_extension =='.txt':
                print(f)
                path_name = os.path.join(path, f)
                with open(path_name, 'r') as fh:
                    new = [line.rstrip() for line in fh]
                with open(path_name, 'w') as fh:
                    fh.writelines((line+'\n' for line in new))
    

    The Python script that has been used to remove trailing spaces from files *.c *.h *.cpp *.hpp found recursively is:

    import os
    PATH = r'simbody'
    extensions = ('.c','.h','.cpp','.hpp')
    
    for path, dirs, files in os.walk(PATH):
        for f in files:
            file_name, file_extension = os.path.splitext(f)
            if file_extension in extensions:
                print(f)
                path_name = os.path.join(path, f)
                with open(path_name, 'r') as fh:
                    new = [line.rstrip() for line in fh]
                with open(path_name, 'w') as fh:
                    fh.writelines((line+'\n' for line in new))
    
    opened by Gjacquenot 36
  • Add getPreviousStepUnweightedYErrorEstimates to Integrator

    Add getPreviousStepUnweightedYErrorEstimates to Integrator

    Hi,

    This PR adds getPreviousStepUnweightedYErrorEstimates into simbody's Integrator interface.

    Motivation

    We would like to improve the performance of OpenSim model simulations. One important factor in a simulation's performance may be integrator behaviour. An OpenSim model can contain many components, such as bodies, joints, muscles, etc. - each of those components may map to state variables in the integrator. We suspect that, in complex OpenSim models using error-corrected integrators, integrator performance may be dictated by a small number of components that have high errors in their state variables.

    This PR enables downstream implementations to ask the integrator what its estimates of error were for all state variables during the last integration step. Downstream, we want to join this information (raw state variable values) with OpenSim-level information (components) so that we can ask questions like "which muscle in the model has high-error state variables associated with it". The ambition being that we can eventually say "these muscles might be misconfigured (e.g. too stiff) - we should investigate why".

    Discussion

    My initial commit here is a general suggestion for how this could be achieved, rather than being authoritative. I'm not ultra-familiar with the integrator implementation, so I may have missed some things. Likely discussion points are:

    • The name is fairly verbose, but I wanted to make it clear that the error estimates returned by this are unweighted, and that they can't, alone, be used to infer an integrator's behavior (they are still, nevertheless, fairly useful to have access to). Maybe a better name could be used
    • The error estimates are populated on each step, successful or not. The wording deliberately says "previous step", but the other "previous step" method (getPreviousStepSize) is for the previous successful step.
    • I'm guessing AbstractIntegratorRep is the best place to hold the yErrEst Vector, because other representations may want to store it differently (so it shouldn't force a storage model by putting it on IntegratorRep)
    • CPodesIntegratorRep::getPreviousStepUnweightedYErrorEstimates is currently just throwing as a placeholder. I noticed the implementation does access (in constraint) but doesn't store it. Downstream (OpenSim) doesn't typically use this integrator, but throwing does technically violate Liskov (and his substitution principle).

    This change is Reviewable

    opened by adamkewley 0
  • Clang10 /w C++20 error: SimTK indexes: use of overloaded operator '==' is ambiguous

    Clang10 /w C++20 error: SimTK indexes: use of overloaded operator '==' is ambiguous

    I'm compiling a downstream project that uses OpenSim, but (transitively) includes Simbody. Top-level compiler details:

    # clang++
    Debian clang version 10.0.1-++20200708124224+ef32c611aa2-1~exp1~20200707224822.188 
    Target: x86_64-pc-linux-gnu
    Thread model: posix
    InstalledDir: /usr/bin
    # clang
    Debian clang version 10.0.1-++20200708124224+ef32c611aa2-1~exp1~20200707224822.188 
    Target: x86_64-pc-linux-gnu
    Thread model: posix
    InstalledDir: /usr/bin
    

    Installed as a prebuilt binary from the llvm project site. Effectively, I unpacked it and then configured a project that uses it. Command-line looks something like this:

    CXX=clang++-10 CC=clang-10 cmake -S ../osmv -B . -DCMAKE_PREFIX_PATH=$(readlink -f ~/Desktop/osc/master-RelWithDebInfo-install/lib/cmake) -DCMAKE_GENERATOR=Ninja
    cmake --build . --target all
    

    This compiles completely fine if my project is set to C++17, e.g. with:

    target_compile_features(osmv PUBLIC cxx_std_17)
    # broken: cxx_std_20
    

    When compiling under C++20, it breaks with (gisted, because it's a big error dump):

    https://gist.github.com/adamkewley/36c726f82afe89bffa087a5b9d02f50a

    Excerpt of that gist:

    /home/adam/Desktop/osc/master-RelWithDebInfo-install/include/simbody/simmath/internal/ContactGeometry.h:840:27: error: use of overloaded operator '==' is ambiguous (with operand types 'SimTK::ContactGeometryTypeId' and 'SimTK::ContactGeometryTypeId')
    {   return geo.getTypeId()==classTypeId(); }
               ~~~~~~~~~~~~~~~^ ~~~~~~~~~~~~~
    /home/adam/Desktop/osc/master-RelWithDebInfo-install/include/simbody/simmath/internal/ContactGeometry.h:44:1: note: candidate function
    SimTK_DEFINE_UNIQUE_INDEX_TYPE(ContactGeometryTypeId);
    ^
    /home/adam/Desktop/osc/master-RelWithDebInfo-install/include/simbody/SimTKcommon/internal/common.h:427:5: note: expanded from macro 'SimTK_DEFINE_UNIQUE_INDEX_TYPE'
        SimTK_DEFINE_AND_EXPORT_UNIQUE_LOCAL_INDEX_TYPE(,,,NAME)   \
        ^
    /home/adam/Desktop/osc/master-RelWithDebInfo-install/include/simbody/SimTKcommon/internal/common.h:459:10: note: expanded from macro 'SimTK_DEFINE_AND_EXPORT_UNIQUE_LOCAL_INDEX_TYPE'
        bool operator==(int  i) const {assert(isValidExtended() && isValidExtended(i)); return ix==i;}    \
             ^
    /home/adam/Desktop/osc/master-RelWithDebInfo-install/include/simbody/simmath/internal/ContactGeometry.h:44:1: note: candidate function (with reversed parameter order)
    /home/adam/Desktop/osc/master-RelWithDebInfo-install/include/simbody/SimTKcommon/internal/common.h:427:5: note: expanded from macro 'SimTK_DEFINE_UNIQUE_INDEX_TYPE'
        SimTK_DEFINE_AND_EXPORT_UNIQUE_LOCAL_INDEX_TYPE(,,,NAME)   \
        ^
    /home/adam/Desktop/osc/master-RelWithDebInfo-install/include/simbody/SimTKcommon/internal/common.h:459:10: note: expanded from macro 'SimTK_DEFINE_AND_EXPORT_UNIQUE_LOCAL_INDEX_TYPE'
        bool operator==(int  i) const {assert(isValidExtended() && isValidExtended(i)); return ix==i;}    \
    

    The error seems to be because C++20 adds the spaceship operator (clang implementation coverage is here, search 'Consistent comparison').

    Simbody (obviously) doesn't use this feature, but it seems to change the semantics of comparison operators such that they're now broken in Simbody. One quick fix that got rid of some of those errors was to add a comparison between the index type and itself, because (if I understand correctly) the index-type's current implementation relies on an implicit conversion to an int when comparing an index to its own type.

    However, that doesn't fix all of the errors because some of them seem to be due to a change in the semantics of comparison. C++20 seems to require that comparison is reversible. That is, that a == b is equivalent to b == a at the source level, and an ambiguity can be generated if a == b is possible but b == a is not (which might, when combined in weird ways with implicit conversion, be part of the issue here).

    Here's some related reading material:

    • Similar issue, different project: https://github.com/boostorg/date_time/issues/132
    • Overview of comparisons in C++20: https://brevzin.github.io/c++/2019/07/28/comparisons-cpp20/#reversing-primary-operators

    I don't currently have time to fix this, PR it, deal with reviews, etc. but might have time in the future. I figured it's best to document the behavior now rather than the issue being undocumented and everyone seperately having to figure out what the issue is.

    opened by adamkewley 1
  • Replace loop with explicit formula

    Replace loop with explicit formula

    Iterative calculation of the number of bins in Parallel2DExecutor can be replaced by an explicit formula.

    Test code:

    #include <cmath>
    #include <iostream>
    
    int main()
    {
            for (int nCpus = 2; nCpus < 513; nCpus++) {
                    int levels = 1;
                    while (1 << levels < nCpus)
                            levels++;
                    levels++;
                    int bins = 1 << levels;
    
                    int levelsNew = std::ceil(std::log2(nCpus)) + 1;
                    int binsNew = 1 << levelsNew;
                    if (bins != binsNew)
                            throw std::runtime_error(std::string("MISMATCH ") + std::to_string(bins) + " " + std::to_string(binsNew));
                    std::cout << nCpus << "(" << levels << ", " << bins << ") - " << "(" << levelsNew << ", " << binsNew << ")" << std::endl;
            }
    }
    

    This change is Reviewable

    opened by MadCatX 1
  • ParallelExecutor executes in multiple threads when it should not, causes access to invalid TLS

    ParallelExecutor executes in multiple threads when it should not, causes access to invalid TLS

    Hello everyone,

    I have been seeing an odd crash in some of molmodel unit tests which I eventually traced back to Simbody's ParallelExecutor running in multithreaded mode even when it should use the singlethreaded shortcut. The following conditions have to be met for the problem to occur:

    • A Parallel2DExecutor task is created.
    • The backing ParallelExecutor is set to use only one thread.
    • The computed problem is of such size that the last square created by Parallel2DExecutor is empty (= has zero size).

    This causes this condition: if (min(times, numMaxThreads) == 1) {

    to evaluate to false because times is 0 and ParallelExecutor then enters the multithreaded loop. Since the task's TLS has already been initialized to singlethreaded operation by previous iterations of the comptutation, finish() method of the task then tries to access the TLS of the worker thread instead of the main thread, causing a crash.

    Changing the respective check to if (min(times, numMaxThreads) <= 1) {

    should fix the issue.

    For the record, I used TestDuMMForces from molmodel test suite to debug this.

    I also wonder if there could be a "reverse" case of this problem. For instance, if the initial TriangleTask solution used only one thread but the subsequent SquareTasks were large enough for multithreaded processing. My analysis of the code suggests that this should not happen but I'm not sufficiently familiar with the code to think through all the possibilities.

    opened by MadCatX 8
  • Some examples segfault when compiled without the NDEBUG flag

    Some examples segfault when compiled without the NDEBUG flag

    I have successfully compiled the TheoJansenStrandbeest.cpp example (linux, gcc 10.1, simbody 3.7) but I get a segfault as soon as I launch it.

    Here is my gdb backtrace:

    0x0000555555563685 in SimTK::ListOfDependents::notePrerequisiteChange (this=0x5555555dafd8, stateImpl=...)
        at /usr/include/simbody/SimTKcommon/internal/StateImpl.h:2257
    2257	    for (auto ckey : m_dependents) {
    (gdb) backtrace 
    #0  0x0000555555563685 in SimTK::ListOfDependents::notePrerequisiteChange (this=0x5555555dafd8, stateImpl=...)
        at /usr/include/simbody/SimTKcommon/internal/StateImpl.h:2257
    #1  0x0000555555562b3d in SimTK::CacheEntryInfo::invalidate (this=0x5555555daf98, stateImpl=...)
        at /usr/include/simbody/SimTKcommon/internal/StateImpl.h:331
    #2  0x00005555555636b6 in SimTK::ListOfDependents::notePrerequisiteChange (this=0x55555558b2a0, stateImpl=...)
        at /usr/include/simbody/SimTKcommon/internal/StateImpl.h:2260
    #3  0x00007ffff7edeec5 in SimTK::StateImpl::advanceSystemToStage(SimTK::Stage) const ()
       from /usr/lib/libSimTKcommon.so.3.7
    #4  0x00007ffff7eee8d7 in SimTK::System::Guts::realizeModel(SimTK::State&) const ()
       from /usr/lib/libSimTKcommon.so.3.7
    #5  0x00007ffff7eefe75 in SimTK::System::Guts::realizeTopology() const () from /usr/lib/libSimTKcommon.so.3.7
    #6  0x000055555555dd20 in main () at TheoJansenStrandbeest.cpp:208
    
    opened by dpellegr 4
  • Top Spinner Example (demo of Ball mobilizer showing precession and nutation)

    Top Spinner Example (demo of Ball mobilizer showing precession and nutation)

    Hello! I wrote this example to train myself and I thought that it could be useful to others. Feel free to do anything you want with it.


    This change is Reviewable

    opened by dpellegr 3
  • Test template in one header

    Test template in one header

    Hi, Would it be great to regroup all test template in one header file other than declare in each test files ?

    opened by tomlogan501 3
  • Ubuntu 16.04 simbody-visualizer ExamplePendulum error

    Ubuntu 16.04 simbody-visualizer ExamplePendulum error

    Ubuntu 16.04 builded successful

    when run ./ExamplePendulum. get a Error:

    [email protected]:~/simbody-source/build$ ./ExamplePendulum
    Reactions @M: ~[~[~[24.7279,30.7279,-0.2],~[-33.76,33.56,-12]] ~[~[6.36396,9.36396,0],~[-16.88,16.78,-6]] ~[~[6.66134e-16,3,0],~[-7.92,5.94,-3]] ~[~[-1.18329e-30,-7.88861e-31,-4.44089e-16],~[0,0,0]] ~[~[-1.32625e-30,1.31634e-30,1.23252e-15],~[1.77636e-17,1.23252e-15,-1.03042e-30]]]
    Reactions @F: ~[~[~[-24.7279,-30.7279,0.2],~[33.76,-33.56,12]] ~[~[-6.36396,-9.36396,-0],~[16.88,-16.78,6]] ~[~[-6.66134e-16,-3,-0],~[7.92,-5.94,3]] ~[~[1.18329e-30,7.88861e-31,4.44089e-16],~[-0,-0,-0]] ~[~[1.32625e-30,-1.31634e-30,-1.23252e-15],~[-1.77636e-17,-1.23252e-15,1.03042e-30]]]
    norm of difference: 0
    Pin mobilizer reaction forces:
    FB_G=~[~[2.12132,5.12132,0.0707107],~[-16.88,16.78,-6]] ~[~[0,0,-5.94],~[-7.92,5.94,-3]]
    Constraint reaction forces (should be the same):
    FC_G=~[~[2.12132,5.12132,0.0707107],~[-16.88,16.78,-6]] ~[~[-2.66454e-15,3.10862e-15,-5.94],~[-7.92,5.94,-3]]
    Hit ENTER to run a short simulation ...simbody-visualizer listenerThread: unrecoverable error:
    SimTK Exception thrown at simbody-visualizer.cpp:2048:
      Error detected by Simbody method simbody-visualizer: An attempt to read() 1 bytes from pipe 3 failed with errno=4 (Interrupted system call).
      (Required condition 'retval!=-1' was not met.)
    
    
    FM_G=~[~[~[29.3755,27.4883,-4.92352],~[-40.9974,36.0737,-12]] ~[~[8.68779,7.74405,2.66454e-15],~[-20.4986,18.0368,-6]] ~[~[2.86849,0.878508,0],~[-8.58479,9.29639,-3]] ~[~[-1.69336e-30,-2.81945e-30,-2.87144e-16],~[-4.44089e-16,0,7.88861e-31]] ~[~[-6.28915e-30,-1.91384e-30,2.69026e-16],~[1.38336e-15,9.95069e-16,5.31156e-30]]]
    [email protected]:~/simbody-source/build$ 
    
    opened by freeyyc 7
  • Use CMake's ${CMAKE_CURRENT_SOURCE_DIR} instead

    Use CMake's ${CMAKE_CURRENT_SOURCE_DIR} instead

    Hey there! (TL;DR: What needs to be done to fix this is on the bottom.)

    CMake offers two mechanisms to fetch dependencies on the fly. The older ExternalProject and the newer FetchContent.

    The way latter works is really simple:

    1. Declare dependency
    2. Check if satisfied, if not, download it
    3. Add subdirectory

    The only catch comes with how a project specifies it's file paths. In my newer projects I use ${CMAKE_CURRENT_SOURCE_DIR}/source.cc, which causes CMake to search for the file relative to the current CMakeLists that declares the file.

    Simbody, however, uses CMAKE_SOURCE_DIR instead, which relates the paths to the top-level CMake file causing FetchContent Setups to subsequently fail on configure.

    Solution: Replace every path to use ${CMAKE_CURRENT_SOURCE_DIR}, so that users can easily pull in this project using the FetchContent API.

    This is especially neat for users that don't have admin priviliges to install/run conda. Additionally I might have postgraduates checking out my repository, who I don't want to bother with getting a project's dependency straight.

    Below is a sample of how one would use the FetchContent API.

    cmake_minimum_required(VERSION 3.11)
    project(sample)
    
    FetchContent_Declare(
        simbody
        GIT_REPOSITORY https://github.com/simbody/simbody.git
        GIT_TAG "Simbody-3.7"
    )
    
    FetchContent_GetProperties(simbody)
    if(NOT simbody_POPULATED)
        FetchContent_Populate(simbody)
        add_subdirectory(${simbody_SOURCE_DIR})
    endif()
    
    add_executable(
        sample_app
        "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
    )
    
    target_link_libraries(
        sample_app
        PRIVATE
        SimTK
    )
    
    opened by HiImJulien 9
  • Allow tweaking optimizer parameters in Assembler class

    Allow tweaking optimizer parameters in Assembler class

    While using OpenSim's InverseKinematicsSolver, we noticed that we could get a huge performance boost without any major loss in solving quality by changing the limited memory history parameter in Assembler class:

    https://github.com/simbody/simbody/blob/187d22c690359677912f03c0490049f878d36c72/Simbody/src/Assembler.cpp#L767

    The default is hardcoded to 50, while we've found 3 to be sufficient for our case (we use the LBFGS-B optimizer). This is mainly helpful in realtime, since it allows us to run with a higher accuracy (lower accuracy tends to lead to jumpiness when doing slow movements, since the solver does an early out if the previous solution is still "good enough"), but it also on average halves the offline processing time which is quite nice since this usually takes a while. The comment here states that 50 is a compromise value which makes sense, though having some way to modify the value (and other relevant parameters, perhaps even optimizer type) and tweak the performance for specific use cases without patching the library would be useful.

    opened by Henrik-Norgren 1
Releases(Simbody-3.7)
  • Simbody-3.7(Dec 8, 2019)

    This release of Simbody includes a smoothed compliant contact model and a few bug fixes.

    • The new SmoothSphereHalfSpaceForce provides a continuous and differentiable contact model, ideal for use with gradient-based optimization algorithms (PR #667).
    • Fixes a memory issue with CPodes (PR #642).
    • The new CMake variable INSTALL_DOCS controls whether docs are installed (PR #655).
    • Fixes a bug with calculating constraint acceleration errors (PR #670).
    • Fixes Pathname::getThisExecutablePath() for FreeBSD (PR #672).
    • Fixes simbody-visualizer on macOS 10.15 Catalina when using high-DPI screens. Now, simbody-visualizer is an app bundle (simbody-visualizer.app) on Mac (PR #676).
    Source code(tar.gz)
    Source code(zip)
  • Simbody-3.6.1(Jun 11, 2018)

    This patch release is 3.6 with minor changes:

    • Fixed a bug wherein a program may crash when using the visualizer if the visualizer window was closed manually.
    Source code(tar.gz)
    Source code(zip)
  • Simbody-3.6(Feb 21, 2018)

    This is the first release of Simbody that requires C++11, as much of the code base now takes advantage of C++11 features. The MinGW compiler is now supported, providing an alternative to Visual C++ on Windows. This release fixes a bug in MultibodyGraphMaker where massless bodies were handled incorrectly. The state's caching mechanism is now more fine-grained ("stage versions"), though this change should not affect users in this release.

    If upgrading from 3.5, you may need to make minor changes to downstream code:

    • SimTK::ClonePtr's equality comparison operator previously checked equality between the underlying objects, but now checks equality between pointers.
    • Support for long double has been removed.
    • Some methods in SimTK::ClonePtr and SimTK::ReferencePtr have been renamed.
    • SimTK::Xml was changed from a class to a namespace.

    Where possible, we have deprecated previous methods rather than removing them completely.

    There were numerous smaller improvements to Simbody since the previous release, in build and installation, documentation, performance, bug fixes, and small enhancements. For details, see CHANGELOG.md.

    For installation instructions, see README.md. For API documentation, see https://simbody.github.io/simbody-3.6-doxygen/api/. For information on contributing to the Simbody project, see CONTRIBUTING.md.

    If you have questions or problems, please post to the Simbody Forum.

    Source code(tar.gz)
    Source code(zip)
  • Simbody-3.5.4(Oct 1, 2016)

  • Simbody-3.5.3(Jun 15, 2015)

    This patch release is 3.5.2 with minor changes:

    • The source will now compile on Windows with Visual C++ 2015. It has also been tested with 2013 and should still work with 2010.

    There are also bug fixes for two relatively obscure problems:

    • SpatialInertia::shift() and calcCompositeBodyInertias() were not correct for non-zero center of mass offsets (issue #334).
    • VectorIterator was causing unnecessary copying during mesh handling (issue #349).
    Source code(tar.gz)
    Source code(zip)
  • Simbody-3.5.2(May 15, 2015)

    Same as 3.5.1 except on 64 bit Windows which now has a patched version of Lapack that addresses an obscure error handling problem that caused trouble for some OpenSim users. This release is intended to support OpenSim; there is no reason for Simbody users to upgrade from 3.5.1 although it is harmless to do so.

    The change here is a patch to Lapack 3.4.2 (64 bit) to fix the bug discussed in Issue #177 and PR #342. There were two functions where convergence failures incorrectly caused an abort (XERBLA in Lapack-speak) that bubbled up to trash an IpOpt optimization that should have recovered. See discussion on Lapack forum: http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=13&t=4586. The patched Lapack DLL is binary compatible with the previous one, same functions and ordinals.

    Source code(tar.gz)
    Source code(zip)
  • Simbody-3.5.1(Dec 31, 2014)

    (This patch release fixed an installation problem but is otherwise identical to 3.5.)

    Release 3.5 focused primarily on infrastructure for and prototyping of rigid contact and impact, and the development of examples showing how to perform task space control using Simbody. These two projects were supported by our DARPA research subcontract with Open Source Robotics Foundation, and were integrated with Gazebo. Further development for rigid contact is required for smooth integration into Simbody; this is planned for Simbody 4.0 and only the bravest among you should attempt to use rigid contact before then. The task space control examples TaskSpaceControl-UR10 and TaskSpaceControl-Atlas can be found in the Simbody examples directory.

    Chris Dembia integrated Nikolaus Hansen's Covariant Matrix Adaptation Evolution Strategy (CMA-ES) global optimizer into Simbody's existing Optimizer class framework, and implemented a multithreading capability for it. This is ready to use and we would like feedback. Thanks to Nikolaus Hansen for allowing us to include this in Simbody under the Apache 2.0 license.

    There were numerous smaller improvements to Simbody since the previous release, in build and installation, documentation, performance, bug fixes, and small enhancements. There are no known incompatibilities with previous release 3.4.1 and we highly recommend that you upgrade. For details, see CHANGELOG.md.

    For installation instructions, see README.md. For information on contributing to the Simbody project, see CONTRIBUTING.md.

    If you have questions or problems, please post to the Simbody Forum.

    Source code(tar.gz)
    Source code(zip)
  • Simbody-3.4.1(Mar 31, 2014)

    This release is functionally similar to 3.3 but has had extensive changes to build and install, mostly affecting Linux and OSX systems. The behavior should now conform better to standards on those platforms, thanks to the hard work of @scpeters and @j-rivero at Open Source Robotics Foundation and @chrisdembia at Stanford.

    There are a number of bug fixes but they will not be noticed by most users. The most numerically significant is that SimbodyMatterSubsystem::getTotalCentrifugalForces() now returns the correct result (see issue #112). There are several small new features and enhancements but they were targeted narrowly at specific use cases and are likely to affect only the people who were involved in their development.

    If you run into problems with the build changes, please post to the Simbody forum.

    Source code(tar.gz)
    Source code(zip)
  • Simbody-3.3.1(Jan 21, 2014)

    This is the first release built for use in Open Source Robotic Foundation's Gazebo robot simulator and is also the version of Simbody that ships with OpenSim 3.2. It incorporates many fixes and enhancements prompted by the integration effort with OSRF, and a new Debian builder for smooth incorporation into the Gazebo build.

    This is also a stable general purpose Simbody build.

    Version 3.3.1 is a minor patch to 3.3 to fix some problems compiling with Visual Studio 12 (2013) on Windows. Otherwise it is unchanged from 3.3.

    Source code(tar.gz)
    Source code(zip)
  • Simbody-3.1(Aug 16, 2013)

Owner
Simbody Project
High-accuracy C++ multibody dynamics/physics library for scientific & engineering simulation of biomechanical and mechanical systems.
Simbody Project
Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

Bullet Physics SDK This is the official C++ source code repository of the Bullet Physics SDK: real-time collision detection and multi-physics simulati

Bullet Physics SDK 7.6k Feb 19, 2021
C++ library for multi-physics simulation

Project CHRONO Project Chrono represents a community effort aimed at producing a physics-based modelling and simulation infrastructure based on a plat

null 987 Feb 18, 2021
A fast and lightweight 2D game physics library.

NEW IN CHIPMUNK 7 Chipmunk 7 is complete and now includes the ARM NEON optimizations, the autogeometry code, and the mulithreaded solver. The latest p

Scott Lembcke 1.6k Feb 19, 2021
Box2D is a 2D physics engine for games

Build Status Box2D Box2D is a 2D physics engine for games. Contributing Please do not submit pull requests with new features or core library changes.

Erin Catto 4.7k Feb 19, 2021
A modern C++11 quantum computing library

Quantum++ Version 2.6 - 9 January 2021 Build status: Chat (questions/issues) About Quantum++ is a modern C++11 general purpose quantum computing libra

softwareQ Inc. 272 Feb 19, 2021
Real-time multi-physics simulation with an emphasis on medical simulation.

Introduction SOFA is an open source framework primarily targeted at real-time simulation, with an emphasis on medical simulation. It is mainly intende

SOFA Framework 422 Feb 19, 2021
NVIDIA PhysX SDK 3.4

NVIDIA PhysX SDK 3.4 Copyright (c) 2018 NVIDIA Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without mo

NVIDIA GameWorks 2.2k Feb 18, 2021
2D physics engine for games

LiquidFun Version 1.1.0 Welcome to LiquidFun! LiquidFun is a 2D physics engine for games. Go to our landing page to browse our documentation and see s

Google 4.2k Feb 18, 2021
Openframework wrapper for box2d

ofxBox2d Introduction This is a simple wrapper for box2d using Openframeworks. The examples below are still in progressive, but should be stable for t

Vanderlin 298 Dec 14, 2020