Diff of /Docs/anymocap/index.md [000000] .. [38ba34]

Switch to unified view

a b/Docs/anymocap/index.md
1
(anymocap)=
2
3
# The AnyMoCap Framework
4
5
The AnyMoCap model is an effort to create a simple and unified framework for
6
doing any kind of MoCap analysis with the [AnyBody Modeling
7
System](https://www.anybodytech.com).
8
9
:::{figure-md} 
10
:align: center
11
12
<img src="/_static/anymocap.jpg" width="50%">
13
14
Making MoCap models the easier
15
:::
16
17
## Features
18
19
- Adapts to any Mocap protocol
20
- Optimization of marker locations and anthropometrics.
21
- Support Marker based (C3D) and inertial based (BVH) input.
22
- Support for standard force plates: (Types 1-4) plus more.
23
- {doc}`Prediction of ground reaction forces <grf-prediction>`
24
- Easy setup with multiple trials and subjects
25
26
27
## Over determinate kinematic analysis
28
29
:::{seealso}
30
:class: margin
31
The AnyBody tutorials, and the lesson on using the
32
{doc}`AnyMoCap model <tutorials:Making_things_move/lesson5>`
33
:::
34
35
36
Musculoskeletal models that use Motion capture data are different from other
37
types of models found the AMMR.  Most importantly, MoCap models usually require
38
an over-determinate kinematic solver to handle the excess in information that
39
the optical markers provide.
40
41
The over-determinate solver in AMS works great, but
42
it can only find velocities and accelerations numerically. That has some
43
performance issue when running inverse dynamics analysis. To overcome the
44
problem, the MoCap analysis is split into a two-step procedure, as illustrated on
45
the figure below:
46
47
(anymocap-flow-figure)=
48
49
:::{figure} /Applications/Mocap/anymocap_flow.png
50
Figure 1: The framework of the AnyMoCap model. Analysis is split into three
51
steps. *Parameter identification*, *Marker tracking*, *Inverse dynamic
52
analysis*.
53
:::
54
55
The over determinate kinematic analysis solves the model for positions, and
56
writes joint angles to a a set of files. These joint angles can then be used
57
with the determinate kinematic solver in the inverse dynamic analysis.
58
59
## AnyMoCap examples
60
61
The following gallery shows different examples using the AnyMoCap framework.
62
63
:::{tip}
64
:class: margin
65
The {ref}`example_mocap_multitrial` is likely the best starting point when
66
working with many trials/subjects from a MoCap experiment.
67
:::
68
69
70
:::{include} /Applications/Mocap/gallery.txt
71
:::
72
73
74
## Get started
75
76
:::{caution}
77
:class: margin
78
It is recommended *not* to place working models inside the AMMR folder.
79
Copy the example elsewhere before using.
80
:::
81
82
The easiest way to get started, is to adapt one the example application above.
83
84
A typical application using the AnyMoCap framework will look something like this:
85
86
```{code-block} AnyScriptDoc
87
:linenos: true
88
89
 #include "../libdef.any"
90
91
 #path MOCAP_TRIAL_SPECIFIC_DATA "TrialSpecificData.any"
92
 #path MOCAP_SUBJECT_SPECIFIC_DATA "SubjectSpecificData.any"
93
 #path MOCAP_LAB_SPECIFIC_DATA "LabSpecificData.any"
94
95
 // Include the AnyMoCap Framwork
96
 #include "<ANYMOCAP_MODEL>"
97
```
98
99
You can place this main file anywhere on your computer as long the
100
`libdef.any` file points to model repository (AMMR) you want to use.
101
102
103
104
### Model structure
105
106
When loading the AnyMoCap model the following layout shows up in the model tree:
107
108
:::{figure} model-structure.png
109
:::
110
111
#### Description of Model folders
112
113
::::{dropdown} Top-level model structure.
114
:animate: fade-in-slide-down
115
:icon: file-directory
116
117
```{eval-rst}
118
.. table::
119
120
    ======================================= ==============================================================================================
121
    Folder name                             Description
122
    ======================================= ==============================================================================================
123
    ``ModelSetup``                          Contains contains all the machinery of the AnyMoCap Frame.
124
    ``HumanModel``                          Contain the Human model used. This is constructed automatically by the AnyMoCap framework.
125
    ``Main.EnvironmentModel``               Contains the model parts which are not part of the Human model. (e.g.  force plate and environment)
126
    ``Studies``                             Contains the three studies ``ParameterIdentification``, ``MarkerTracking``, and
127
                                            ``InverseDynamicStudy``. See :ref:`figure 1 <AnyMoCap-flow-figure>`.
128
    ``DrawSettings``                        Contains visual and color settings for the model.
129
    ``RunParameterIdentification``          Operation to run the Parameter Identification study and save the results.
130
    ``RunAnalysis``                         Operation to 1. load the optimized parameters (scaling and marker positions), 2. run marker
131
                                            tracking and finally 3. run inverse dynamics analysis, 4. save results to and HDF5 file for later replay.
132
    ``LoadAndReplay``                       This loads any previously saved data and starts the replay operation.
133
    ======================================= ==============================================================================================
134
135
::::
136
137
(anymocap-settings)=
138
139
140
## Options and settings
141
142
The `Main.ModelSetup` folder contains the main machinery of the *AnyMoCap*
143
framework. It is controlled by a number of settings both `#define`/`#path` switches
144
and variables which can be set directly. For example:
145
146
```AnyScriptDoc
147
#define MOCAP_INPUT_DATA_TYPE "C3D"
148
149
Main.ModelSetup.TrialSpecificData.LastFrame = 240;
150
```
151
152
The following two sections gives an overview of the settings available:
153
154
### Paths settings and switches
155
156
Path settings and switches are usually prefixed by `MOCAP_` to indicate that
157
they are specific to the AnyMoCap framework.
158
159
160
::::{dropdown} `#path` settings for AnyMoCap.
161
:animate: fade-in-slide-down
162
:icon: code
163
164
```{eval-rst}
165
.. table:: 
166
167
    ======================================= ============================================================================================== ========================================
168
    Settings                                Description                                                                                    Default
169
    ======================================= ============================================================================================== ========================================
170
    ``MOCAP_TRIAL_SPECIFIC_DATA``           Path to a file with trial specific data. This file is include within the                       None
171
                                            ``Main.ModelSetup.TrialSpecificData`` folder.
172
    ``MOCAP_SUBJECT_SPECIFIC_DATA``         Path to a file with subject/session specific data. This file is include within the             None
173
                                            ``Main.ModelSetup.SubjectSpecificData`` folder.
174
    ``MOCAP_LAB_SPECIFIC_DATA``             Path to a file with laboratory specific data (i.e. data common for the whole model or          None
175
                                            experimental setup. This file is include within the ``Main.ModelSetup.LabSpecificData``
176
                                            folder.
177
    ``MOCAP_C3DSETTINGS``                   A file with setting for the C3D file.                                                          None
178
179
    ``MOCAP_BVHSETTINGS``                   A file with setting for the C3D file.                                                          None
180
    ``MOCAP_EXTRA_DRIVERS_FILE``            A file with user defined extra drivers. Additional drivers are useful/necessary                None
181
                                            in some cases where the marker protocol doesn't provide enough information
182
                                            to specify all degrees of freedom. Hence, these drivers complement a
183
                                            specific driver protocol. This file is included in ``Main.ModelSetup.MoCapExtraDrivers``
184
    ``MOCAP_MARKER_PROTOCOL_FILE``          A file with the definition of the marker protocol.                                             None
185
                                            This file is included in ``Main.ModelSetup.MoCapDrivers``
186
    ``BODY_MODEL_CONFIG_FILE``              A file with the body model configuration.                                                      None
187
    ``MOCAP_FORCE_PLATE_FILE``              A file with the definition of the force plates.                                                None
188
    ``MOCAP_C3D_DATA_PATH``                 Path to folder where C3D files are stored.                                                     Main file directory
189
    ``ANYMOCAP_MODEL_PATH``                 Path to the AnyMoCap framework.                                                                The AnyMoCap implementation in the AMMR
190
    ``ANYBODY_PATH_OUTPUT``                 Path to where output files are saved.                                                          The main file directory
191
    ``TEMP_PATH``                           Path to where temporary files are saved (joint angles etc.)                                    ``ANYBODY_PATH_OUTPUT``
192
    ======================================= ============================================================================================== ========================================
193
194
```
195
196
::::
197
198
199
200
::::{dropdown} `#define` settings for AnyMoCap.
201
:animate: fade-in-slide-down
202
:icon: code
203
204
```{eval-rst}
205
.. table:: ``#define`` settings for AnyMoCap.
206
207
    ============================================== ============================================================================================== ========================================
208
    Setting                                        Description                                                                                    Default value
209
    ============================================== ============================================================================================== ========================================
210
    ``MOCAP_INPUT_DATA_TYPE``                      Data type ("C3D", "BVH") used by the AnyMoCap application.                                     "C3D"
211
    ``MOCAP_CREATE_PARAMETER_ID_SHORTCUT``         Setting for creating the ``Main.RunParameterIdentification`` shortcut operation  .             ON
212
    ``MOCAP_OUTPUT_FILENAME_PREFIX``               Prefix added to all output files from the model.                                               ""
213
    ``MOCAP_PARAMETER_FILE_PREFIX``                Prefix for the parameter identfication files. Can be usefull to set explicitly                 ""
214
                                                   in special cases where subjects share a common parameter file.
215
    ``MOCAP_USE_GRF_PREDICTION``                   Switch to indicate that the model uses Ground Reaction Force (GRF) prediction. It will ensure  OFF
216
                                                   that the AnyMoCap framework uses the appropriate settings. (e.g. recruited actuators as weak
217
                                                   residuals on the pelvis.
218
    ``MOCAP_FILTER_JOINT_ANGLES``                  Switch to enable extra low pass filtering of the output from the Marker tracking. Useful in    OFF
219
                                                   some cases where other drivers (e.g. joint limits) cause high accelerations in the output
220
                                                   from Marker tracking.
221
    ``MOCAP_HIDE_UPPERBODY``                       Switch hide the upper body (Thorax, neck, arms and skull).                                     OFF
222
    ``MOCAP_HUMAN_GROUND_RESIDUALS``               The type of Human Ground residuals (Hand of God) used. Possible values are                     "Pelvis"
223
                                                   "Pelvis", "Thorax", "PelvisWeak". "PelvisWeak" is default when using GRF prediction.
224
    ============================================== ============================================================================================== ========================================
225
226
227
```
228
::::
229
230
231
### Configurable variables
232
233
The `Main.ModelSetup` folder contains all the machinery of the AnyMoCap
234
framework. It has three important subfolder (`TrialSpecificData`,
235
`SubjectSpecificData` and `LabSpecificData`).
236
237
:::{figure} model-setup-structure.png
238
These three folders contain variables specific to the application but also has
239
a few variables which can be assigned directly by the user.
240
:::
241
242
243
::::{dropdown} Variables in the `Main.ModelSetup.TrialSpecificData` folder which can be overridden.
244
:animate: fade-in-slide-down
245
:icon: code
246
247
248
```{eval-rst}
249
.. table:: 
250
251
    ======================================= ============================================================================================== ========================================
252
    ``Main.ModelSetup.TrialSpecificData``   Description                                                                                     Default value
253
    ======================================= ============================================================================================== ========================================
254
    ``TrialFileName``                       Name of the current trial. This is usually used for naming output files and                     Name of the main-file directory
255
                                            locating the input c3d files (c3d filename without the extension)
256
    ``LoadParametersFrom``                  List of trial names from which the scaling and optimized marker postions are loaded from.       ``{TrialFileName}``
257
    ``FirstFrame``                          First frame of the C3D/BVH file to use as starting frame in the analysis                        First frame in the C3D/BVH file
258
    ``LastFrame``                           The last frame of the C3D/BVH file to use in the analysis                                       Last frame in the C3D/BVH
259
    ``tStart``                              Specifies the start time of the analysis. Setting this overides ``FirstFrame``                  Calculated based on ``FirstFrame``
260
    ``tEnd``                                Specifies the end time of the analysis. Setting this overides ``LastFrame``                     Calculated based on ``LastFrame``
261
    ``nStep``                               Number of time steps used in the analysis. (Note that the number of time-steps in the inverse   Calculate based on ``tStart``/``tEnd``
262
                                            dynamic analysis will be 4 less than this values)
263
    ======================================= ============================================================================================== ========================================
264
265
266
```
267
::::
268
269
270
::::{dropdown} Variables in the ``Main.ModelSetup.LabSpecificData`` folder which can be overridden.
271
:animate: fade-in-slide-down
272
:icon: code
273
274
```{eval-rst}
275
.. table:: 
276
277
    ======================================= ============================================================================================== ========================================
278
    ``Main.ModelSetup.LabSpecificData``     Description                                                                                       Default value
279
    ======================================= ============================================================================================== ========================================
280
    ``Gravity``                             Specifies the gravity vector in global reference frame.                                         ``{0,0,-9.81}``
281
    ``LowPassFilterSettings``               Folder with filter settings used for markers and analog (force) data.
282
    ``.MarkerFilterCutOffFrequency``        The lowpass cutoff frequency used for the marker data.                                          ``5.0``
283
    ``.MarkerFilterOrder``                  The filter order used when low pass filtering the marker data.                                  ``2``
284
                                            Note: Since the filter is applied as a zero phase filter
285
                                            (**filtfilt** or forward/backward filter) the effective filter order is the
286
                                            double of this value.
287
    ``.ForceFilterCutOffFrequency``         The lowpass cutoff frequency used for the force/analog data.                                   ``12.0``
288
    ``.ForceFilterOrder``                   The filter order used when low pass filtering the force/analog data.                           ``2``
289
                                            Note: Since the filter is applied as a zero phase filter
290
                                            (**filtfilt** or forward/backward filter) the effective filter order is the
291
                                            double of this value.
292
    ======================================= ============================================================================================== ========================================
293
294
295
```
296
::::
297
298
## More resources
299
300
This section contains further documentation on the AnyMoCap framework.
301
302
```{toctree}
303
:maxdepth: 1
304
305
grf-prediction
306
```