Giter VIP home page Giter VIP logo

opensimad's Introduction

OpenSimAD

Windows libraries for OpenSimAD - OpenSim with support for Algorithmic Differentiation.

How to generate an external function for use with CasADi?

OpenSimAD is used to formulate trajectory optimization problems with OpenSim musculoskeletal models. To leverage the benefits of algorithmic differentiation, we use CasADi external functions. In our case, the external functions typically take as inputs the multi-body model states (joint positions and speeds) and controls (join accelerations) and return the joint torques after solving inverse dynamics. The external functions can then be called when formulating trajectory optimization problems (e.g., https://github.com/antoinefalisse/3dpredictsim and https://github.com/antoinefalisse/predictsim_mtp).

Here we provide code and examples to generate external functions automatically given an OpenSim musculoskeletal model (.osim file).

Install requirements (Windows)

  • Third-party software:
    • CMake (make sure cmake.exe is in your path)
    • Visual studio (tested with Visual Studio 2017 Community only)
    • Anaconda
  • conda environment:
    • Open an Anaconda prompt
    • Create environment: conda create -n opensimAD pip spyder python=3.8
    • Activate environment: conda activate opensimAD
    • Navigate to the folder where you want to download the code: eg. cd Documents
    • Download code: git clone https://github.com/antoinefalisse/opensimAD.git
    • Navigate to the folder: cd opensimAD
    • Install required packages: python -m pip install -r requirements.txt
    • Install OpenSim by following the instructions here

Example

  • run main.py
    • You should get as output a few files in the example folder. Among them: F.cpp, F.dll, and F_map.npy. The .cpp file contains the source code of the external function, the .dll file is the dynamically linked library that can be called when formulating your trajectory optimization problem, the .npy file is a dictionnary that describes the outputs of the external function (names and indices).
    • More details in the comments of main.py about what inputs are necessary and optional.

Limitations

  • Not all OpenSim models are supported:
    • Your model should not have locked joints. Please replace them with weld joints (locked joints would technically require having kinematic constraints, which is possible but makes the problem more complicated).
    • Constraints will be ignored (eg, coupling constraints).
    • SimmSplines are not supported, as their implementation in OpenSim is not really compatible with algorithmic differentiation. See how we replaced the splines of the LaiArnold_modifed model with polynomials.
  • OpenSimAD does not support all features of OpenSim. Make sure you verify what you are doing. We have only used OpenSimAD for specific applications.

Tutorial

  • TODO: You can find here a tutorial describing how to generate a predictive simulation of walking. The tutorial describes all the steps required, including the use of OpenSimAD to general external functions for use when formulating the trajectory optimization problem underlying the predictive simulation.

Citation

Please cite this paper in your publications if OpenSimAD helps your research:

  • Falisse A, Serrancolí G, et al. (2019) Algorithmic differentiation improves the computational efficiency of OpenSim-based trajectory optimization of human movement. PLoS ONE 14(10): e0217730. https://doi.org/10.1371/journal.pone.0217730

Please cite this paper in your publications if you used OpenSimAD for simulations of human walking:

  • Falisse A, et al. (2019) Rapid predictive simulations with complex musculoskeletal models suggest that diverse healthy and pathological human gaits can emerge from similar control strategies. J. R. Soc. Interface.162019040220190402. http://doi.org/10.1098/rsif.2019.0402

Source code

The OpenSimAD libraries were compiled from here.

opensimad's People

Contributors

antoinefalisse avatar maartenafschrift avatar suhlrich avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.