Manual
User Manual:
Open the PDF directly: View PDF
.
Page Count: 8
| Download | |
| Open PDF In Browser | View PDF |
Manual SimTK optcntrlmuscle (v1.1)
Antoine Falisse, Maarten Afschrift, Friedl De Groote
04/18/2017
Contents
1 Overview
1
2 Installation Instruction
2
3 Main Function
3.1 With explicit activation dynamics formulation (De Groote et al. (2016))
3.2 With implicit activation dynamics formulation (De Groote et al. (2009))
3.3 Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4 Output arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
2
2
2
3
4
4 GPOPS-II
4.1 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
5
5
5 Muscle model
5
6 Examples
6.1 Walking example De Groote et al. 2016 . . .
6.2 Running example De Groote et al. 2016 . . .
6.3 OpenSim installation example Gait10dof18m
6.4 OpenSim installation example Gait23dof54m
5
5
6
7
7
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Overview
The provided MATLAB code solves the muscle redundancy problem using the direct collocation
optimal control software GPOPS-II as described in De Groote F, Kinney AL, Rao AV, Fregly
BJ. Evaluation of direct collocation optimal control problem formulations for solving the muscle
redundancy problem. Annals of Biomedical Engineering (2016). http://link.springer.com/
article/10.1007%2Fs10439-016-1591-9.
From v1.1, an implicit formulation of activation dynamics can be used to solve the muscle redundancy problem. Additionally, by using the activation dynamics model proposed by Raasch
et al. (1997), we could introduce a nonlinear change of variables to exactly impose activation dynamics in a continuously differentiable form, omitting the need for a smooth approximation such as described in De Groote et al. (2016). A result of this change of variables
is that muscle excitations are not directly accessible during the optimization. Therefore, we
1
replaced muscle excitations by muscle activations in the objective function. This implicit formulation is described in De Groote F, Pipeleers G, Jonkers I, Demeulenaere B, Patten C,
Swevers J, De Schutter J. A physiology based inverse dynamic analysis of human gait: potential
and perspectives F. Computer Methods in Biomechanics and Biomedical Engineering (2009).
http://www.tandfonline.com/doi/full/10.1080/10255840902788587.
Results from both formulations are very similar (differences can be attributed to the slightly
different activation dynamics models and cost functions). However, the formulation with implicit
activation dynamics (De Groote et al., (2009)) is computationally faster. This can mainly be
explained by the omission of a tanh function in the constraint definition, whose evaluation is
computationally expensive when solving the NLP.
2
Installation Instruction
Add the main folder and subfolder to your MATLAB path
1
addpath(genpath('C/......./SimTK optcntrlmuscle'))).
Several software packages are needed to run the program
The OpenSim MATLAB interface is used to generate the inputs to the optimal control
problem based on a scaled OpenSim model and the solution of inverse kinematics (providing the solution of inverse dynamics is optional). To this aim, install OpenSim and set
up the OpenSim MATLAB interface (OpenSim: https://simtk.org/frs/?group_id=
91, OpenSim API: http://simtk-confluence.stanford.edu:8080/display/OpenSim/
Scripting+with+Matlab).
GPOPS-II is used to solve the optimal control problem using direct collocation (http:
//www.gpops2.com/). A one-time 30-day trial license is avaiable for all users who register.
ADiGator is used for automatic differentiation (https://sourceforge.net/projects/
adigator/).
3
Main Function
SolveMuscleRedundancy is the main function of this program and is used to solve the muscle
redundancy problem. There are four variants of this function:
3.1
With explicit activation dynamics formulation (De Groote et al. (2016))
SolveMuscleRedundancy FtildeState uses the normalized tendon force as a state
SolveMuscleRedundancy lMtildeState uses the normalized muscle fiber length as a state
3.2
With implicit activation dynamics formulation (De Groote et al. (2009))
SolveMuscleRedundancy FtildeState actdyn uses the normalized tendon force as a state
SolveMuscleRedundancy lMtildeState actdyn uses the normalized muscle fiber length as
a state
2
3.3
Input Arguments
Required Input arguments for SolveMuscleRedundancy
1. model path: directory and filename of the scaled OpenSim model (.osim). The code
should work with any OpenSim model with valid muscle-tendon parameters for which
OpenSim’s Inverse Dynamics and Muscle Analysis Tools generate reliable results. Note
that only the muscle-tendon parameters and not the muscle model specified in the osim-file
are used (for details see Muscle model).
2. IK path: directory and filename of the inverse kinematics solution (.mot file).
3. ID path: directory and filename of the inverse dynamics solution (.sto file). If left empty,
the inverse dynamics solution will be computed from the external loads (see Optional input
arguments).
4. time: 1 x 2 MATLAB array with the initial and final time of the analysis in seconds.
Initial and final states influence the optimal controls over a period of about 50 ms at the
beginning and end of the time interval over which the optimal control problem is solved.
Since in practice the initial and final states are generally unknown, problems should be
solved for a time interval containing five additional data points (considering a 100Hz
sampling frequency) at the beginning and end of the motion cycle. Those additional data
points should not be considered in further analyses. The user should thus not be surprised
to observe unrealistically high muscle activation at the beginning of the motion (more
details in companion paper).
5. OutPath: directory where you want to store the results from the muscle analysis.
6. Misc: miscellaneous input arguments
DofNames Input is a cell array specifying for which degrees of freedom you want to
solve the muscle redundancy problem. Typically the muscle redundancy problem is
solved for one leg at a time (there are no muscles spanning both legs).
MuscleNames Input is a cell array that specifies the muscles to be included in when
solving the muscle redundancy problem. All muscles that actuate (i.e. have a moment
arm with respect to) the degrees of freedom specified in DofNames Input will be
selected by default if this array is empty.
Optional input arguments
1. Misc.Loads path: path to the external loads file (.xml). The program will use the OpenSim
libraries to solve the inverse dynamics problem when the required input argument ID path
is empty and Misc.Loads path points to an external loads file.
2. Misc.ID ResultsPath: Path where the inverse dynamics results will be saved when the
required input argument ID path is empty.
3. Misc.f cutoff ID: Cutoff frequency for the butterworth recursive low pass filter applied to
the inverse dynamics data (default is 6 Hz).
4. Misc.f order ID: order of the butterworth recursive low pass filter applied to the inverse
dynamics data (default is 6).
3
5. Misc.f cutoff LMT : cutoff frequency for butterworth recursive low pass filter applied to
the muscle tendon lengths from the muscle analysis (default 6 Hz).
6. Misc.f order LMT : order of the butterworth recursive low pass filter applied to the muscle
tendon lengths from the muscle analysis (default 6).
7. Misc.f cutoff dM : cutoff frequency for butterworth recursive low pass filter applied to the
muscle moment arms from the muscle analysis (default 6 Hz).
8. Misc.f order dM : order of the butterworth recursive low pass filter applied to the muscle
moment arms from the muscle analysis (default 6).
9. Misc.f cutoff IK : cutoff frequency for the butterworth recursive low pass filter applied
to the inverse kinematics data (default is 6 Hz) when performing the muscle analysis to
compute muscle-tendon lengths and moment arms.
10. Misc.f order IK : order of the butterworth recursive low pass filter applied to the inverse
kinematics data (default is 6).
11. Misc.Mesh Frequency: Number of mesh interval per second (default is 100, but a denser
mesh might be required to obtain the desired accuracy especially for faster motions).
3.4
Output arguments
1. Time: time vector.
2. MExcitation: optimal muscle excitation (matrix dimension: number of collocation points
x number of muscles).
3. MActivation: optimal muscle activation (matrix dimension: number of collocation points
x number of muscles).
4. RActivation: activation of the reserve actuators (matrix dimension: number of collocation
points x number of degrees of freedom).
5. TForcetilde: normalized tendon force (matrix dimension: number of collocation points x
number of muscles).
6. TForce: tendon force (matrix dimension: number of collocation points x number of muscles).
7. lMtilde: normalized muscle fiber length (matrix dimension: number of collocation points
x number of muscles).
8. lM: muscle fiber length (matrix dimension: number of collocation points x number of
muscles) .
9. MuscleNames: cell array that contains the names of the selected muscles (matrix dimension: number of muscles).
10. OptInfo: output structure created by GPOPS-II.
11. DatStore: data structure with input information for the optimal control problem.
4
4
GPOPS-II
4.1
Setup
The GPOPS-II setup is accessible through the function SolveMuscleRedundancy < state >.m
under GPOPS setup. The user is referred to the GPOPS-II user guide for setup options. A
higher accuracy can be reached by adjusting, for instance, the number of mesh intervals. This
however comes at the expense of the computational time. 100 mesh intervals per second are
used by default.
4.2
Output
The GPOPS-II output, OptInfo, contains all information related to the optimal control problem
solution. Convergence to an optimal solution is reached when output.result.nlpinfo is flagged 0
(”EXIT: Optimal solution found” in the command window of MATLAB). The mesh accuracy
can be assessed with output.result.maxerrors. Cost functional, control, state (and costate) can
be accessed in output.result.solution.phase.
To recall, the user should consider extending the time interval by 50-100 ms at the beginning and
end of the motion to limit the influence of the unknown initial and final state on the solution.
Results from those additional periods should not be considered realistic and will typically result
in high muscle activation.
5
Muscle model
The musculotendon properties are fully described in the supplementary materials of the aforementioned publication. Importantly, only the tendon slack length, optimal muscle fiber length,
maximal isometric muscle force, optimal pennation angle and maximal muscle fiber contraction
velocity are extracted from the referred OpenSim model. Other properties are defined in the code
and can be changed if desired. By default, the activation and deactivation time constants are
15 and 60 ms respectively (see tau act and tau deact in SolveMuscleRedundancy < state >.m).
6
Examples
Four examples are provided in the folder examples.
6.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Walking example De Groote et al. 2016
clear all ; close all ; clc
%% Choose f o r m u l a t i o n
% formulation = ' lMtildeState ' ;
formulation = ' FtildeState ' ;
%% Choose a c t i v a t i o n dynamics
% a c t d y n = ' DeGroote2016 ' ;
a c t d y n = ' DeGroote2009 ' ;
%% Example
% add main f o l d e r and s u b f o l d e r t o matlab path ( i n s t a l l a t i o n )
f i l e p a t h=which ( ' W a l k i n g D e G r o o t e e t a l 2 0 1 6 . m ' ) ;
[ DirExample Walking , ¬ ,¬]= f i l e p a r t s ( f i l e p a t h ) ; ...
[ DirExample , ¬]= f i l e p a r t s ( DirExample Walking ) ; [ MainDir , ¬]= f i l e p a r t s ( DirExample ) ;
addpath ( g e n p a t h ( MainDir ) ) ;
% Needed I n p u t Arguments
I K p a t h= f u l l f i l e ( MainDir , ' Examples ' , ' W a l k i n g D e G r o o t e e t a l 2 0 1 6 ' , ' WalkingData ' , ' i n v e r s e k i n e m a t i c s . m o t ' ) ;
I D p a t h= f u l l f i l e ( MainDir , ' Examples ' , ' W a l k i n g D e G r o o t e e t a l 2 0 1 6 ' , ' WalkingData ' , ' i n v e r s e d y n a m i c s . s t o ' ) ;
m o d e l p a t h= f u l l f i l e ( MainDir , ' Examples ' , ' W a l k i n g D e G r o o t e e t a l 2 0 1 6 ' , ' WalkingData ' , ' s u b j e c t 0 1 . o s i m ' ) ;
5
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
t i m e =[0 . 5 1 6 1 . 9 5 ] ; % R i g h t s t a n c e p h a s e (+50ms b e g i n n i n g and end o f t i m e i n t e r v a l , more
d e t a i l s s e e manual and p u b l i c a t i o n )
OutPath= f u l l f i l e ( MainDir , ' Examples ' , ' W a l k i n g D e G r o o t e e t a l 2 0 1 6 ' , ' R e s u l t s ' ) ;
M i s c . M u s c l e N a m e s I n p u t ={}; % S e l e c t s a l l m u s c l e s f o r t h e I n p u t DOFS when t h i s i s l e f t empty .
M i s c . D o f N a m e s I n p u t={ ' a n k l e a n g l e r ' , ' k n e e a n g l e r ' , ' h i p f l e x i o n r ' , ' h i p r o t a t i o n r ' , ' h i p a d d u c t i o n r
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'
};
% O p t i o n a l I n p u t Arguments
% c u t o f f f r e q u e n c y f i l t e r i n g ID
Misc.f cutoff ID = 6;
Misc.f order ID = 4;
% o r d e r f r e q u e n c y f i l t e r i n g ID
% c u t o f f f r e q u e n c y f i l t e r i n g lMT
Misc.f cutoff lMT = 6;
Misc.f order lMT = 4;
% o r d e r f r e q u e n c y f i l t e r i n g lMT
% c u t o f f f r e q u e n c y f i l t e r i n g MA
M i s c . f c u t o f f d M= 6 ;
Misc.f order dM = 4;
% o r d e r f r e q u e n c y f i l t e r i n g MA
M i s c . f c u t o f f I K= 6 ;
% c u t o f f f r e q u e n c y f i l t e r i n g IK
% o r d e r f r e q u e n c y f i l t e r i n g IK
Misc.f order IK = 4;
Misc.Atendon = [ ] ;
% Tendon S t i f f n e s s f o r t h e s e l e c t e d m u s c l e s
%% S o l v e t h e problem
switch actdyn
c a s e ' DeGroote2016 ' % A c t i v a t i o n dynamics from De G r o o t e e t a l . ( 2 0 1 6 )
switch formulation
case ' lMtildeState '
[ Time , M E x c i t a t i o n , M A c t i v a t i o n , R A c t i v a t i o n , T F o r c e t i l d e , TForce , l M t i l d e , lM , MuscleNames , O p t I n f o , D a t S t
case ' FtildeState '
[ Time , M E x c i t a t i o n , M A c t i v a t i o n , R A c t i v a t i o n , T F o r c e t i l d e , TForce , l M t i l d e , lM , MuscleNames , O p t I n f o , D a t S t
end
case
' DeGroote2009 ' % A c t i v a t i o n dynamics from De G r o o t e e t
a l . (2009)
switch formulation
case ' lMtildeState '
[ Time actdyn , M E x c i t a t i o n a c t d y n , M A c t i v a t i o n a c t d y n , R A c t i v a t i o n a c t d y n , T F o r c e t i l d e a c t d y n , T F o r c e a
case ' FtildeState '
[ Time actdyn , M E x c i t a t i o n a c t d y n , M A c t i v a t i o n a c t d y n , R A c t i v a t i o n a c t d y n , T F o r c e t i l d e a c t d y n , T F o r c e a
end
end
6.2
1
2
3
4
5
6
7
8
9
10
11
...
Running example De Groote et al. 2016
clear all ; close all ; clc
%% Choose f o r m u l a t i o n
% formulation = ' lMtildeState ' ;
formulation = ' FtildeState ' ;
%% Choose a c t i v a t i o n dynamics f o r m u l a t i o n
% a c t d y n = ' DeGroote2016 ' ;
a c t d y n = ' DeGroote2009 ' ;
%% Example
% add main f o l d e r and s u b f o l d e r t o matlab path ( i n s t a l l a t i o n )
f i l e p a t h=which ( ' R u n n i n g D e G r o o t e e t a l 2 0 1 6 . m ' ) ;
[ DirExample Running , ¬ ,¬]= f i l e p a r t s ( f i l e p a t h ) ; ...
[ DirExample , ¬]= f i l e p a r t s ( DirExample Running ) ; [ MainDir , ¬]= f i l e p a r t s ( DirExample ) ;
addpath ( g e n p a t h ( MainDir ) ) ;
% Needed I n p u t Arguments
I K p a t h= f u l l f i l e ( MainDir , ' Examples ' , ' R u n n i n g D e G r o o t e e t a l 2 0 1 6 ' , ' RunningData ' , ' I K J o g g e n 1 . m o t ' ) ;
I D p a t h= f u l l f i l e ( MainDir , ' Examples ' , ' R u n n i n g D e G r o o t e e t a l 2 0 1 6 ' , ' RunningData ' , ' I D J o g g e n 1 . s t o ' ) ;
m o d e l p a t h= f u l l f i l e ( MainDir , ' Examples ' , ' R u n n i n g D e G r o o t e e t a l 2 0 1 6 ' , ' RunningData ' , ' AdDB Scaled FB FA.osim ' ) ;
t i m e =[0 . 0 5 0 . 9 8 ] ; % R i g h t s t a n c e p h a s e (+50ms b e g i n n i n g and end o f t i m e i n t e r v a l , more d e t a i l s ...
s e e manual and p u b l i c a t i o n )
OutPath= f u l l f i l e ( MainDir , ' Examples ' , ' R u n n i n g D e G r o o t e e t a l 2 0 1 6 ' , ' R e s u l t s ' ) ;
M i s c . M u s c l e N a m e s I n p u t ={}; % S e l e c t s a l l m u s c l e s f o r t h e I n p u t DOFS when t h i s i s l e f t empty .
M i s c . D o f N a m e s I n p u t={ ' a n k l e a n g l e r ' , ' k n e e a n g l e r ' , ' h i p f l e x i o n r ' , ' h i p a d d u c t i o n r ' , ' h i p r o t a t i o n r
'
};
% O p t i o n a l I n p u t Arguments
Misc.Atendon = [ ] ;
% Tendon S t i f f n e s s f o r t h e s e l e c t e d m u s c l e s
Misc.f cutoff ID = 10;
% c u t o f f f r e q u e n c y f i l t e r i n g ID
Misc.f order ID = 5;
% o r d e r f r e q u e n c y f i l t e r i n g ID
Misc.f cutoff lMT = 10;
% c u t o f f f r e q u e n c y f i l t e r i n g lMT
Misc.f order lMT = 5;
% o r d e r f r e q u e n c y f i l t e r i n g lMT
M i s c . f c u t o f f d M= 1 0 ;
% c u t o f f f r e q u e n c y f i l t e r i n g MA
Misc.f order dM = 5;
% o r d e r f r e q u e n c y f i l t e r i n g MA
M i s c . f c u t o f f I K= 1 0 ;
% c u t o f f f r e q u e n c y f i l t e r i n g IK
Misc.f order IK = 5;
% o r d e r f r e q u e n c y f i l t e r i n g IK
%% S o l v e t h e problem
switch actdyn
c a s e ' DeGroote2016 ' % A c t i v a t i o n dynamics from De G r o o t e e t a l . ( 2 0 1 6 )
switch formulation
case ' lMtildeState '
[ Time , M E x c i t a t i o n , M A c t i v a t i o n , R A c t i v a t i o n , T F o r c e t i l d e , TForce , l M t i l d e , lM , MuscleNames , O p t I n f o , D a t S t
case ' FtildeState '
[ Time , M E x c i t a t i o n , M A c t i v a t i o n , R A c t i v a t i o n , T F o r c e t i l d e , TForce , l M t i l d e , lM , MuscleNames , O p t I n f o , D a t S t
end
case
' DeGroote2009 ' % A c t i v a t i o n dynamics from De G r o o t e e t
a l . (2009)
switch formulation
case ' lMtildeState '
[ Time actdyn , M E x c i t a t i o n a c t d y n , M A c t i v a t i o n a c t d y n , R A c t i v a t i o n a c t d y n , T F o r c e t i l d e a c t d y n , T F o r c e a
case ' FtildeState '
[ Time actdyn , M E x c i t a t i o n a c t d y n , M A c t i v a t i o n a c t d y n , R A c t i v a t i o n a c t d y n , T F o r c e t i l d e a c t d y n , T F o r c e a
end
6
51
end
6.3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
clear all ; close all ; clc
%% Choose f o r m u l a t i o n
% formulation = ' lMtildeState ' ;
formulation = ' FtildeState ' ;
%% Choose a c t i v a t i o n dynamics f o r m u l a t i o n
% a c t d y n = ' DeGroote2016 ' ;
a c t d y n = ' DeGroote2009 ' ;
%% Example
% add main f o l d e r and s u b f o l d e r t o matlab path ( i n s t a l l a t i o n )
f i l e p a t h=which ( ' Example Gait10dof18m.m ' ) ; [ DirExample , ¬ ,¬]= f i l e p a r t s ( f i l e p a t h ) ; ...
[ DirExample2 , ¬ ,¬]= f i l e p a r t s ( DirExample ) ; [ MainDir , ¬]= f i l e p a r t s ( DirExample2 ) ;
addpath ( g e n p a t h ( MainDir ) ) ;
% Needed I n p u t Arguments
Datapath= ' C: \ OpenSim 3 . 3 \ Models \ G a i t 1 0 d o f 1 8 m u s c \ O u t p u t R e f e r e n c e ' ;
I K p a t h= f u l l f i l e ( Datapath , ' IK ' , ' s u b j e c t 0 1 w a l k I K . m o t ' ) ;
I D p a t h = [ ] ; % compute ID from t h e e x t e r n a l l o a d s
m o d e l p a t h= f u l l f i l e ( Datapath , ' s u b j e c t 0 1 . o s i m ' ) ;
t i m e =[0 . 7 1 . 4 ] ;
% Part o f the r i g h t s t a n c e phase
OutPath= f u l l f i l e ( MainDir , ' Examples ' , ' O p e n S i m I n s t a l l a t i o n G a i t 1 0 d o f 1 8 m
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'
,
'
Results
M i s c . D o f N a m e s I n p u t={ ' a n k l e a n g l e r ' , ' k n e e a n g l e r ' , ' h i p f l e x i o n r ' } ;
M i s c . L o a d s p a t h= f u l l f i l e ( Datapath , ' E x p e r i m e n t a l D a t a ' , ' s u b j e c t 0 1 w a l k g r f . x m l
M i s c . I D R e s u l t s P a t h= f u l l f i l e ( Datapath , ' ID ' , ' i n v e r s e d y n a m i c s . s t o ' ) ;
'
'
);
);
%% S o l v e t h e problem
switch actdyn
c a s e ' DeGroote2016 ' % A c t i v a t i o n dynamics from De G r o o t e e t a l . ( 2 0 1 6 )
switch formulation
case ' lMtildeState '
[ Time , M E x c i t a t i o n , M A c t i v a t i o n , R A c t i v a t i o n , T F o r c e t i l d e , TForce , l M t i l d e , lM , MuscleNames , O p t I n f o , D a t S t
case ' FtildeState '
[ Time , M E x c i t a t i o n , M A c t i v a t i o n , R A c t i v a t i o n , T F o r c e t i l d e , TForce , l M t i l d e , lM , MuscleNames , O p t I n f o , D a t S t
end
case
' DeGroote2009 ' % A c t i v a t i o n dynamics from De G r o o t e e t
a l . (2009)
switch formulation
case ' lMtildeState '
[ Time actdyn , M E x c i t a t i o n a c t d y n , M A c t i v a t i o n a c t d y n , R A c t i v a t i o n a c t d y n , T F o r c e t i l d e a c t d y n , T F o r c e a
case ' FtildeState '
[ Time actdyn , M E x c i t a t i o n a c t d y n , M A c t i v a t i o n a c t d y n , R A c t i v a t i o n a c t d y n , T F o r c e t i l d e a c t d y n , T F o r c e a
end
end
6.4
1
2
3
4
5
6
7
8
9
10
OpenSim installation example Gait10dof18m
OpenSim installation example Gait23dof54m
clear all ; close all ; clc
%% Choose f o r m u l a t i o n
% formulation = ' lMtildeState ' ;
formulation = ' FtildeState ' ;
%% Choose a c t i v a t i o n dynamics f o r m u l a t i o n
% a c t d y n = ' DeGroote2016 ' ;
a c t d y n = ' DeGroote2009 ' ;
%% Example
% add main f o l d e r and s u b f o l d e r t o matlab path ( i n s t a l l a t i o n )
f i l e p a t h=which ( ' Example Gait23dof54m.m ' ) ; [ DirExample , ¬ ,¬]= f i l e p a r t s ( f i l e p a t h ) ; ...
[ DirExample2 , ¬ ,¬]= f i l e p a r t s ( DirExample ) ; [ MainDir , ¬]= f i l e p a r t s ( DirExample2 ) ;
addpath ( g e n p a t h ( MainDir ) ) ;
% Needed I n p u t Arguments
Datapath= ' C: \ OpenSim 3 . 3 \ Models \ G a i t 2 3 5 4 S i m b o d y \ O u t p u t R e f e r e n c e ' ;
I K p a t h= f u l l f i l e ( Datapath , ' s u b j e c t 0 1 w a l k 1 i k . m o t ' ) ;
I D p a t h= f u l l f i l e ( Datapath , ' R e s u l t s I n v e r s e D y n a m i c s ' , ' i n v e r s e d y n a m i c s . s t o ' ) ;
m o d e l p a t h= f u l l f i l e ( Datapath , ' s u b j e c t 0 1 s c a l e d O n l y . o s i m ' ) ;
t i m e =[0 . 7 1 . 4 ] ;
% Part o f the r i g h t s t a n c e phase
OutPath= f u l l f i l e ( MainDir , ' Examples ' , ' O p e n S i m I n s t a l l a t i o n G a i t 2 3 d o f 5 4 m ' , ' R e s u l t s
'
);
M i s c . M u s c l e N a m e s I n p u t ={};
% S e l e c t s a l l m u s c l e s f o r t h e I n p u t DOFS when t h i s
M i s c . D o f N a m e s I n p u t={ ' a n k l e a n g l e r ' , ' k n e e a n g l e r ' , ' h i p f l e x i o n r ' } ;
is
left
empty.
%% S o l v e t h e problem
switch actdyn
c a s e ' DeGroote2016 ' % A c t i v a t i o n dynamics from De G r o o t e e t a l . ( 2 0 1 6 )
switch formulation
case ' lMtildeState '
[ Time , M E x c i t a t i o n , M A c t i v a t i o n , R A c t i v a t i o n , T F o r c e t i l d e , TForce , l M t i l d e , lM , MuscleNames , O p t I n f o , D a t S t
case ' FtildeState '
[ Time , M E x c i t a t i o n , M A c t i v a t i o n , R A c t i v a t i o n , T F o r c e t i l d e , TForce , l M t i l d e , lM , MuscleNames , O p t I n f o , D a t S t
end
case
' DeGroote2009 ' % A c t i v a t i o n dynamics from De G r o o t e e t
switch formulation
7
al.
(2009)
36
37
38
39
40
41
case
case
' lMtildeState '
[ Time actdyn , M E x c i t a t i o n a c t d y n , M A c t i v a t i o n a c t d y n , R A c t i v a t i o n a c t d y n , T F o r c e t i l d e a c t d y n , T F o r c e a
' FtildeState '
[ Time actdyn , M E x c i t a t i o n a c t d y n , M A c t i v a t i o n a c t d y n , R A c t i v a t i o n a c t d y n , T F o r c e t i l d e a c t d y n , T F o r c e a
end
end
8
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.5 Linearized : No Page Count : 8 Page Mode : UseOutlines Author : Title : Subject : Creator : LaTeX with hyperref package Producer : pdfTeX-1.40.14 Create Date : 2017:04:18 21:19:22+02:00 Modify Date : 2017:04:18 21:19:22+02:00 Trapped : False PTEX Fullbanner : This is MiKTeX-pdfTeX 2.9.4902 (1.40.14)EXIF Metadata provided by EXIF.tools