Biomech-Sim-Toolbox 1
Toolbox for movement simulation and analysis
|
The class describes the Gait3d model. More...
Public Member Functions | |
function | extractControl (in obj, in type, in controlname) |
Function to obtain index of contol with a specific type (and name) | |
function | extractState (in obj, in type, in statename) |
Function to obtain index of state with a specific type (and name) | |
function | Gait3d (in opensimfile) |
Constructor setting default Gait3d object. | |
function | getCoP (in obj, in grf) |
Function to calculate the center of pressure. | |
function | getDynamics (in obj, in x, in xdot, in u) |
Function computing implicit differential equation for 3D musculoskeletal model. | |
function | getErate_bhargava (in obj, in F_ce, in stim, in act, in l_ce, in v_ce, in t_stim) |
Model function to calculate the energy rate of a single time step using Bhargava et al. | |
function | getErate_Houdijk (in obj, in F_ce, in act, in l_ce, in v_ce) |
Model function to calculate the energy rate of a single time. | |
function | getErate_Lichtwark (in obj, in F_ce, in act, in l_ce, in v_ce, in t_stim) |
Model function to calculate the energy rate of a single time step using a continuous version of Lichtwark & Wilson's model. | |
function | getErate_margaria (in obj, in F_ce, in v_ce) |
Model function to calculate the energy rate of a single time step using Margaria's model. | |
function | getErate_Minetti (in obj, in act, in v_ce) |
Model function to calculate the energy rate of a single time. | |
function | getErate_uchida (in obj, in F_ce, in stim, in act, in l_ce, in v_ce) |
Model function to calculate the energy rate of a single time. | |
function | getErate_Umberger (in obj, in F_ce, in stim, in act, in l_ce, in v_ce) |
Model function to calculate the energy rate of a single time step with Umberger et al. | |
function | getEratec_bhargava (in obj, in F_ce, in stim, in act, in l_ce, in v_ce, in dFdx, in dFdxdot, in epsilon) |
Model function to calculate the energy rate of a single time step using a continuous version of Bhargava et al. | |
function | getEratec_Houdijk (in obj, in F_ce, in act, in l_ce, in v_ce, in dFdx, in dFdxdot, in epsilon) |
Model function to calculate the energy rate of a single time step using a continuous version of Houdijk et al. | |
function | getEratec_Lichtwark (in obj, in F_ce, in act, in l_ce, in v_ce, in dFdx, in dFdxdot, in epsilon) |
Model function to calculate the energy rate of a single time step using a continuous version of Lichtwark & Wilson's model. | |
function | getEratec_margaria (in obj, in F_ce, in v_ce, in dFdx, in dFdxdot, in epsilon) |
Model function to calculate the energy rate of a single time step using a continuous version of Margaria's model. | |
function | getEratec_Minetti (in obj, in act, in v_ce) |
Model function to calculate the energy rate of a single time step using Minetti's model. | |
function | getEratec_umberger (in obj, in F_ce, in stim, in act, in l_ce, in v_ce, in dFdx, in dFdxdot, in epsilon) |
Model function to calculate the energy rate of a single time step with the continuous version of Umberger et al. | |
function | getFkin (in obj, in q, in qdot) |
Function returns position and orientation of body segments, for the system in position q. | |
function | getGRF (in obj, in x) |
Function returns the ground reaction forces for the system in state x. | |
function | getJointmoments (in obj, in x, in u) |
Function returns joint moments, for the system in state x. | |
function | getLCE (in obj, in x) |
Function returns length of contractile element, for the system in state x. | |
function | getLdotCE (in obj, in xdot) |
Function returns length change of contractile element, for the system in state x. | |
function | getMetabolicRate_pernode (in obj, in x, in xdot, in u, in t_stim, in name, in getCont, in epsilon, in exponent) |
Model function to calculate metabolic cost of a movement. | |
function | getMuscleCEforces (in obj, in x, in xdot) |
Function returning muscle forces of CE for the system in state x. | |
function | getMuscleCEpower (in obj, in x, in xdot) |
Function returns power generated by muscle contractile elements, for the system in state x. | |
function | getMuscleforces (in obj, in x) |
Function returns muscle forces, for the system in state x. | |
function | getPassiveJointmoments (in obj, in x) |
Function returns passive joint moments, for the system in state x. | |
function | setbodymass (in obj, in bodymass) |
Function to set body mass, does not influence the. | |
function | setMuscles (in obj, in muscles) |
Function to set the muscles table. | |
function | setSegmentMass (in obj, in segmentName, in segmentMass) |
Function to set segment mass. | |
function | setSegments (in obj, in segmentTable) |
Function to set segment Table. | |
function | showMarker (in obj, in x, in markerTable, in measuredMean) |
Function to plot marker positions. | |
virtual | showStick (in obj, in x) |
Abstract function to show model as stick figure. | |
function | showStick (in obj, in x, in range, in plotFeet, in plotGRF, in plotCPs, in plotJointCOSYs, in az, in el) |
Function to show model as stick figure. | |
virtual | simuAccGyro (in obj, in data, in q, in qd, in qdd) |
Abstract function to simulate acceleration and gyroscope signals. | |
function | simuAccGyro (in obj, in variables, in q, in qd, in qdd, in idxSegment, in idxAcc, in idxGyro, in dlocalAll, in plocalAll) |
Matlab function to simulates sensors placed on 3D model. | |
function | simuMarker (in obj, in variables, in q, in idxSegment, in plocalAll, in dlocalAll) |
Matlab function to simulates markers placed on 3D model. | |
Static Public Member Functions | |
function | createRandomPerson (in obj, in symmusrand, in massratio, in lengthratio) |
Function to make MEX functions. | |
function | getMexFiles (in osimName, in clean, in rebuild_contact, in debugMode) |
Function to make MEX functions. | |
Public Attributes | |
Property | CPs |
Table: Contact points. | |
Property | dofs |
Table: Degrees of freedom (Range of Dofs should not be changed here. | |
Property | drag_coefficient |
Double: Air drag coefficient in N/(m/s)^2 (default: 0.2128) | |
Property | gravity |
Double array: Gravity vector in m/(s^2) | |
Constant Property | GRFNAMES = {'rightFx', 'rightFy', 'rightFz', 'rightMx', 'rightMy', 'rightMz', 'leftFx', 'leftFy', 'leftFz', 'leftMx', 'leftMy', 'leftMz' } |
Cell array with string: Gives the names for the GRF vector returned by getGRF() | |
Property | joints |
Table: Joints. | |
Property | markers |
Table: Markers (Containing also the CPs. Their names start with 'CP') | |
Property | mExtraScaleFactor |
Double: Scale factor for extra torques in Nm (default: 100 since we used this in previous simulations. | |
Property | muscles |
Table: Muscles. | |
Property | torques |
Table: Torque actuators. | |
Property | wind_speed |
Double: Wind speed in direction of +X in m/s (default: 0) | |
Protected Member Functions | |
function | computeMomentArms (in obj, in range_muscleMoment, in examine, in name) |
Function to generate muscle length polynomials from Opensim muscle paths. | |
function | getCoM (in obj, in x) |
Function to calculate the center of mass. | |
function | getDynamicsCPOffset (in obj, in x, in xdot, in u, in CPYOffset) |
Function computing implicit differential equation for 3D musculoskeletal model which allows an adaption of the CP position. | |
function | initMex (in obj) |
Initialize model mex file. | |
function | initModel (in obj) |
Function to initialize model with default parameters. | |
virtual | initModel (in obj, in vargin) |
Abstract function to initialize with default parameters. | |
function | loadMomentArms (in obj) |
Function to load or compute moment arms. | |
function | loadOsimFile (in obj, in osimfile) |
Function to load the content from the opensim file. | |
function | update_constraints (in obj) |
Function defining the table Gait3d.constraints. | |
function | update_controls (in obj) |
Function defining the table Gait3d.controls. | |
function | update_idxControls (in obj) |
Function defining Model.hidxControls. | |
function | update_idxForward (in obj) |
Function defining Model.idxForward. | |
function | update_idxForwardAll (in obj) |
Function defining Model.idxForwardAll. | |
function | update_idxSideward (in obj) |
Function defining Model.idxSideward. | |
function | update_idxSidewardAll (in obj) |
Function defining Model.idxSidewardAll. | |
function | update_idxStates (in obj) |
Function defining Model.hidxStates. | |
function | update_idxSymmetry (in obj) |
Function defining Gait3d.idxSymmetry. | |
function | update_idxTorqueDof (in obj) |
Function defining Model.idxTorqueDof. | |
function | update_idxUpward (in obj) |
Function defining Model.idxUpward. | |
function | update_mexParameter (in obj, in src, in evnt) |
Function performed to update the parameter of the mex and the tables. | |
function | update_states (in obj) |
Function defining the table Gait3d.states. | |
Static Protected Member Functions | |
static function | plotgrf (in F, in CoP, in color) |
Function used in showStick() to plot GRFs. | |
function | readOsim (in osimfile) |
Function to load OpenSim model in Matlab as structure. | |
Protected Attributes | |
Property | bodyheight |
Property | bodymass |
Double: Bodymass in kg (Is computed by summing up all body mass except talus. | |
Property | constraints |
Table: Information on constraints implemented in the mex and here. | |
Property | controls |
Table: Information on controls of the model. | |
Property | hdlMEX |
Handle: MEX function of the model for dynamics etc. | |
Property | idxForward |
Double array: Indices for forward translation. | |
Property | idxForwardAll |
Double array: Indices for forward translation, speed, position of contact points and force at contact points. | |
Property | idxSideward |
Double array: Indices for sideward translation. | |
Property | idxSidewardAll |
Double array: Indices for sideward translation, speed, position of contact points and force at contact points. | |
Property | idxSymmetry |
Struct: Double arrays with indices for symmetry to map right to left. | |
Property | idxTorqueDof |
Double array: Indices of dofs of torque actuators. | |
Property | idxUpward |
Double array: Indices for upward translation. | |
Property | init |
Double: Showing if the mex model is initialized. | |
Property | nConstraints |
Double: Number of constraints (height of Model.constraints) | |
Property | nControls |
Double: Number of controls (height of Model.controls) | |
Property | nCPs |
Double: Number of contact points (height of Model.CPs) | |
Property | nDofs |
Double: Number of degree of freedoms (height of Model.dofs) | |
Property | nJoints |
Double: Number of joints (height of Model.joints) | |
Property | nMarkers |
Double: Number of markers (height of Gait3d.markers) | |
Property | nMus |
Double: Number of muscles (height of Model.muscles) | |
Property | nSegments |
Double: Number of segments (height of Model.segments) | |
Property | nStates |
Double: Number of states (height of Model.states) | |
Property | nTor |
Double: Number of torque actuators (height of Model.torques) | |
Property | osim |
Struct: Information (name, file, modified, sha256) on opensim model. | |
Property | segments |
Table: Segments (Segment properties should not be changed) | |
Property | states |
Table: Information on states of the model. | |
The class describes the Gait3d model.
Constructor setting default Gait3d object.
Initializes the model and builds and initializes the mex function. The mex functions can be also build with other options if Gait3d.getMexFiles(osimName) is called before the constructor is called.
Sets a new default for Gait3d.mExtraScaleFactor: 10 Nm
The standard model can be called using:
The osim file must be in the matlab path.
opensimfile | String: Opensim file with path, name and extension |
obj | Gait3d class object |
|
protected |
Function to generate muscle length polynomials from Opensim muscle paths.
For each muscle, the generalized coordinates are moved through their entire range, in a specified number of steps (currently 6). So for a muscle that spans 4 dofs, we will examine 6^4 = 1296 poses. For each pose, the Opensim API is used to obtain the moment arms of the muscle. Also the API is used to obtain the muscle-tendon length when all generalized coordinates are zero.
Stepwise regression is done on the moment arm data to produce the best set of polynomial terms. The addition of terms stops when one of the following is true:
The examine option is intended for model developers to inspect the polynomials and make sure they are good enough. When regenerating polynomials for a model that has already been tested, the examine and name options should not be used.
Saves results at strrep(which(settings.osimfile), '.osim', '_momentarms.mat')
obj | Gait3d class object |
range_muscleMoment | Table: Ranges of DOFs which were used to fit polynomials |
examine | (optional, default 0) when 1: plots results for each muscle and pauses for inspection |
name | (optional) name of the muscle that should be processed (when missing, all are done) |
momentarm_model | Struct: Resulting polynomials which are also saved at strrep(which(settings.osimfile), '.osim', '_momentarms.mat') |
|
static |
Function to make MEX functions.
Creates a musculoskeletal model with random parameters
symmusrand | double matrix: matrix with random numbers that will be used to randomze muscle parameters |
massratio | (optional) ratio to be used for randomizing the mass of the body |
lengthratio | (optional) ratio to be used for randomizing the length of the body |
|
inherited |
Function to obtain index of contol with a specific type (and name)
obj | Model class object |
type | String: Type of the control |
controlname | (optional) String or cell array of strings: Name of the control |
iControl | Double array: Indices in Model.controls matching type (and name) |
|
inherited |
Function to obtain index of state with a specific type (and name)
obj | Model class object |
type | String: Type of the state |
statename | (optional) String or cell array of strings: Name of the state |
iState | Double array: Indices in Model.states matching type (and name) |
|
protected |
Function to calculate the center of mass.
It solves the center of pressure (CoM) coordinates from the locations of the individual centers of mass
obj | Model class object |
x | Double vector: state of system |
CoM | Double vector: x, y, z location of center of mass |
|
inherited |
Function to calculate the center of pressure.
It solves the center of pressure (COP) coordinates from: COP x F + Ty = M, where COP is a point in the XZ plane and Ty is the "free moment" on the Y axis. expand the equation:
Use COPy = 0, to get COPx = Mz / Fy and COPz = -Mx / Fy
For 2D, COPz will be 0.
obj | Model class object |
grf | Double vector: Ground contact vector containing Fx, Fy, Fz, Mx, My, Mz (right), and Fx, Fy, Fz, Mx, My, Mz (left) (12) |
CoP_r | Double vector: Center of pressure in x, y and z direction for right foot (3) |
CoP_l | Double vector: Center of pressure in x, y and z direction for left foot (3) |
|
virtual |
Function computing implicit differential equation for 3D musculoskeletal model.
This function calls the mex file of gait3d.c: [f, dfdx, dfdxdot, dfdumus, dfdMextra] = obj.hdlMEX('Dynamics',x,xdot,umus,Mextra);
with the neural excitation umus and the extra torques Mextra.
The dynamic residuals will be between fmin and fmax when inputs satisfy system dynamics : fmin <= f(x,dx/dt,umus,Mextra) <= fmax
The last four outputs are optional and some computation time is saved if you do not request all of them.
obj | Gait3d class object |
x | Double array: State of the model (Gait3d.nStates x 1) |
xdot | Double array: State derivatives (Gait3d.nStates x 1) |
u | Double array: Controls of the model (Gait3d.nControls x 1) |
f | Double array: Dynamic residuals (Gait3d.nConstraints x 1) |
dfdx | (optional) Double matrix: Transpose of Jacobian matrix df/dx (Gait3d.nStates x Gait3d.nConstraints) |
dfdxdot | (optional) Double matrix: Transpose of Jacobian matrix df/dxdot (Gait3d.nStates x Gait3d.nConstraints) |
dfdu | (optional) Double matrix: Transpose of Jacobian matrix df/du (Gait3d.nControls x Gait3d.nConstraints) |
Reimplemented from Model.
|
protected |
Function computing implicit differential equation for 3D musculoskeletal model which allows an adaption of the CP position.
I calls Gait3d.getDynamics() and then overrights the entries to allow apply a vertical shift to the CP position.
obj | Gait3d_CPOffset class object |
x | Double array: State of the model (Gait3d.nStates x 1) |
xdot | Double array: State derivatives (Gait3d.nStates x 1) |
u | Double array: Controls of the model (Gait3d.nControls x 1) |
CPYOffset | Double: Vertical offset of original CP positions applied to all CPs |
f | Double array: Dynamic residuals (Gait3d.nConstraints x 1) |
dfdx | (optional) Double matrix: Transpose of Jacobian matrix df/dx (Gait3d.nStates x Gait3d.nConstraints) |
dfdxdot | (optional) Double matrix: Transpose of Jacobian matrix df/dxdot (Gait3d.nStates x Gait3d.nConstraints) |
dfdu | (optional) Double matrix: Transpose of Jacobian matrix df/du (Gait3d.nControls x Gait3d.nConstraints) |
dfdCPYOffset | (optional) Double matrix: Transpose of Jacobian matrix df/dCPYOffset (1 x Gait3d.nConstraints) |
|
inherited |
Model function to calculate the energy rate of a single time step using Bhargava et al.
's model
Function to calculate the energy rate at a single time step using a continuous version of Bhargava et al.'s model. Model paper: Bhargava et al., J Biomech, 2004
Inputs are muscle states of the specific muscle that is considered.
obj | Model object |
F_ce | Force in the contractile element |
stim | Stimulation of the muscle (between 0 and 1) |
act | Activation level of the muscle (between 0 and 1) |
l_ce | Normalized length of the contractile element |
v_ce | Normalized velocity of the contractile element |
t_stim | Duration of stimulation of muscle |
The output of getEratec_bhargava.m is a double which is equal to the energy rate of the time step in W/kg
Edot | The energy expenditure during the current time step |
|
inherited |
Model function to calculate the energy rate of a single time.
Function to calculate the energy rate at a single time step using Houdijk et al.'s model. Houdijk et al., J Biomech, 2006. The paper desription is not optimal, see comments
Inputs are muscle parameters of the specific muscle that is considered. Inputs are muscle states of the specific muscle that is considered.
obj | Model object |
F_ce | Force in the contractile element |
act | Activation level of the muscle (between 0 and 1) |
l_ce | Normalized length of the contractile element |
v_ce | Normalized velocity of the contractile element |
The output of getErate_Houdijk.m is a double which is equal to the energy rate of the time step in W/kg
Edot | The energy expenditure during the current time step |
w | Muscle work during the current time step |
|
inherited |
Model function to calculate the energy rate of a single time step using a continuous version of Lichtwark & Wilson's model.
Function to calculate the energy rate at a single time step using Lichtwark & Wilson's model, described in the supplement of Lichtwark & Wilson, J Biomech, 2007. The exception in gamma (line 68), which is according to Lichtwark & Wilson, J Exp Biol, 2005, because results were better in the 2019 comparison paper
Inputs are muscle parameters of the specific muscle that is considered.
obj | Model object |
F_ce | Force in the contractile element |
act | Activation level of the muscle (between 0 and 1) |
l_ce | Normalized length of the contractile element |
v_ce | Normalized velocity of the contractile element |
t_stim | Duration of stimulation of muscle |
The output of getErate_Lichtwark.m is a double which is equal to the energy rate of the time step in W/kg
Edot | The energy expenditure during the current time step |
|
inherited |
Model function to calculate the energy rate of a single time step using Margaria's model.
Function to calculate the energy rate at a single time step using Margaria's model: 25 % efficient during shortening, 120% during lengthening. Margaria, Int Z Angew Physiol Einschl Arbeitsphysiol, 1968
Inputs are muscle parameters of the specific muscle that is considered.
obj | Model object |
F_ce | Force in the contractile element |
v_ce | Normalized velocity of the contractile element |
The output of getErate_margaria.m is a double which is equal to the energy rate of the time step in W/kg
Edot | is the energy expenditure during the current time step |
|
inherited |
Model function to calculate the energy rate of a single time.
Function to calculate the energy rate at a single time step using Minetti's model. Based on: Minetti & Alexander, J Theor Biol, 1997. Uses muscle-level work instead of torque-level
Inputs are muscle parameters of the specific muscle that is considered.
obj | Model object |
act | activation level of the muscle (between 0 and 1) |
v_ce | current velocity of the contractile element |
The output of getErate_Minetti is a double which is equal to the energy rate
Edot | is the energy expenditure during the current time step |
|
inherited |
Model function to calculate the energy rate of a single time.
Function to calculate the energy rate at a single time step using Uchida's model: Uchida et al., PLOS ONE, 2016
Inputs are muscle states of the specific muscle that is considered
obj | Model class object |
F_ce | Double vector: Muscle force of CE returned by obj.getMuscleCEforces(x) (Model.nMus x 1) |
stim | Double vector: Stimulation of muscles = neural excitation u (Model.nMus x 1) |
act | Double vector: Activation of muscles a (Model.nMus x 1) |
l_ce | Double vector: Length of contractile element of muscles s (Model.nMus x 1) |
v_ce | Double vector: Velocity of contractile element of muscles (Model.nMus x 1) |
The output of getErate_uchida.m is a double which is equal to the energy rate of the time step in W/kg
Edot | Double vector: Energy expenditure during one time step (energy rate) in W (Model.nMus x 1) |
w_ce | Double vector: Mechanical work rate of contractile element in W/kg (normalized to muscle mass) (Model.nMus x 1) |
h_sl | Double vector: Heat rate due to shortening and lengthening of muscles in W/kg (normalized to muscle mass) (Model.nMus x 1) |
h_am | Double vector: Heat rate from the activation of muscles and its maintenance in W/kg (normalized to muscle mass) (Model.nMus x 1) |
|
inherited |
Model function to calculate the energy rate of a single time step with Umberger et al.
's model. Ross Miller's code was also used as a reference.
Function to calculate the energy rate at a single time step using Umberger's model. It uses the 2010 version (no negative work): Umberger, J R Soc Interface, 2010 2003 (original) Version: Umberger et al., "A model of human muscle energy expenditure," Computer methods in biomechanics and biomedical engineering, vol. 6, no. 2, pp. 99–111, 2003.
Inputs are muscle states of the specific muscle that is considered
obj | Gait2dc class object |
F_ce | Double vector: Muscle force of CE returned by Model.getMuscleCEforces(x) (Model.nMus x 1) |
stim | Double vector: Stimulation of muscles = neural excitation u (Model.nMus x 1) |
act | Double vector: Activation of muscles a (Model.nMus x 1) |
l_ce | Double vector: Length of contractile element of muscles s (Model.nMus x 1) |
v_ce | Double vector: Velocity of contractile element of muscles (Model.nMus x 1) |
The output of getErate_Umberger.m is a double which is equal to the energy rate of the time step in W/kg
Edot | Double vector: Energy expenditure during one time step (energy rate) in W (Model.nMus x 1) |
w_ce | Double vector: Mechanical work rate of contractile element in W/kg (normalized to muscle mass) (Model.nMus x 1) |
h_sl | Double vector: Heat rate due to shortening and lengthening of muscles in W/kg (normalized to muscle mass) (Model.nMus x 1) |
h_am | Double vector: Heat rate from the activation of muscles and its maintenance in W/kg (normalized to muscle mass) (Model.nMus x 1) |
|
inherited |
Model function to calculate the energy rate of a single time step using a continuous version of Bhargava et al.
's model
Function to calculate the energy rate at a single time step using a continuous version of Bhargava et al.'s model. Line 60, phi, was chosen based on graphs of phi as a function of t_stim, since t_stim cannot be differentiated. Model paper: bhargava et al., J Biomech, 2004
Inputs are muscle states of the specific muscle that is considered.
obj | Model object |
F_ce | Force in the contractile element |
stim | Stimulation of the muscle (between 0 and 1) |
act | Activation level of the muscle (between 0 and 1) |
l_ce | Normalized length of the contractile element |
v_ce | Normalized velocity of the contractile element |
dFdx | Derivative of CE forces with respect to the state |
dFdxdot | Derivative of CE forces with respect to the state derivative |
epsilon | Measure of the nonlinearity of the continuous functions |
The output of getEratec_bhargava.m is a double which is equal to the energy rate of the time step in W/kg
Edot | The energy expenditure during the current time step |
dEdot | The gradient of Edot with respect to all states and inputs |
|
inherited |
Model function to calculate the energy rate of a single time step using a continuous version of Houdijk et al.
's model
Function to calculate the energy rate at a single time step using a continuous version of Houdijk et al.'s model. Houdijk et al., J Biomech, 2006.
Inputs are muscle parameters of the specific muscle that is considered. Inputs are muscle states of the specific muscle that is considered.
obj | Model object |
F_ce | Force in the contractile element |
act | Activation level of the muscle (between 0 and 1) |
l_ce | Normalized length of the contractile element |
v_ce | Normalized velocity of the contractile element |
dFdx | Derivative of CE forces with respect to the state |
dFdxdot | Derivative of CE forces with respect to the state derivative |
epsilon | Measure of the nonlinearity of the continuous functions |
The output of getEratec_Houdijk.m is a double which is equal to the energy rate of the time step in W/kg
Edot | The energy expenditure during the current time step |
dEdot | The gradient of Edot with respect to all states and inputs% |
|
inherited |
Model function to calculate the energy rate of a single time step using a continuous version of Lichtwark & Wilson's model.
Function to calculate the energy rate at a single time step using a continuous version of Lichtwark & Wilson's model, described in the supplement of Lichtwark & Wilson, J Biomech, 2007.
Inputs are muscle parameters of the specific muscle that is considered.
obj | Model object |
F_ce | Force in the contractile element |
act | Activation level of the muscle (between 0 and 1) |
l_ce | Normalized length of the contractile element |
v_ce | Normalized velocity of the contractile element |
dFdx | Derivative of CE forces with respect to the state |
dFdxdot | Derivative of CE forces with respect to the state derivative |
epsilon | Measure of the nonlinearity of the continuous functions |
The output of getEratec_Lichtwark.m is a double which is equal to the energy rate of the time step in W/kg
Edot | The energy expenditure during the current time step |
dEdot | The gradien |
|
inherited |
Model function to calculate the energy rate of a single time step using a continuous version of Margaria's model.
Function to calculate the energy rate at a single time step using a continuous version of Margaria's model: 25 % efficient during shortening, 120% during lengthening. Margaria, Int Z Angew Physiol Einschl Arbeitsphysiol, 1968
Inputs are muscle parameters of the specific muscle that is considered.
obj | Model object |
F_ce | Force in the contractile element |
v_ce | Normalized velocity of the contractile element |
dFdx | Derivative of CE forces with respect to the state |
dFdxdot | Derivative of CE forces with respect to the state derivative |
epsilon | Measure of the nonlinearity of the continuous functions |
The output of getEratec_margaria.m is a double which is equal to the energy rate of the time step in W/kg
Edot | is the energy expenditure during the current time step |
dEdot | is the gradient of Edot with respect to all states and inputs |
|
inherited |
Model function to calculate the energy rate of a single time step using Minetti's model.
No discsontinuities here, so it is the same as the original model.
Function to calculate the energy rate at a single time step using Minetti's model. Based on: Minetti & Alexander, J Theor Biol, 1997. Uses muscle-level work instead of torque-level
Inputs are muscle parameters of the specific muscle that is considered.
obj | Model object |
act | activation level of the muscle (between 0 and 1) |
v_ce | current velocity of the contractile element |
The output of getEratec_Minetti.m is a double which is equal to the energy rate of the time step in W/kg
Edot | is the energy expenditure during the current time step |
dEdot | is the gradient of Edot with respect to all states and inputs |
|
inherited |
Model function to calculate the energy rate of a single time step with the continuous version of Umberger et al.
's model
Function to calculate the energy rate at a single time step using a continuous version of Umberger's model. This one is published in Koelewijn, Dorscky et al., Comp Meth Biomed Biomech Eng, 2016, and uses the 2010 version (no negative work): Umberger, J R Soc Interface, 2010
Inputs are muscle states of the specific muscle that is considered.
obj | Model object |
F_ce | Force in the contractile element |
stim | Stimulation of the muscle (between 0 and 1) |
act | Activation level of the muscle (between 0 and 1) |
l_ce | Normalized length of the contractile element |
v_ce | Normalized velocity of the contractile element |
dFdx | Derivative of CE forces with respect to the state |
dFdxdot | Derivative of CE forces with respect to the state derivative |
epsilon | Measure of the nonlinearity of the continuous functions |
The output of getEratec_umberger.m is a double which is equal to the energy rate of the time step in W/kg
Edot | The energy expenditure during the current time step |
dEdot | The gradient of Edot with respect to all states and inputs |
function getFkin | ( | in | obj, |
in | q, | ||
in | qdot | ||
) |
Function returns position and orientation of body segments, for the system in position q.
Needed for tracking of marker trajectories, and for 3D visualization of the model. This function calls the mex file of gait3d.c [FK, dFKdq,dFKdotdq] = obj.hdlMEX('Fkin', q, qdot);
The order the following for each segment:
'p1', 'p2', 'p3', 'R11', 'R12', 'R13', 'R21', 'R22', 'R23', 'R31', 'R32', 'R33'
p can be obtained by:
R can be obtained by:
obj | Gait3d class object |
q | Double array: Generalized coordinates (elements of states with type 'q') (Gait3d.nDofs x 1) |
qdot | (optional) Double array: Generalized velocities (elements of states with type 'qdot') (Gait3d.nDofs x 1) |
FK | Double array: position (3) and orientation (3x3, stored row-wise) of nSegments-1. Segments are the bodies in the .osim model, not including ground. ((Gait3d.nSegments-1) * 12) |
dFKdq | (optional) Double matrix: Jacobian of FK with respect to q ((Gait3d.nSegments-1) * 12 x Gait3d.nDofs) |
dFKdotdq | (optional) Double matrix: Jacobian of dFK/dt with respect to q ((Gait3d.nSegments-1) * 12 x Gait3d.nDofs) |
|
virtual |
Function returns the ground reaction forces for the system in state x.
This function calls the mex file of gait3d.c: [grf, dgrfdx] = obj.hdlMEX('GRF', x);
obj | Gait3d class object |
x | Double array: State of the model (Gait3d.nStates x 1) |
grf | Double array (12x1) containing:
|
dgrfdx | (optional) Double matrix: Transpose of Jacobian matrix dgrf/dx (Gait3d.nStates x 12) |
Reimplemented from Model.
|
virtual |
Function returns joint moments, for the system in state x.
This includes passive joint moments and muscle moments and extra moments (e.g. arms).
obj | Gait3d class object |
x | Double array: State of the model (Gait3d.nStates x 1) |
u | (optional) Double array: Controls of the model which are only needed if you want to apply extra moments (i.e. arm torques) (Gait3d.nControls x 1) |
M | Double array: Moment/force for each DOF (Gait3d.nDofs x 1) |
dMdx | (optional) Double matrix: Transpose of Jacobian matrix dM/dx (Gait3d.nStates x Gait3d.nDofs) |
dMdu | (optional) Double matrix: Transpose of Jacobian matrix dM/du (Gait3d.nControls x Gait3d.nDofs) |
Reimplemented from Model.
function getLCE | ( | in | obj, |
in | x | ||
) |
Function returns length of contractile element, for the system in state x.
This function obtaines L_CE from s using the equations which are also implemented in the c code.
obj | Gait3d class object |
x | Double array: State of the model (Gait3d.nStates x 1) |
L_CE | Double array: CE length (m) of each muscle (Gait3d.nMus x 1) |
function getLdotCE | ( | in | obj, |
in | xdot | ||
) |
Function returns length change of contractile element, for the system in state x.
This function obtaines Ldot_CE from sdot using the equations which are also implemented in the c code.
obj | Gait3d class object |
xdot | Double array: State derivatives (Gait3d.nStates x 1) |
Ldot_CE | Double array: CE length change (m/s) of each muscle (Gait3d.nMus x 1) |
|
inherited |
Model function to calculate metabolic cost of a movement.
Function to calculate the metabolic cost of a movement. Seven different models are currently implemented
obj | Model object |
x | Double vector: States of the current node |
xdot | Double vector: Derivatives of states |
u | Double vector: Controls of the current node |
t_stim | Double vector: how long each muscle was already stimulated |
name | (optional) String: name of the model that is being used. Options are umberger, lichtwark, bhargava, margaria, minetti, houdijk, and uchida |
getCont | (optional) Boolean: If true, get the continuous version which is needed if we use the output for simulation. (default: 0) |
epsilon | (optional) double parameter: Measure of nonlinearity of model, which is only used in the continuous model version. Default 0. |
exponent | (optional) integer: if metabolic cost is the objective, this number allows to minimize the square, cube, or nth-power of metabolic cost. Default is 1 |
Edot | Double vector: Energy expenditure during one time step (energy rate) in W (Model.nMus x 1) |
dEdotdx | Double vector: Derivative of Edot w.r.t to x (Model.nStates x 1) |
dEdotdu | Double vector: Derivative of Edot w.r.t to u (Model.nControls x 1) |
dEdotdT | Double: Derivative of Edot w.r.t to T |
|
static |
Function to make MEX functions.
Generates Autolev source file for model and builds the MEX function
osimName | String: Name of Opensim model. See lines 30-41 for supported models |
rebuild_contact | (optional) Bool: If true, enforce rebuilding contact_raw.c (default: 0) |
debugMode | (optional) Bool: If true, code will be compiled in debug mode and not optimized. (default: 0) |
name_MEX | String: Name of the mex function which has to be called |
|
virtual |
Function returning muscle forces of CE for the system in state x.
This function calls the mex file of gait3d.c: [forces] = obj.hdlMEX('MuscleCEforces', x);
obj | Gait3d class object |
x | Double array: State of the model (Gait3d.nStates x 1) |
xdot | Double array: State derivatives (Gait3d.nStates x 1) |
forcesCE | Double array: Muscle forces of CE (in N) (Gait3d.nMus x 1) |
dforcesCEdx | Double array: Transpose of Jacobian matrix d force / d x (Gait3d.nStates x Gait3d.nMus) |
dforcesCEdxdot | Double array: Transpose of Jacobian matrix d force / d xdot (Gait3d.nStates x Gait3d.nMus) |
Reimplemented from Model.
|
virtual |
Function returns power generated by muscle contractile elements, for the system in state x.
xdot must be the state derivatives, such that the muscle balance equations are satisfied It is up to the user to ensure that the muscle contraction balance f(x,xdot)=0 when this function is used.
obj | Gait3d class object |
x | Double array: State of the model (Gait3d.nStates x 1) |
xdot | Double array: State derivatives (Gait3d.nStates x 1) |
powers | Double array: CE power output (W) of each muscle (Gait3d.nMus x 1) |
conDynRes | Double array: Contraction dynamics residuals (Gait3d.nMus x 1) |
Reimplemented from Model.
|
virtual |
Function returns muscle forces, for the system in state x.
This function calls the mex file of gait3d.c: [forces, lengths, momentarms] = obj.hdlMEX('Muscleforces', x);
obj | Gait3d class object |
x | Double array: State of the model (Gait3d.nStates x 1) |
forces | Double array: Muscle forces (N) (Gait3d.nMus x 1) |
lengths | (optional) Double array: Muscle-tendon lengths (m) (Gait3d.nMus x 1) |
momentarms | (optional) Double matrix: Muscle moment arms (m) (Gait3d.nMus x Gait3d.nDofs) |
Reimplemented from Model.
function getPassiveJointmoments | ( | in | obj, |
in | x | ||
) |
Function returns passive joint moments, for the system in state x.
This function returns the passive joint moments due to ligaments
obj | Gait3d class object |
x | Double array: State of the model (Gait3d.nStates x 1) |
M | Double array: Passive moment for each DOF (Gait3d.nDofs x 1) |
dMdx | (optional) Double matrix: Transpose of Jacobian matrix dM/dx (Gait3d.nStates x Gait3d.nDofs) |
|
protectedvirtual |
Initialize model mex file.
This function calls the mex file of gait3d.c [info] = obj.hdlMEX('Initialize', model)
This initializes the model. This is required before anything is done with the model.
Input: model Struct containing model parameters.
Output: info Struct with information about the size of the model, fields: Nx Number of state variables: 2* Gait3d.nDofs + 2* Gait3d.nMuscles + 9* Gait3d.nCPs Nf Number of functions returned by the Dynamics function fmin,fmax Lower and upper bounds for dynamics residuals f Bodyweight Sum of weights of all segments. This is used to set bodymass
obj | Gait3d class object |
Reimplemented from Model.
|
protected |
Function to initialize model with default parameters.
Initialize contact points and stiffness of dofs
obj | Gait3d class object |
|
protectedvirtualinherited |
Abstract function to initialize with default parameters.
Reimplemented in Gait2dc.
|
protected |
Function to load or compute moment arms.
Loads moment arms save in the file strrep(obj.osim.file,'.osim','_momentarms.mat'). If there is not such a file, the moment arms will be computed and saved.
We define here also the ranges of the dofs used to get the muscle moments and the ones used to get the passive moments:
obj | Gait3d class object |
|
protected |
Function to load the content from the opensim file.
Calls readOsim() if there is no .mat file corresponding to the requested osimfile. Therefore it searches for a file called strrep(osimfile, '.osim', '.mat') and checks the sha code to see weather the .mat file is still up to date with the opensim file.
obj | Gait3d class object |
osimfile | String: Filename of opensim file including path and extension |
|
staticprotected |
Function used in showStick() to plot GRFs.
Plots a ground reaction force vector represented by 3D force and CoP.
F | Double array: Force (3 x 1) |
CoP | Double array: Center of pressure in x, y, z coordinates (3 x 1) |
color | String: Color (e.g. color = 'r') |
|
staticprotected |
Function to load OpenSim model in Matlab as structure.
Saves the model struct using strrep(osimfile, '.osim', '.mat').
osimfile | String: Filename of opensim file including path and extension |
model | Struct: Parameters of OpenSim model |
|
inherited |
Function to set body mass, does not influence the.
obj | Model class object |
segmentTable | Double: bodymass |
|
inherited |
Function to set the muscles table.
obj | Model class object |
segmentTable | Table: muscles |
|
inherited |
Function to set segment mass.
obj | Model class object |
segmentName | String: Name of the segment |
segmentMass | Double: Mass of the segment in kg |
|
inherited |
Function to set segment Table.
obj | Model class object |
segmentTable | Table: segmentTable |
function showMarker | ( | in | obj, |
in | x, | ||
in | markerTable, | ||
in | measuredMean | ||
) |
Function to plot marker positions.
The motion in x and the matrix measured have to fit to each other. If you want to plot for example only a single node, markerTable.mean must be only the data of this single node.
You can use the function like this:
obj | Gait3d class object |
x | Double matrix: State vector of model for n time points (Gait3d.nStates x n) |
markerTable | Table: Variables table specifying markers with at least the columns: type, name, segment, position, direction to call Gait3d.simuMarker. |
measuredMean | (optional) Double matrix: Measured marker data in meter(!) which will be plotted as reference. The matrix must have the same number of time points as the state vector x. Further, the matrix columns must correspond to the rows of the markerTable in the same order to be able to match coordinates of the markers. (n x height(markerTable)) (default: empty) |
|
virtualinherited |
Abstract function to show model as stick figure.
function showStick | ( | in | obj, |
in | x, | ||
in | range, | ||
in | plotFeet, | ||
in | plotGRF, | ||
in | plotCPs, | ||
in | plotJointCOSYs, | ||
in | az, | ||
in | el | ||
) |
Function to show model as stick figure.
obj | Gait3d class object |
x | Double matrice: State vector of model for n time points (Gait3d.nStates x n) |
range | (optional) Double matrice: Defining the range of the figure with [xmin, xmax; ymin, ymax, zmin, zmax]. (3 x 2) (default: [pelvisX-1, pelvisX+1; -0.2, 2, pelvisZ-1, pelvisZ+1]) |
plotFeet | (optional) Integer: Defines if and how the feet are plotted (default: 0)
|
plotGRF | (optional) Bool: If true, it plots arrows for the GRFs (default: 0) |
plotCPs | (optional) Bool: If true, it plots spheres for the CPs (default: 0) |
plotJointCOSYs | (optional) Bool: If true, it plots the coordinate systems of the joints (default: 0) |
az | (optional) Double: Azimuth for the view of the figure (view(az, el)). (default: 90) |
el | (optional) Double: Elevation for the view of the figure (view(az, el)). (default: 0) |
|
virtualinherited |
Abstract function to simulate acceleration and gyroscope signals.
function simuAccGyro | ( | in | obj, |
in | variables, | ||
in | q, | ||
in | qd, | ||
in | qdd, | ||
in | idxSegment, | ||
in | idxAcc, | ||
in | idxGyro, | ||
in | dlocalAll, | ||
in | plocalAll | ||
) |
Matlab function to simulates sensors placed on 3D model.
Do not change "obj" or "variables" in this function! This will allow Matlab to "pass by reference" and avoid function call overhead.
Position has to given as X, Y and Z position of sensor in segment coordinate system in m.
Direction has to be given in axis definition, e.g [1, 0, 0].
obj | Gait3d class object |
variables | Table: Variable table containing the accelerometer and gyroscope data with at least the columns: type, name, segment, position, direction |
q | Generalized coordinates (Gait3d.nDofs x 1) |
qd | First derivatives of generalized coordinates (Gait3d.nDofs x 1) |
qdd | Second derivatives of generalized coordinates (Gait3d.nDofs x 1) (use NaN to skip) |
idxSegment | (optional) Double array: Indices of segments fitting to respective IMU (variables.nVars.all x 1) => It is faster to pass them than to recalculate each time. |
idxAcc | (optional) Double array: Indices in variables that have type 'acc' (nAcc x 1) => It is faster to pass them than to recalculate each time. |
idxGyro | (optional) Double array: Indices in variables that have type 'gyro' (nGyro x 1) => It is faster to pass them than to recalculate each time. |
dlocalAll | (optional) Double matrix: Local direction of the IMU saved in variables (variables.nVars.all x 3) => It is faster to pass them than to extract them each time. |
plocalAll | (optional) Double matrix: Local position of the IMU saved in variables (variables.nVars.all x 3) => It is faster to pass them than to extract them each time. |
s | Simulated sensor signals (variables.nVars.all x 1) |
ds_dq | Sparse Jacobian ds/dq (variables.nVars.all x Gait3d.nDofs) |
ds_dqd | Sparse Jacobian ds/dqd (variables.nVars.all x Gait3d.nDofs) |
ds_dqdd | Sparse Jacobian ds/dqdd (variables.nVars.all x Gait3d.nDofs) |
function simuMarker | ( | in | obj, |
in | variables, | ||
in | q, | ||
in | idxSegment, | ||
in | plocalAll, | ||
in | dlocalAll | ||
) |
Matlab function to simulates markers placed on 3D model.
Do not change "obj" or "variables" in this function! This will allow Matlab to "pass by reference" and avoid function call overhead.
Position has to given as X, Y, and Z position of marker in segment coordinate system in m. Direction has to be given in axis definition, e.g [1, 0, 0].
obj | Gait3d class object |
variables | Table: Variable table containing the marker data with at least the columns: type, name, segment, position, direction |
q | Double array: Generalized coordinates (Gait3d.nDofs x 1) |
idxSegment | (optional) Double array: Indices of segments fitting to respective markers (variables.nVars.all x 1) => It is faster to pass them than to recalculate each time. |
plocalAll | (optional) Double matrix: Local position of the markers saved in variables (variables.nVars.all x 3) => It is faster to pass them than to extract them each time. |
dlocalAll | (optional) Double matrix: Local direction of the markers saved in variables (variables.nVars.all x 3) => It is faster to pass them than to extract them each time. |
m | Simulated marker signals in meter (variables.nVars.all x 1) |
dm_dq | Sparse Jacobian dm/dq (variables.nVars.all x Gait3d.nDofs) |
|
protectedvirtual |
Function defining the table Gait3d.constraints.
Table lists type, name, equation (string), fmin and fmax
The constraints are composed of Gait3d.nConstraints = 2* Gait3d.nDofs + 2* Gait3d.nMus + 13* Gait3d.nCPs)
obj | Gait3d class object |
Reimplemented from Model.
|
protectedvirtual |
Function defining the table Gait3d.controls.
Table lists type, name, xmin, xmax and xneutral
obj | Gait3d class object |
Reimplemented from Model.
|
protectedinherited |
Function defining Model.hidxControls.
obj | Model class object |
|
protectedinherited |
Function defining Model.idxForward.
Provides the indices of state variables that have forward translation. States have to be updated before!
obj | Model class object |
|
protectedinherited |
Function defining Model.idxForwardAll.
Provides the indices of state variables that have forward translation, speed, position of contact points and force at contact points. States and idxForward have to be updated before!
obj | Model class object |
|
protectedinherited |
Function defining Model.idxSideward.
Provides the indices of state variables that have sideward translation. States have to be updated before!
obj | Model class object |
|
protectedinherited |
Function defining Model.idxSidewardAll.
Provides the indices of state variables that have sideward translation, speed, position of contact points and force at contact points. States and idxSideward have to be updated before!
obj | Model class object |
|
protectedinherited |
Function defining Model.hidxStates.
obj | Model class object |
|
protectedvirtual |
|
protectedinherited |
Function defining Model.idxTorqueDof.
Searches for indices of dof which have torque actuators in Model.torques.
obj | Model class object |
|
protectedinherited |
Function defining Model.idxUpward.
Provides the indices of state variables that have upward translation. States have to be updated before!
obj | Model class object |
|
protectedvirtual |
Function performed to update the parameter of the mex and the tables.
obj | Gait3d class object |
src | meta.property: Object describing the source of the event |
evnt | (optional) event.Propertyevent: Object describing the event |
Reimplemented from Model.
|
protectedvirtual |
Function defining the table Gait3d.states.
Table lists type, name, xmin, xmax and xneutral
obj | Gait3d class object |
Reimplemented from Model.
|
protected |
|
protected |
Double: Bodymass in kg (Is computed by summing up all body mass except talus.
See gait3d.c)
|
protectedinherited |
Table: Information on constraints implemented in the mex and here.
|
protectedinherited |
Table: Information on controls of the model.
|
inherited |
Table: Contact points.
|
inherited |
Table: Degrees of freedom (Range of Dofs should not be changed here.
Set the bounds of the Problem instead.)
|
inherited |
Double: Air drag coefficient in N/(m/s)^2 (default: 0.2128)
|
inherited |
Double array: Gravity vector in m/(s^2)
|
inherited |
Cell array with string: Gives the names for the GRF vector returned by getGRF()
|
protected |
Handle: MEX function of the model for dynamics etc.
|
protectedinherited |
Double array: Indices for forward translation.
|
protectedinherited |
Double array: Indices for forward translation, speed, position of contact points and force at contact points.
|
protectedinherited |
Double array: Indices for sideward translation.
|
protectedinherited |
Double array: Indices for sideward translation, speed, position of contact points and force at contact points.
|
protectedinherited |
Struct: Double arrays with indices for symmetry to map right to left.
|
protectedinherited |
Double array: Indices of dofs of torque actuators.
|
protectedinherited |
Double array: Indices for upward translation.
|
protectedinherited |
Double: Showing if the mex model is initialized.
|
inherited |
Table: Joints.
Property markers |
Table: Markers (Containing also the CPs. Their names start with 'CP')
|
inherited |
Double: Scale factor for extra torques in Nm (default: 100 since we used this in previous simulations.
However, it's probably overwritten in the construction (see Gait3d.m)!)
|
inherited |
Table: Muscles.
|
protectedinherited |
Double: Number of constraints (height of Model.constraints)
|
protectedinherited |
Double: Number of controls (height of Model.controls)
|
protectedinherited |
Double: Number of contact points (height of Model.CPs)
|
protectedinherited |
Double: Number of degree of freedoms (height of Model.dofs)
|
protectedinherited |
Double: Number of joints (height of Model.joints)
|
protected |
Double: Number of markers (height of Gait3d.markers)
|
protectedinherited |
Double: Number of muscles (height of Model.muscles)
|
protectedinherited |
Double: Number of segments (height of Model.segments)
|
protectedinherited |
Double: Number of states (height of Model.states)
|
protectedinherited |
Double: Number of torque actuators (height of Model.torques)
|
protected |
Struct: Information (name, file, modified, sha256) on opensim model.
|
protectedinherited |
Table: Segments (Segment properties should not be changed)
|
protectedinherited |
Table: Information on states of the model.
|
inherited |
Table: Torque actuators.
|
inherited |
Double: Wind speed in direction of +X in m/s (default: 0)