Biomech-Sim-Toolbox 1
Toolbox for movement simulation and analysis
Loading...
Searching...
No Matches
Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Gait2dcTest Class Reference

Test class to test the class Gait2dc. More...

Inheritance diagram for Gait2dcTest:
ModelTest

Public Member Functions

Tests: Gait2dcTest


function test_grf (in testCase)
 Function for testing the ground reaction force model.
 
function test_isometricMuscles (in testCase)
 Function for testing the muscles strength.
 
function test_isokineticMuscles (in testCase)
 Function for testing the muscles strength.
 
function test_dynamicGRF (in testCase)
 Function for testing the GRF.
 
function test_s_static_upright_acc (in testCase)
 Function to test the simulated acc signal for static standing.
 
function test_s_static_upright_gyro (in testCase)
 Function to test the simulated gyro signal for static standing.
 
function test_s_hip_flexion_gyro (in testCase)
 Function to test the simulated gyro signal for hip flexion.
 
Tests: ModelTest
function derivativetest_Dynamics (in testCase)
 Function to test the derivatives of Model.getDynamics()
 
function derivativetest_GRF (in testCase)
 Function to test the derivatives of Model.getGRF()
 
function derivativetest_Moments (in testCase)
 Function to test the derivatives of Model.getJointmoments()
 
function derivativetest_SimuAccGyro_Acc (in testCase)
 Function to test the acc derivatives of Model.simuAccGyro()
 
function derivativetest_SimuAccGyro_Gyro (in testCase)
 Function to test the gyro derivatives of odel.simuAccGyro()
 
function test_speedOfMex (in testCase)
 Function for testing the speed of the MEX function.
 
function test_speedOfSimuAccGyro (in testCase)
 Function for testing the speed of Model.simuAccGyro().
 
function test_memory (in testCase)
 Function for testing memory use of the MEX function.
 
function test_dynamics (in testCase)
 Function for testing the correctness of the dynamic model.
 
function test_showStickNeutral (in testCase)
 Function for testing showStick()
 
function test_simulateFreefall (in testCase)
 Function to simulate freefall.
 

Public Attributes

Property model
 Model object.
 

Protected Member Functions

function contraction_equilibrium (in Lce)
 Function to get contraction equilibrium.
 
function doTest_derivativetest_SimuAccGyro (in testCase, in iCom)
 Function with test content to test Model.simuAccGyro()
 
function generateRandType (in testCase, in type, in isState)
 Function to generate a vector with random numbers of a specific type (e.g.
 
function grf_equilibrium (in xcontact)
 Helperfunction to test grf.
 
function halfstim (in testCase, in t)
 Helperfunction for muscle stimulation function for 50% muscle stimulation.
 
function isokinetic_curves (in testCase, in joint, in range)
 Function to plot isokinetic moment-angular velocity curves.
 
function isometric_curves (in testCase, in joint1, in range1, in joint2, in range2)
 Function to plot isometric curves.
 
function labels ()
 Adds labels to plot.
 
function labels ()
 Adds labels to plot.
 
function matcompare (in testCase, in value, in valueRef, in kind, in namesDim1, in namesDim2)
 Function to verify the derivative outcomes.
 
function maxmoment (in testCase, in joint, in angles, in angvel, in sign)
 Function to simulate maximum moment.
 
function nostim (in testCase, in t)
 Helperfunction for muscle stimulation function for passive simulation.
 
function setup_Test_Random (in testCase, in iCom)
 Function to setup the data.
 
function solvegrf (in testCase, in y, in vy, in xx, in vx, in vxc)
 Function to solves grf by search for static equilibrium in contact variables.
 
function step (in testCase, in stimfun, in x0, in trange, in nsteps, in options)
 Function to solve implicit differential equation for simulaton.
 
function stepgrf (in testCase, in xskeleton, in xinit, in times, in options)
 Function to solve implicit differential equation for simulaton for contact points.
 

Static Protected Member Functions

static function fsolve1 (in fun, in x0, in options)
 Function to solves f(x)=0 using Newton's method.
 

Protected Attributes

Constant Property COMMANDS = {'Acc', 'Gyro'}
 Names of different test conditions.
 
Property data
 Data for tracking tests.
 
Property grf_xc
 Used in test_grf() to keep the previous result as initial guess.
 
Constant Property TOL_DERIVATIVETEST = 10
 Tolerance to pass derivative tests: maxerror/value < tol.
 
Constant Property TOL_S = 10
 Tolerance to pass tests for Model.simuAccGyro()
 

Detailed Description

Test class to test the class Gait2dc.

Run single test selected by name:

testCase = Gait2dcTest;
testCase.model = Gait2dc('gait2dc_par.xls');
res = run(testCase, 'derivativetest_Dynamics');
The class describes the Gait2dc model.
Definition: Gait2dc.m:20
Test class to test the class Gait2dc.
Definition: Gait2dcTest.m:44
Property model
Model object.
Definition: ModelTest.m:38

Overview:

Testname/Tag Derivative Freefall Isometric Memory Speed Neutral getDynamics getGRF getJointmoments simuAccGyro showStick
derivativetest_Dynamics x x
derivativetest_SimuAccGyro_Acc x x
derivativetest_SimuAccGyro_Gyro x x
derivativetest_Moments x x
derivativetest_GRF x x
test_simulateFreefall x x
test_showStickNeutral x x
test_dynamics x x x
test_memory x x
test_speedOfSimuAccGyro x x
test_speedOfMex x x
test_s_hip_flexion_gyro x
test_s_static_upright_acc x x
test_s_static_upright_gyro x x
test_dynamicGRF x
test_isokineticMuscles x x x
test_isometricMuscles x x x
test_grf x

Member Function Documentation

◆ contraction_equilibrium()

function contraction_equilibrium ( in  Lce)
protected

Function to get contraction equilibrium.

Parameters
Lce
Return values
F

◆ derivativetest_Dynamics()

function derivativetest_Dynamics ( in  testCase)
inherited

Function to test the derivatives of Model.getDynamics()

Gait2dc

Example output:

Derivatives for Dynamics
dfdx: Max. difference is: 0.0001211260 (3450.3251510427 vs. 3450.3250299167) at 'dofs: hip_flexion_l: equations of motion from Autolev'(idx:16) and 's: Glutei_l'(idx:28)
dfdxdot: Max. difference is: 0.0000023285 ( -0.0212161829 vs. -0.0212185114) at 'dofs: hip_flexion_l: equations of motion from Autolev'(idx:16) and 'qdot: pelvis_ty'(idx:11)
dfdu: Max. difference is: 0.0000068123 (-152.4926607122 vs. -152.4926675245) at 'muscles: Rectus_l: activation dynamics: da/dt - (u-a)(c1*u + c2) = 0'(idx:46) and 'Rectus_l'(idx:12)

Gait3d

Example output:

Derivatives for Dynamics
dfdx: Max. difference is: 0.0027930663 (-46136.0346080336 vs. -46136.0318149673) at 'muscles: add_brev_l: contraction dynamics: f = Fsee - Fce - Fpee'(idx:122) and 's: add_brev_l'(idx:122)
dfdxdot: Max. difference is: 0.0010051358 (-494.0920577725 vs. -494.0930629083) at 'muscles: per_long_r: contraction dynamics: f = Fsee - Fce - Fpee'(idx:106) and 's: per_long_r'(idx:106)
dfdu: Max. difference is: 0.0000086362 (350.9248257347 vs. 350.9248170985) at 'muscles: glut_max3_l: activation dynamics: da/dt - rate * (u-a) = 0'(idx:223) and 'glut_max3_l'(idx:65)

◆ derivativetest_GRF()

function derivativetest_GRF ( in  testCase)
inherited

Function to test the derivatives of Model.getGRF()

Gait2dc

Example output:

Derivatives for GRF
dGRFdx: Max. difference is: 0.0000000055 ( -0.0688392154 vs. -0.0688392099) at 'right Mz'(idx:6) and 'Fy: toe_r'(idx:58)

Gait3d

Example output:

Derivatives for GRF
dGRFdx: Max. difference is: 0.0000000187 ( -0.9337272476 vs. -0.9337272289) at 'left My'(idx:11) and 'zc: CPL_l'(idx:337)

◆ derivativetest_Moments()

function derivativetest_Moments ( in  testCase)
inherited

Function to test the derivatives of Model.getJointmoments()

Gait2dc

Example output:

Derivatives for Moments
dMdx: Max. difference is: 0.0120983138 (41480.6475985067 vs. 41480.6355001929) at 'hip_flexion_l'(idx:7) and 's: Glutei_l'(idx:28)
dMdu: Max. difference is: 0.0000000000 ( 0.0000000000 vs. 0.0000000000) at 'pelvis_tx'(idx:1) and 'Iliopsoas_r'(idx:1)

Gait3d

Example output:

Derivatives for Moments
dMdx: Max. difference is: 0.1738820117 (-350944.6392260600 vs. -350944.8131080717) at 'hip_flexion_r'(idx:7) and 'q: hip_flexion_r'(idx:7)
dMdu: Max. difference is: 0.0000000000 ( 0.0000000000 vs. 0.0000000000) at 'pelvis_tx'(idx:1) and 'Iliopsoas_r'(idx:1)

◆ derivativetest_SimuAccGyro_Acc()

function derivativetest_SimuAccGyro_Acc ( in  testCase)
inherited

Function to test the acc derivatives of Model.simuAccGyro()

Gait2dc

Example output:

Derivatives for Acc
dsdq: Max. difference is: 0.0000000227 ( 1.7175791416 vs. 1.7175791189) at '4'(idx:4) and 'hip_flexion_r'(idx:4)
dsdqd: Max. difference is: 0.0000000229 ( -0.8737816552 vs. -0.8737816781) at '4'(idx:4) and 'pelvis_tilt'(idx:3)
dsdqdd: Max. difference is: 0.0000000271 ( 0.2436197648 vs. 0.2436197377) at '4'(idx:4) and 'pelvis_tx'(idx:1)

Gait3d

Example output:

Derivatives for Acc
dsdq: Max. difference is: 0.0000016256 ( 1.7379826469 vs. 1.7379810213) at '10'(idx:7) and 'pelvis_tilt'(idx:1)
dsdqd: Max. difference is: 0.0000000929 ( -1.5895990794 vs. -1.5895991723) at '10'(idx:7) and 'hip_rotation_l'(idx:16)
dsdqdd: Max. difference is: 0.0000000209 ( 0.0951314259 vs. 0.0951314050) at '5'(idx:4) and 'pelvis_list'(idx:2)

◆ derivativetest_SimuAccGyro_Gyro()

function derivativetest_SimuAccGyro_Gyro ( in  testCase)
inherited

Function to test the gyro derivatives of odel.simuAccGyro()

Gait2dc

Example output:

Derivatives for Gyro
dsdq: Max. difference is: 0.0000000000 ( 0.0000000000 vs. 0.0000000000) at '1'(idx:1) and 'pelvis_tx'(idx:1)
dsdqd: Max. difference is: 0.0000000061 ( 1.0000000000 vs. 0.9999999939) at '4'(idx:4) and 'pelvis_tilt'(idx:3)
dsdqdd: Max. difference is: 0.0000000000 ( 0.0000000000 vs. 0.0000000000) at '1'(idx:1) and 'pelvis_tx'(idx:1)

Gait3d

Example output:

Derivatives for Gyro
dsdq: Max. difference is: 0.0000000843 ( 0.6910369209 vs. 0.6910368366) at '3'(idx:2) and 'hip_adduction_r'(idx:8)
dsdqd: Max. difference is: 0.0000000081 ( 0.8115557434 vs. 0.8115557515) at '5'(idx:4) and 'hip_rotation_r'(idx:9)
dsdqdd: Max. difference is: 0.0000000000 ( 0.0000000000 vs. 0.0000000000) at '2'(idx:1) and 'pelvis_tilt'(idx:1)

◆ doTest_derivativetest_SimuAccGyro()

function doTest_derivativetest_SimuAccGyro ( in  testCase,
in  iCom 
)
protectedinherited

Function with test content to test Model.simuAccGyro()

◆ fsolve1()

static function fsolve1 ( in  fun,
in  x0,
in  options 
)
staticprotectedinherited

Function to solves f(x)=0 using Newton's method.

Parameters
fun
x0
options
Return values
x
f
info
iterations

◆ generateRandType()

function generateRandType ( in  testCase,
in  type,
in  isState 
)
protectedinherited

Function to generate a vector with random numbers of a specific type (e.g.

q or u)

Usage:

x = testCase.generateRandType('States');
u = testCase.generateRandType('Controls');
q = testCase.generateRandType('q', 1);
M = testCase.generateRandType('torque', 0);
Parameters
testCase
typeString: Either 'States' or 'Controls' or a type which has to be identical to the type specified in model.states or in model.controls
isState(optional) Boolean: Needed if type is not 'States' or 'Controls'. If true, the type is in the model.states. Otherwise we search in the model.controls.
Return values
randTypeDouble vector: Vector containing uniformly sampled random numbers of that type in the interval [xmin, xmax] which is specified in model.states or model.controls

◆ grf_equilibrium()

function grf_equilibrium ( in  xcontact)
protected

Helperfunction to test grf.

Parameters
xcontact
Return values
F
J

◆ halfstim()

function halfstim ( in  testCase,
in  t 
)
protectedinherited

Helperfunction for muscle stimulation function for 50% muscle stimulation.

Todo:
Does it make sense to use 0.5 for all? We should differentiate between muscle exctitation and torques
Parameters
testCase
t
Return values
u

◆ isokinetic_curves()

function isokinetic_curves ( in  testCase,
in  joint,
in  range 
)
protected

Function to plot isokinetic moment-angular velocity curves.

Parameters
testCase
joint
range

◆ isometric_curves()

function isometric_curves ( in  testCase,
in  joint1,
in  range1,
in  joint2,
in  range2 
)
protected

Function to plot isometric curves.

Produces isometric moment-angle curves for a joint, one for each value in a range of angles in second joint. Third joint angle is kept zero.

Parameters
testCase
joint1
range1
joint2
range2

◆ labels() [1/2]

function labels ( )
protected

Adds labels to plot.

◆ labels() [2/2]

function labels ( )
protected

Adds labels to plot.

◆ matcompare()

function matcompare ( in  testCase,
in  value,
in  valueRef,
in  kind,
in  namesDim1,
in  namesDim2 
)
protectedinherited

Function to verify the derivative outcomes.

Parameters
testCase
valueArray or Matrix: Derivatives of Model class
valueRefArray or Matrix: Reference derivatives
kindString: Name of derivative (e.g. dfdx)
namesDim1(optional) Cell array with strings: Names defining the first dimension of the value
namesDim2(optional) Cell array with strings: Names defining the second dimension of the value

◆ maxmoment()

function maxmoment ( in  testCase,
in  joint,
in  angles,
in  angvel,
in  sign 
)
protected

Function to simulate maximum moment.

Simulates maximum moment at one joint, as function of all joint angles and angular velocities.

Parameters
testCase
jointFor which joint we will calculate moment.
anglesThe six joint angles (deg).
angvelThe six angular velocities (deg/s).
sign0: passive, 1: max positive moment, -1: max negative moment.
Return values
mom

◆ nostim()

function nostim ( in  testCase,
in  t 
)
protectedinherited

Helperfunction for muscle stimulation function for passive simulation.

Parameters
testCase
t
Return values
u

◆ setup_Test_Random()

function setup_Test_Random ( in  testCase,
in  iCom 
)
protected

Function to setup the data.

Parameters
testCase
iCom
Return values
testCase

◆ solvegrf()

function solvegrf ( in  testCase,
in  y,
in  vy,
in  xx,
in  vx,
in  vxc 
)
protected

Function to solves grf by search for static equilibrium in contact variables.

Parameters
testCase
y
vy
xx
vx
vxc
Return values
grfGround reaction force

◆ step()

function step ( in  testCase,
in  stimfun,
in  x0,
in  trange,
in  nsteps,
in  options 
)
protectedinherited

Function to solve implicit differential equation for simulaton.

Solves the implicit differential equation fmin <= f(x,dx/dt,u) <= fmax using the midpoint Euler method, with constant stepsize, and Newton iteration.

Parameters
testCase
stimfunA function u = fun(t) to stimulate the muscles.
x0Initial system state.
trange[starttime enddtime]
nstepsHow many time steps to take.
optionsStruct with fields:
  • tol: Tolerance
  • maxiterations: Maximum number of Newton iterations
Return values
toutVector of time points (ntimes x 1).
xoutSolution vectors (nstates x ntimes).
info0: success, -1: maximum number of iterations exceeded.
nevalNumber of evaluations.

◆ stepgrf()

function stepgrf ( in  testCase,
in  xskeleton,
in  xinit,
in  times,
in  options 
)
protected

Function to solve implicit differential equation for simulaton for contact points.

Solves the implicit differential equation f(x,dx/dt) = 0 for the contact variables.

Parameters
testCase
xskeleton
xinit
times
options
Return values
tout
xout
info
neval

◆ test_dynamicGRF()

function test_dynamicGRF ( in  testCase)

Function for testing the GRF.

The foot will be moved along a prescribed trajectory, which is circular with diminishing radius. The speed is one revolution per second. (See "2D Model with Contact (gait2dc) Reference Manual for Version 1.0")

Test dynamic GRFs
Number of time steps: 1100
Number of function evaluations: 23955
Todo:
Add error checking

◆ test_dynamics()

function test_dynamics ( in  testCase)
inherited

Function for testing the correctness of the dynamic model.

Free fall dynamics test: This test shows the correctness of the dynamic model f = f(x,xdot,u,M) = 0. Therefore, the model is put in a freefall acceleration state, so residuals should be zero when acceleration is -g for DOF 5 and zero elsewhere. Moreover, the joint moments of the model in its neutral position are computed and should be zero.

Gait2dc

Dynamics violations:

Joint moments:

GRFs:

Gait3d

Dynamics violations:

Joint moments:

GRFs:

◆ test_grf()

function test_grf ( in  testCase)

Function for testing the ground reaction force model.

This test evaluates the contact model. To test the vertical force, the model is put in a series of positions with different hip height. The vertical ground reaction force at the heel is plotted as a function of hip height. The result (left side of Figure) shows the total force-deformation relationship of the contact model, i.e. deformation of the contact point relative to the foot, and the interaction between the foot and ground. To test the horizontal force, the model is put in three of these hip positions, and the horizontal velocity is varied. The resulting horizontal force is simulated and shown on the right side of the Figure.

Todo:
Add error checking

◆ test_isokineticMuscles()

function test_isokineticMuscles ( in  testCase)

Function for testing the muscles strength.

For the isokinetic test, the model is placed in the neutral position (hips and ankles at zero degrees, knees at 5 degrees flexion). At each joint, angular velocity is then varied from -1000 to +1000 deg/s. At each angular velocity, the state of the system is found that produces steady state muscle forces (dF/dt = 0). The muscle forces are then converted to joint moments and plotted. This is done separately for the flexors and extensors. (See "2D Model with Contact (gait2dc) Reference Manual for Version 1.0")

Todo:
Add error checking

◆ test_isometricMuscles()

function test_isometricMuscles ( in  testCase)

Function for testing the muscles strength.

This puts the model into various joint angle combinations and activates the muscle set three times for each joint. First, activating the muscles that contribute to positive moment. Second, activating the muscles that contribute to a negative moment. Third, no activation, to obtain the passive moment. (See "2D Model with Contact (gait2dc) Reference Manual for Version 1.0")

Todo:
Add error checking

◆ test_memory()

function test_memory ( in  testCase)
inherited

Function for testing memory use of the MEX function.

This tests the memory usage of the multibody dynamics. The MEX function is executed 500000 times with random inputs, and the resulting memory usage is plotted.

This function is only working at Windows!

Gait2dc

Gait3d

Todo:
Add error checking

◆ test_s_hip_flexion_gyro()

function test_s_hip_flexion_gyro ( in  testCase)

Function to test the simulated gyro signal for hip flexion.

Simulates the gyropscope signal at calcn_r for hip flexion with 100 r/s.

◆ test_s_static_upright_acc()

function test_s_static_upright_acc ( in  testCase)

Function to test the simulated acc signal for static standing.

Tests that the acceleration at calcn_r is equal to gravity during static standing.

◆ test_s_static_upright_gyro()

function test_s_static_upright_gyro ( in  testCase)

Function to test the simulated gyro signal for static standing.

Tests that the gyropscope signal at calcn_r is equal to 0 during static standing.

◆ test_showStickNeutral()

function test_showStickNeutral ( in  testCase)
inherited

Function for testing showStick()

This tests plots a stick figure for the neutral position of the model.

Gait2dc

Gait3d

Todo:
Add error checking

◆ test_simulateFreefall()

function test_simulateFreefall ( in  testCase)
inherited

Function to simulate freefall.

The model is placed in a neutral position. We drop the model on the ground. This is done twice, once with passive muscles and once with muscles that are 50% activated. It uses the implicit midpoint Euler method (van den Bogert et al., 2011) with a step size of 10 ms.

The second simulation (with activated muscles) is then repeated with a step size of 1 ms. The results are compared with the 10 ms stepsize.

Gait2dc

Example outpu:

Running test_simulateFreefall:
1. Running passive freefall simulation...
Number of time steps: 400
Number of function evaluations: 2572
2. Running active freefall simulation...
Number of time steps: 400
Number of function evaluations: 2285
3. Running active freefall simulation with smaller steps...
Number of time steps: 4000
Number of function evaluations: 16259

Gait3d

Example output:

Running test_simulateFreefall:
1. Running passive freefall simulation...
Number of time steps: 400
Number of function evaluations: 3120
2. Running active freefall simulation...
Number of time steps: 1
Number of function evaluations: 1129
3. Running active freefall simulation with smaller steps...
Number of time steps: 4000
Number of function evaluations: 17836
Todo:
The second simulation is not solving for 3D. And switching from Windows to Linux caused that also the first simulation is not solving. A difference in the compilers maybe caused this...

◆ test_speedOfMex()

function test_speedOfMex ( in  testCase)
inherited

Function for testing the speed of the MEX function.

This tests the execution time of the multibody dynamics, without and with derivatives. The MEX function is executed 1000 times with random inputs, and the resulting time is divided by 1000.

Gait2dc

Example output:

Speed test
Evaluation of dynamics function without derivatives: 1.100 ms
Evaluation of dynamics function with derivatives: 0.831 ms

Gait3d

Example output:

Speed test
Evaluation of dynamics function without derivatives: 3.340 ms
Evaluation of dynamics function with derivatives: 4.998 ms
Todo:
Add error checking

◆ test_speedOfSimuAccGyro()

function test_speedOfSimuAccGyro ( in  testCase)
inherited

Function for testing the speed of Model.simuAccGyro().

This tests the execution time of Model.simuAccGyro(), without and with derivatives. The simuAccGyro() is executed 1000 times with random inputs, and the resulting time is divided by 1000.

Gait2dc

Example output for 3 (acc x, acc y, acc z) times 7 (trunk, legs, feet) IMU signals:

Speed test of SimuAccGyro()
Evaluation of dynamics function without Jacobians: 1.714 ms
Evaluation of dynamics function with Jacobians: 3.047 ms

Gait3d

Example output for 6 (all acc and gyro) times 7 (trunk, legs, feet) IMU signals::

Speed test of simuAccGyro()
Evaluation of dynamics function without Jacobians: 4.066 ms
Evaluation of dynamics function with Jacobians: 26.996 ms
Todo:
Add error checking

Member Data Documentation

◆ COMMANDS

Constant Property COMMANDS = {'Acc', 'Gyro'}
protectedinherited

Names of different test conditions.

◆ data

Property data
protectedinherited

Data for tracking tests.

◆ grf_xc

Property grf_xc
protectedinherited

Used in test_grf() to keep the previous result as initial guess.

◆ model

Property model
inherited

Model object.

◆ TOL_DERIVATIVETEST

Constant Property TOL_DERIVATIVETEST = 10
protectedinherited

Tolerance to pass derivative tests: maxerror/value < tol.

◆ TOL_S

Constant Property TOL_S = 10
protectedinherited

Tolerance to pass tests for Model.simuAccGyro()


The documentation for this class was generated from the following file: