Biomech-Sim-Toolbox 1
Toolbox for movement simulation and analysis
|
Test class to test the class Gait2d_osim. More...
Public Member Functions | |
Tests: Gait3dTest | |
function | test_grf (in testCase) |
Function for testing the ground reaction force model. | |
function | derivativetest_Fkin (in testCase) |
Function to test the derivatives of Gait3d.getFkin() | |
function | test_Fkin (in testCase) |
Function for testing the forward kinematic model Gait3d.getFkin(). | |
function | test_isometric (in testCase) |
Function for testing the isometric joint moments. | |
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_acc (in testCase) |
Function to test the simulated acc signal for hip flexion. | |
function | test_s_pelvis_rotation_acc (in testCase) |
Function to test the simulated acc signal for pelvis rotation | |
function | test_s_hip_flexion_gyro (in testCase) |
Function to test the simulated gyro signal for hip flexion. | |
function | test_s_pelvis_rotation_gyro (in testCase) |
Function to test the simulated acc signal for pelvis rotation | |
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 | grfoptions |
Struct: Options for Ipopt for test_grf() | |
Property | grftmp |
Struct: Temporary storage for test_grf() | |
Property | model |
Model object. | |
Protected Member Functions | |
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 | grfconfun (in testCase, in X) |
Subfunction for GRF testing. | |
function | grfjacobian (in testCase, in X) |
Subfunction for GRF testing. | |
function | halfstim (in testCase, in t) |
Helperfunction for muscle stimulation function for 50% muscle stimulation. | |
function | matcompare (in testCase, in value, in valueRef, in kind, in namesDim1, in namesDim2) |
Function to verify the derivative outcomes. | |
function | maxmom (in testCase, in x, in idof, in direction) |
Function to find the maximal moment for a joint. | |
function | moments (in testCase, in idof) |
Function to generate active and passive joint moment curves. | |
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 vx) |
Subfunction for GRF testing. | |
function | step (in testCase, in stimfun, in x0, in trange, in nsteps, in options) |
Function to solve implicit differential equation for simulaton. | |
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() | |
Test class to test the class Gait2d_osim.
Run single test selected by name:
Overview:
Testname/Tag | Derivative | Freefall | Isometric | Memory | Speed | Neutral | getDynamics | getFkin | getGRF | getJointmoments | getMuscleforces | simuAccGyro | showStick |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
derivativetest_Dynamics | x | x | |||||||||||
derivativetest_SimuAccGyro_Acc | x | x | |||||||||||
derivativetest_SimuAccGyro_Gyro | x | x | |||||||||||
derivativetest_Moments | x | x | |||||||||||
derivativetest_GRF | x | x | |||||||||||
derivativetest_Fkin | 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_pelvis_rotation_gyro | x | ||||||||||||
test_s_hip_flexion_acc | x | x | |||||||||||
test_s_pelvis_rotation_acc | x | x | |||||||||||
test_s_static_upright_acc | x | x | |||||||||||
test_s_static_upright_gyro | x | x | |||||||||||
test_isometric | x | x | x | x | |||||||||
test_Fkin | x | x | |||||||||||
test_grf | x |
|
inherited |
Function to test the derivatives of Model.getDynamics()
Example output:
Example output:
function derivativetest_Fkin | ( | in | testCase | ) |
Function to test the derivatives of Gait3d.getFkin()
Example output:
|
inherited |
Function to test the derivatives of Model.getGRF()
Example output:
Example output:
|
inherited |
Function to test the derivatives of Model.getJointmoments()
Example output:
Example output:
|
inherited |
Function to test the acc derivatives of Model.simuAccGyro()
Example output:
Example output:
|
inherited |
Function to test the gyro derivatives of odel.simuAccGyro()
Example output:
Example output:
|
protectedinherited |
Function with test content to test Model.simuAccGyro()
|
staticprotectedinherited |
Function to solves f(x)=0 using Newton's method.
fun | |
x0 | |
options |
x | |
f | |
info | |
iterations |
|
protectedinherited |
Function to generate a vector with random numbers of a specific type (e.g.
q or u)
Usage:
testCase | |
type | String: 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. |
randType | Double vector: Vector containing uniformly sampled random numbers of that type in the interval [xmin, xmax] which is specified in model.states or model.controls |
|
protected |
Subfunction for GRF testing.
testCase | |
X |
c |
|
protected |
Subfunction for GRF testing.
testCase | |
X |
J |
|
protectedinherited |
Helperfunction for muscle stimulation function for 50% muscle stimulation.
testCase | |
t |
u |
|
protectedinherited |
Function to verify the derivative outcomes.
testCase | |
value | Array or Matrix: Derivatives of Model class |
valueRef | Array or Matrix: Reference derivatives |
kind | String: 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 |
|
protected |
Function to find the maximal moment for a joint.
Function to find the maximal moment for a joint with the model in posture given by x while muscles are required to be in equilibrium contraction state.
testCase | |
x | posture of the model |
idof | which joint moment we want to maximize |
direction | +1 for max moment, -1 for min moment |
M | the maximum moment |
x | the system state that produces the max moment (can be used as initial guess for next function call) |
|
protected |
Function to generate active and passive joint moment curves.
testCase | |
idof |
angles | |
pasmom | |
actmax | |
actmin |
|
protectedinherited |
Helperfunction for muscle stimulation function for passive simulation.
testCase | |
t |
u |
|
protected |
Function to setup the data.
testCase | |
iCom |
testCase |
|
protected |
Subfunction for GRF testing.
Function to solves grf by search for static equilibrium in contact variables
testCase | |
y | |
vy | |
vx |
Fx | |
Fy | |
x |
|
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.
testCase | |
stimfun | A function u = fun(t) to stimulate the muscles. |
x0 | Initial system state. |
trange | [starttime enddtime] |
nsteps | How many time steps to take. |
options | Struct with fields:
|
tout | Vector of time points (ntimes x 1). |
xout | Solution vectors (nstates x ntimes). |
info | 0: success, -1: maximum number of iterations exceeded. |
neval | Number of evaluations. |
|
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.
Dynamics violations:
Joint moments:
GRFs:
Dynamics violations:
Joint moments:
GRFs:
function test_Fkin | ( | in | testCase | ) |
Function for testing the forward kinematic model Gait3d.getFkin().
This test sequentially animates the kinematic degrees of freedom. First, the model is placed in a neutral position. Then each degree of freedom is animated. After that the Jacobian dFk/dq is computed i.e., the deritive of every segment position and orientation with respect to each kinematic degree of freedom. The result is compared to finite differences and the sparsity of the jacobian is plotted.
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.
function test_isometric | ( | in | testCase | ) |
|
inherited |
function test_s_hip_flexion_acc | ( | in | testCase | ) |
Function to test the simulated acc signal for hip flexion.
Simulates the acceleration signal at calcn_r for hip flexion with 100 r/s. The expected acceleration is computed based on the radius (computed from positions of segments) and known rotational velocity.
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.
function test_s_pelvis_rotation_acc | ( | in | testCase | ) |
Function to test the simulated acc signal for pelvis rotation
Simulates the acceleration signal at calcn_r for pelvis rotation around 45 Deg and a hip flexion rate of 100 rad/s. The expected acceleration is computed based on the radius (computed from positions of segments), the known hip rotation and known rotational velocity.
function test_s_pelvis_rotation_gyro | ( | in | testCase | ) |
Function to test the simulated acc signal for pelvis rotation
Simulates the acceleration signal at calcn_r for pelvis rotation around 45 Deg and a hip flexion rate of 100 rad/s. The expected gyroscope signal is computed based on the known hip rotation and known rotational velocity.
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.
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.
|
inherited |
|
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.
Example outpu:
Example output:
|
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.
Example output:
Example output:
|
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.
Example output for 3 (acc x, acc y, acc z) times 7 (trunk, legs, feet) IMU signals:
Example output for 6 (all acc and gyro) times 7 (trunk, legs, feet) IMU signals::
|
protectedinherited |
Names of different test conditions.
|
protectedinherited |
Data for tracking tests.
|
protectedinherited |
Used in test_grf() to keep the previous result as initial guess.
Property grfoptions |
Struct: Options for Ipopt for test_grf()
Property grftmp |
Struct: Temporary storage for test_grf()
|
inherited |
Model object.
|
protectedinherited |
Tolerance to pass derivative tests: maxerror/value < tol.
|
protectedinherited |
Tolerance to pass tests for Model.simuAccGyro()