This is the material for a tutorial on analyzing multibody dynamics with scientific Python tools. It was first given as "Simulation and Control of Biomechanical Systems with Python" at the Midwest American Society of Biomechanics Regional meeting on March 4th, 2014 in Akron, Ohio. Modified versions have subsequently been given at PYCON2014, SCIPY2014, SCIPY2015, and SCIPY 2016.
The tutorial covers these main topics:
- Symbolic derivation of equations of motion for multibody systems.
- Numerical simulation of the resulting system.
- 3D visualization of the motion of the system.
- Optimal feedback control for stabilization.
The attendees will be exposed to various functionality of these Python tools:
The tutorial can be run locally or through the Binder service:
- PYCON 2014: https://youtu.be/IoMR-ESzqw8
- SCIPY 2014: https://youtu.be/lWbeuDwYVto, https://youtu.be/1-KqRvNX0po
- SCIPY 2015: https://youtu.be/mdo2NYtA-xY
- SCIPY 2016: https://youtu.be/r4piIKV4sDw
All materials herein are licensed under Create Commons Attribution 4.0.
A new version of the tutorial is typically created each time the tutorial is given to incorporate feedback from the attendees and for software updates. These versions can be downloaded from:
The tutorial will go through the PyDy workflow in small steps. At the end the students should have a working 3-link 2D inverted pendulum model of a human that can be used for balancing studies. The free body diagram of the model is shown below:
To run these notebooks the SciPy Stack is required. To obtain the needed packages, we are recommending users install the Anaconda Scientific Python Distribution which contains most of the necessary software and eases cross platform installation. You should install Anaconda to your home directory. The installation directory can simply be deleted when the tutorial is over if you no longer want the files.
First, download and install Anaconda for your operating system. After Anaconda is installed, update various packages to the latest versions by issuing this command in a terminal:
$ conda update numpy scipy sympy matplotlib notebook ipywidgets
Now install the latest PyDy with:
$ conda install -c conda-forge pydy
This is only required if you want to run the tutorial without internet access.
$ conda install mathjax
If you want to see the 3D visualizations you must use a WebGL compliant browser. Visit http://get.webgl.org/ to see if your current browser supports WebGL. If not, you will need to upgrade or install another browser. Visit http://caniuse.com/webgl to choose a suitable browser. We've only confirmed the following:
Latest versions of Firefox and Chrome work.
Latest version Firefox works.
Latest version of Chrome works and IE 11 works.
We know that some OS browser combinations do not work. See pydy/pydy#36 for more details.
Either download the latest zipped tutorial materials from:
Or download the specific release for your conference from:
and then extract the zip file.
From the terminal, navigate to the extracted tutorial directory, for example:
$ cd /home/username/pydy-tutorial-human-standing
To make sure your software environment is correctly setup, run the check_env.py script in a terminal with:
$ python check_env.py
If no errors are returned, then you've correctly installed the software and can run the tutorial. If errors appear, then install or upgrade the software as needed.
Open a terminal window in the
notebooks directory and type:
$ cd notebooks $ ipython notebook
Your web browser should open and you see a list of all the notebooks and can click to open them and execute.
These are the notebooks for the tutorial.
- [15 min] n00_python_intro.ipynb
- [14 min] n01_dynamics_overview.ipynb
- [ 4 min] n02_problem_introduction.ipynb
- [39 min] n03_kinematics.ipynb
- [18 min] n04_inertia.ipynb
- [25 min] n05_kinetics.ipynb
- [25 min] n06_equations_of_motion.ipynb
- [32 min] n07_simulation.ipynb
- [25 min] n08_visualization.ipynb
- [28 min] n09_control.ipynb