Biomech-Sim-Toolbox 1
Toolbox for movement simulation and analysis
Loading...
Searching...
No Matches
gait2dc.m File Reference

Matlab script documenting the use of the MEX function gait2dc.mex32. More...

Detailed Description

Matlab script documenting the use of the MEX function gait2dc.mex32.

This file documents the use of the MEX function gait2dc.mex32. The musculoskeletal model is documented in the file gait2dc_reference. The MEX function can be used to perform several functions with the model.

Size of the model
Label Description
Ndof Number of kinematic degrees of freedom (is 9 for this model)
Nmuscles Number of muscles (16)
Ncontacts Number of contact points defined in the XLS file
Nstates Number of state variables: 2*Ndof * 2*Nmuscles + 4*Ncontacts
NRstick Number of right side stick figure points: 5 + Ncontacts (trunk, hip, Rknee, Rankle, Right contact points, and Rankle again)
NLstick Number of left side stick figure points: 4 + Ncontacts (hip, Lknee, Lankle, Left contact points, and Lankle again)


The MEX function can be used in several ways.

par = readxls('gait2dc_par.xls);
[xneutral] = gait2d('Initialize', par)

This initializes the model with a set of parameters. This is required before anything is done with the model. The par matrix can be obtained by reading an Excel file. The Excel file also contains labels to facilitate human reading and editing.

Parameters
parMatrix with model parameters, formatted using gait2dc_par.xls
Return values
xneutralModel state vector (Nstates x 1) for a neutral state where the model is in free fall with feet not quite touching the ground, but otherwise close to static equilibrium.


[f, dfdx, dfdxdot, dfdu, dfdM] = gait2dc('Dynamics',x,xdot,u,M)
double f[4]
Definition: contact_2d_raw.c:20

Implicit differential equation for 2D musculoskeletal model : f(x,dx/dt,u,M) = 0

Parameters
xState of the model (Nstates x 1)
xdotState derivatives (Nstates x 1)
uNeural excitations for the muscles (Nmuscles x 1)
M(optional) Extra joint moments (Njoints x 1), for instance from prosthetic device
Return values
fDynamic residuals (Nstates x 1), wil be zero when inputs satisfy system dynamics
dfdx(optional) Jacobian matrix df/dx (Nstates x Nstates)
dfdxdot(optional) Jacobian matrix df/dxdot (Nstates x Nstates)
dfdu(optional) Jacobian matrix df/du (Nstates x Nmuscles)
dfdM(optional) Jacobian matrix df/dM (Nstates x Njoints)

The last four outputs are optional and some computation time is saved if you do not request all of them.


[grf, dgrfdx] = gait2dc('GRF', x)

This returns the ground reaction forces for the system in state x

Return values
grf6 x 1 matrix, Right Fx,Fy,Mz Left Fx,Fy,Mz
dgrfdx(optional) 6 x Nstates matrix, derivatives of grf with respect to state x


[right,left,rfoot,lfoot] = gait2dc('Stick', x)

This returns data for a stick figure, for the system in state x

Return values
rightNL x 2 matrix, containing x and y coordinates for right side stick figure
leftNR x 2 matrix, containing x and y coordinates for left side stick figure
rfoot[optional] NRf x 2 matrix, x and y coordinates of the right foot without deformation
lfoot[optional] NLf x 2 matrix, x and y coordinates of the left foot without deformation


[forces, dFdx] = gait2dc('Muscleforces', x)

This returns muscle forces, for the system in state x

Return values
forces16 x 1 column vector with muscle forces (N), in same order as muscle table in gait2d_par.xls
dFdx16 x 66 matrix with the derivates of the muscle