Code for "Synthesis of Biologically Realistic Human Motion Using Joint Torque Actuation", SIGGRAPH 2019
https://arxiv.org/abs/1904.13041
To run data generation, you will need a Matlab environment with OpenSim and IPOPT packages installed:
- Install the Opensim library and set up its Matlab scripting environment (The current version of code uses OpenSim 3.3, which is only supported on Windows. Consider installing a Windows 7 virtual machine. Give the VM multiple cores of CPU.):
1.1 Download and install OpenSim 3.3. Installation Guide: https://simtk-confluence.stanford.edu:8443/display/OpenSim33/Installing+OpenSim
1.2 Configure Matlab Scripting Environment: https://simtk-confluence.stanford.edu:8443/display/OpenSim33/Scripting+with+Matlab
- Install IPOPT package in Matlab: Download this file: www.coin-or.org/download/binary/Ipopt/Ipopt-3.11.3-win32win64-matlabmexfiles.zip , unzip it and place the folder to some good place, open Matlab, run addpath('D:/where-you-put-ipopt-folder') and then savepath.
To run Neural Net training, you will need a Python environment with keras (tensorflow), numpy, and scipy installed.
Train NN to approximate R:
- Run MAIN_2D_R or MAIN_3D_R (MATLAB) to generate training data
- Run train_leg_2D_R or train_leg_3D_R (Python) to train NN using the generated data
- If to be used in Trajectory Optimization in Matlab, run keras_output_weight.py to translate trained model in Step 2 in Python to a Matlab readable NN model.
Train NN to approximate E:
- Run rej_sample_R4E_2D or rej_sample_R4E_3D (Python) to sample valid torque vectors. (Note: this is different from the sampling method in the Siggraph paper. This new method is much faster and has better sample distribution. The effective number of samples remain similar.)
- Run MAIN_2D_E or MAIN_3D_E (MATLAB) to calculate the ground truth E values for the sampled vectors. They are the training data (where E are the labels, i.e. y_train).
- Run train_leg_2D_E or train_leg_3D_E (Python) to train NN using the generated data
- If to be used in Trajectory Optimization in Matlab, run keras_output_weight.py to translate trained model in Step 3 in Python to a Matlab readable NN model.
Some MATLAB examples of how to use learned R and E in trajectory optimization problems are included:
- Jumping: run Jump_box_and_lr/JumperLeftRevoluteFoot_DC.m with addNN = false (BOX baseline) or addNN = true (Learned R); run Jump_MTU/JumperLeftRevoluteFootStatic_DC.m for the MTU baseline.
- Max Swing: run Swing_box_and_lr/Swing_DC.m with addNN = false (BOX baseline) or addNN = true (Learned R); run Swing_MTU/SwingStaticMuscle_DC.m for the MTU baseline.
- Fix-distance Swing: run Swing_fix_dist_lronly_and_lrle/Swing_DC.m with useMeta = false (Learned R only) or useMeta = true (Learned R and E).
The generated trajectories (joint angles in .sto file) can be visualized using OpenSim desktop application.