@author M.Millard
@date Oct. 2013

Code to accompany:

[1] M.Millard and A.Kecskemethy (2013). A 3D Foot-Ground Model using Disk Contacts.
Proceedings of the Second Conference on Interdisciplinary Applications in 
Kinematics, September 9-11, 2013. Lima, Peru

================================================================================
This code sample contains two directories
  1. ControlledGrabnerDisk:
     A forward-dynamic simulation of a Grabner disk element that is controlled
     to rise from being flat on the ground to being rotation by 90 degrees to 
     the surface. After the simulation, the kinematics of the rotation are post
     processed to extract the radius of curvature information. See below for 
     details.

  2. FussKontactModel:
     Contains the code required to validate the disk-based 3D foot contact 
     model against the trials shown in the paper, and also the trials shown
     during the IAK presentation. See below for details
  
  
If you want to generate the VRML animations of the simulations, you 
will need to:
             1. Download and install the latest version of Java Runtime
             2. Download Solvere4D from SourceForge or Git. I wrote this program
                specificially for generating 3D animations of multibody mechanisms
                and it is available free of charge.
             3. Edit 'compileWRL.bat' in ControlledGrabnerDisk/animation so that
                the folder to Solvere4D and also for the file
                ControlledGrabnerDisk\animation\disk.s4d are correct for your 
                machine.
             4. When all is working a 3D animation will be generated in the file 
                ControlledGrabnerDisk\animation\disk.wrl . You can view this
                file by downloading BSContact (at least the trial version) from
                Bitmanagement.
             5. The blue circle at the bottom of the screen is play/pause. The 
                arrows are used to speed up or slow down the rate of play, and
                the slider can be grabbed and moved to access specific parts of
                the video.
                  
================================================================================

================================================================================     
  1. ControlledGrabnerDisk:     
     main.m: will run a forward simulation and produce sim_rotateDisk_c#.mat
             where # is the parameter C in Eqn. 2 of [1]. 
     main_curvature.m: will generate publication-quality plots of the curvature
                       of the path of the disk during a rotation simulation.
                       At the moment plots are generated for C=1 (gray), 
                       and C=10 (black).
             
     These two main functions depend on several other files which may be of 
     interest to you:
     
     ->gen_vParam.m: 
        where the parameter 'c', and other model parameters are set.
     ->calc_xdot.m:
        where the state derivatives of a 3D body at the center of a Grabner
        disk are computed. Note that a control torque is applied to the 
        disk so that it rotates about the floor in a sticking (no slipping)
        condition.
     -> xDotMex_ControlledDisk.c
        a c-code function of the state equations of a 3D body with a Grabner
        disk attached at the center of mass, and with an applied wrench also
        to the center of mass. This optimized code was generated using MapleSim,
        which is a product of MapleSoft.
     -> GrabnerDiskContact.mpl & GrabnerDiskContactPring.mpl
        Maple functions that compute the contact forces and torques applied by
        the Grabner disk to the center of the disk.        
================================================================================

================================================================================
  2. FussKontactModel:
        main_optimizeFoot.m: 
            will run a forward simulation of the foot executing the walking and 
            foot rotation task that are discussed in the paper. The walking 
            simulation requires 1 minute of time, while the rotation simulation 
            requires about 10 minutes of time on a new machine 
            (my laptop has an i7). Note that there have been improvements to the
            controller and to the way the initial conditions are computed since
            the publication of the IAK paper. These improvements are most
            noticeable in the COP plot of fig_Walking01.pdf.
                                    
            The output of this function is a capture of the simulation data
            and the animation
            
            modeldata/limaIAK/opt_Walking01.mat
            modeldata/limaIAK/opt_Rotations10.mat
            modeldata/limaIAK/opt_Walking01.wrl
            modeldata/limaIAK/opt_Rotations10.wrl
        
            *Make sure you update the 3 *.bat files in the animation folder
             so that the paths are correct for your machine - else you will
             not get any animations.
        
            Files of interest
            -> paramList.m: contains the list of model parameters
            -> refineInitialConditions.m: computes the initial conditions of 
                 model that most closely match the experimental data. 
            ->calcXdot.m: computes the control wrench and computes the state
                          derivative of the 3D foot contact model.
            ->xDotMex.c : The C-code mex function that computes the state 
                         derivative of the 3D foot contact model. This 
                         optimized C-code was generated using MapleSim, which
                         is a product of MapleSoft.
        
        modeldata/getnPlots.m
            Will generate the plots that appear in the paper [1]. These plots
            are stored in
            
            modeldata/limaIAK/fig_Walking01.pdf
            modeldata/limaIAK/fig_Rotations10.pdf
================================================================================            
            