-
Notifications
You must be signed in to change notification settings - Fork 0
/
inverse_dynamics.py
447 lines (352 loc) · 21.8 KB
/
inverse_dynamics.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# Rahil Mehrizi
# Jan 2020
# A module for performing inverse kinetics on marker and force plate data
import pandas as pd
def mass(body_mass, gender):
"""Returns segment's mass as a fraction of total body mass
Methods
==========
De Leva, Paolo. "ADJUSTMENTS TO ZATSIORSKY-SELUYANOV" S SEGMENT IN ERTIA PARAMETERS."
J biomech 29.9 (1996): 1223-1230.
Parameters
==========
body_mass : float
total body mass in kg
gender: bool
0 : male
1 : female
Returns
=======
A dictionary with mass of each body segment in kg
"""
if gender == 0:
c1 = 14.16
c2 = 4.33
c3 = 1.37
if gender == 1:
c1 = 14.78
c2 = 4.81
c3 = 1.29
thigh_l_mass = c1 * 0.01 * body_mass
shank_l_mass = c2 * 0.01 * body_mass
foot_l_mass = c3 * 0.01 * body_mass
thigh_r_mass = c1 * 0.01 * body_mass
shank_r_mass = c2 * 0.01 * body_mass
foot_r_mass = c3 * 0.01 * body_mass
return dict({'thigh_l': thigh_l_mass, 'shank_l': shank_l_mass, 'foot_l': foot_l_mass,
'thigh_r': thigh_r_mass, 'shank_r': shank_r_mass, 'foot_r': foot_r_mass})
def center_of_mass(marker_data, gender):
"""Returns segment's center of mass coordinates based on the fraction of length
Methods
==========
De Leva, Paolo. "ADJUSTMENTS TO ZATSIORSKY-SELUYANOV" S SEGMENT IN ERTIA PARAMETERS."
J biomech 29.9 (1996): 1223-1230.
Parameters
==========
marker_data : dataframe
A dataframe with 27 columns including 3d coordinates of 9 joints
gender: bool
0 : male
1 : female
Returns
=======
A dataframe with 18 columns including 3d coordinates of 6 body segment center of mass
"""
if gender == 0:
c1 = 40.95
c2 = 44.59
c3 = 44.15
if gender == 1:
c1 = 36.9
c2 = 27.1
c3 = 29.9
output = []
output.append(marker_data['hip_l_x'] - c1 * 0.01 * (marker_data['hip_l_x'] - marker_data['knee_l_x']))
output.append(marker_data['hip_l_y'] - c1 * 0.01 * (marker_data['hip_l_y'] - marker_data['knee_l_y']))
output.append(marker_data['hip_l_z'] - c1 * 0.01 * (marker_data['hip_l_z'] - marker_data['knee_l_z']))
output.append(marker_data['knee_l_x'] - c2 * 0.01 * (marker_data['knee_l_x'] - marker_data['ankle_l_x']))
output.append(marker_data['knee_l_y'] - c2 * 0.01 * (marker_data['knee_l_y'] - marker_data['ankle_l_y']))
output.append(marker_data['knee_l_z'] - c2 * 0.01 * (marker_data['knee_l_z'] - marker_data['ankle_l_z']))
output.append(marker_data['ankle_l_x'] - c3 * 0.01 * (marker_data['ankle_l_x'] - marker_data['toe2_l_x']))
output.append(marker_data['ankle_l_y'] - c3 * 0.01 * (marker_data['ankle_l_y'] - marker_data['toe2_l_y']))
output.append(marker_data['ankle_l_z'] - c3 * 0.01 * (marker_data['ankle_l_z'] - marker_data['toe2_l_z']))
output.append(marker_data['hip_r_x'] - c1 * 0.01 * (marker_data['hip_r_x'] - marker_data['knee_r_x']))
output.append(marker_data['hip_r_y'] - c1 * 0.01 * (marker_data['hip_r_y'] - marker_data['knee_r_y']))
output.append(marker_data['hip_r_z'] - c1 * 0.01 * (marker_data['hip_r_z'] - marker_data['knee_r_z']))
output.append(marker_data['knee_r_x'] - c2 * 0.01 * (marker_data['knee_r_x'] - marker_data['ankle_r_x']))
output.append(marker_data['knee_r_y'] - c2 * 0.01 * (marker_data['knee_r_y'] - marker_data['ankle_r_y']))
output.append(marker_data['knee_r_z'] - c2 * 0.01 * (marker_data['knee_r_z'] - marker_data['ankle_r_z']))
output.append(marker_data['ankle_l_x'] - c3 * 0.01 * (marker_data['ankle_l_x'] - marker_data['toe2_l_x']))
output.append(marker_data['ankle_r_y'] - c3 * 0.01 * (marker_data['ankle_r_y'] - marker_data['toe2_r_y']))
output.append(marker_data['ankle_r_z'] - c3 * 0.01 * (marker_data['ankle_r_z'] - marker_data['toe2_r_z']))
output = [list(i) for i in zip(*output)]
return pd.DataFrame(output, columns=['thigh_l_x', 'thigh_l_y', 'thigh_l_z',
'shank_l_x', 'shank_l_y', 'shank_l_z',
'foot_l_x', 'foot_l_y', 'foot_l_z',
'thigh_r_x', 'thigh_r_y', 'thigh_r_z',
'shank_r_x', 'shank_r_y', 'shank_r_z',
'foot_r_x', 'foot_r_y', 'foot_r_z'])
def derivative(df, delta=0.01, order=2):
"""Returns 1st and 2nd derivatives of a dataframe
Methods
==========
numerical calculating of derivative for each column
df/dx = (f(t) - f(t-1)) / delta_t
d2f/dx2 = (f(t) - 2*f(t-1) + f(t-2)) / (delta_t)^2
Parameters
==========
df: dataframe
delta: float
delta_t in s
order: [1,2]
1: first derivative
2: second derivative
Returns
=======
A dataframe with values equal to the derivative of the input dataframe
"""
if order == 1:
deriv = (df - df.diff()) / delta
if order == 2:
deriv = (df - 2 * df.diff() + df.diff(periods=2)) / delta ** 2
return deriv
def force(fp, mass, cm_dd):
"""Returns force at each joint in N
Methods
==========
Newton-Euler equations
(Hof, At L. "An explicit expression for the moment in multibody systems."
Journal of biomechanics 25.10 (1992): 1209-1211.)
Parameters
==========
fp: dataframe
A dataframe with 6 columns including 3d components of the force applied to the left and right force plates in N
mass: float
total body mass in kg
cm_dd: dataframe
second derivative of each segment center of mass (output of derivative function)
Returns
=======
A dataframe with 18 columns:
ankle_l_x : x component of force applied on the left ankle
ankle_l_y : y component of force applied on the left ankle
ankle_l_z : z component of force applied on the left ankle
knee_l_x : x component of force applied on the left knee
knee_l_y : y component of force applied on the left knee
knee_l_z : z component of force applied on the left knee
hip_l_x : x component of force applied on the left hip
hip_l_y : y component of force applied on the left hip
hip_l_z : z component of force applied on the left hip
ankle_r_x : x component of force applied on the right ankle
ankle_r_y : y component of force applied on the right ankle
ankle_r_z : z component of force applied on the right ankle
knee_r_x : x component of force applied on the right knee
knee_r_y : y component of force applied on the right knee
knee_r_z : z component of force applied on the right knee
hip_r_x : x component of force applied on the right hip
hip_r_y : y component of force applied on the right hip
hip_r_z : z component of force applied on the right hip
"""
g_x, g_y, g_z = [0, -9.81, 0]
cm_dd = cm_dd.dropna()
output = []
output.append(- fp['for_l_x'] - mass['foot_l'] * g_x + mass['foot_l'] * cm_dd['foot_l_x'])
output.append(- fp['for_l_y'] - mass['foot_l'] * g_y + mass['foot_l'] * cm_dd['foot_l_y'])
output.append(- fp['for_l_z'] - mass['foot_l'] * g_z + mass['foot_l'] * cm_dd['foot_l_z'])
output.append(- output[0] - mass['shank_l'] * g_x + mass['shank_l'] * cm_dd['shank_l_x'])
output.append(- output[1] - mass['shank_l'] * g_y + mass['shank_l'] * cm_dd['shank_l_y'])
output.append(- output[2] - mass['shank_l'] * g_z + mass['shank_l'] * cm_dd['shank_l_z'])
output.append(- output[3] - mass['thigh_l'] * g_x + mass['thigh_l'] * cm_dd['thigh_l_x'])
output.append(- output[4] - mass['thigh_l'] * g_y + mass['thigh_l'] * cm_dd['thigh_l_y'])
output.append(- output[5] - mass['thigh_l'] * g_z + mass['thigh_l'] * cm_dd['thigh_l_z'])
output.append(- fp['for_r_x'] - mass['foot_r'] * g_x + mass['foot_r'] * cm_dd['foot_r_x'])
output.append(- fp['for_r_y'] - mass['foot_r'] * g_y + mass['foot_r'] * cm_dd['foot_r_y'])
output.append(- fp['for_r_z'] - mass['foot_r'] * g_z + mass['foot_r'] * cm_dd['foot_r_z'])
output.append(- output[9] - mass['shank_r'] * g_x + mass['shank_r'] * cm_dd['shank_r_x'])
output.append(- output[10] - mass['shank_r'] * g_x + mass['shank_r'] * cm_dd['shank_r_y'])
output.append(- output[11] - mass['shank_r'] * g_x + mass['shank_r'] * cm_dd['shank_r_z'])
output.append(- output[12] - mass['thigh_r'] * g_x + mass['thigh_r'] * cm_dd['thigh_r_x'])
output.append(- output[13] - mass['thigh_r'] * g_y + mass['thigh_r'] * cm_dd['thigh_r_y'])
output.append(- output[14] - mass['thigh_r'] * g_z + mass['thigh_r'] * cm_dd['thigh_r_z'])
output = [list(i) for i in zip(*output)]
return pd.DataFrame(output, columns=['ankle_l_x', 'ankle_l_y', 'ankle_l_z',
'knee_l_x', 'knee_l_y', 'knee_l_z',
'hip_l_x', 'hip_l_y', 'hip_l_z',
'ankle_r_x', 'ankle_r_y', 'ankle_r_z',
'knee_r_x', 'knee_r_y', 'knee_r_z',
'hip_r_x', 'hip_r_y', 'hip_r_z'])
def moment(fp, marker, mass, cm, cm_dd, force):
"""Returns moment at each joint in Nm
Methods
==========
Newton-Euler equations
(Hof, At L. "An explicit expression for the moment in multibody systems."
Journal of biomechanics 25.10 (1992): 1209-1211.)
Parameters
==========
fp: dataframe
A dataframe with 18 columns including 3d coordinates of center of pressure and 3d components of the force and
moment applied to the left and right force plates in N
marker_data : dataframe
A dataframe with 27 columns including 3d coordinates of 9 joint
mass: float
total body mass in kg
cm: dataframe
A dataframe with 18 columns including 3d coordinates of 6 body segment center of mass (output of center_of_mass function)
cm_dd: dataframe
second derivative of each segment center of mass (output of derivative function)
force: dataframe
A dataframe with 18 columns including 3d components of force at each joint (output of force function)
Returns
=======
A dataframe with 18 columns:
ankle_l_x : x component of moment applied on the left ankle
ankle_l_y : y component of moment applied on the left ankle
ankle_l_z : z component of moment applied on the left ankle
knee_l_x : x component of moment applied on the left knee
knee_l_y : y component of moment applied on the left knee
knee_l_z : z component of moment applied on the left knee
hip_l_x : x component of moment applied on the left hip
hip_l_y : y component of moment applied on the left hip
hip_l_z : z component of moment applied on the left hip
ankle_r_x : x component of moment applied on the right ankle
ankle_r_y : y component of moment applied on the right ankle
ankle_r_z : z component of moment applied on the right ankle
knee_r_x : x component of moment applied on the right knee
knee_r_y : y component of moment applied on the right knee
knee_r_z : z component of moment applied on the right knee
hip_r_x : x component of moment applied on the right hip
hip_r_y : y component of moment applied on the right hip
hip_r_z : z component of moment applied on the right hip
"""
g_x, g_y, g_z = [0, -9.81, 0]
cm_dd = cm_dd.dropna()
output = []
output.append(- fp['mom_l_x'] - (fp['cop_l_y'] - marker['ankle_l_y']) * fp['for_l_z'] - \
(fp['cop_l_z'] - marker['ankle_l_z']) * fp['for_l_y'] - \
(cm['foot_l_y'] - marker['ankle_l_y']) * mass['foot_l'] * g_z -\
(cm['foot_l_z'] - marker['ankle_l_z']) * mass['foot_l'] * g_y +\
(cm['foot_l_y'] - marker['ankle_l_y']) * mass['foot_l'] * cm_dd['foot_l_z'] +\
(cm['foot_l_z'] - marker['ankle_l_z']) * mass['foot_l'] * cm_dd['foot_l_y'])
output.append(- fp['mom_l_y'] - (fp['cop_l_z'] - marker['ankle_l_z']) * fp['for_l_x'] - \
(fp['cop_l_x'] - marker['ankle_l_x']) * fp['for_l_z'] - \
(cm['foot_l_z'] - marker['ankle_l_z']) * mass['foot_l'] * g_x -\
(cm['foot_l_x'] - marker['ankle_l_x']) * mass['foot_l'] * g_z +\
(cm['foot_l_z'] - marker['ankle_l_z']) * mass['foot_l'] * cm_dd['foot_l_x'] +\
(cm['foot_l_x'] - marker['ankle_l_x']) * mass['foot_l'] * cm_dd['foot_l_z'])
output.append(- fp['mom_l_z'] - (fp['cop_l_x'] - marker['ankle_l_x']) * fp['for_l_y'] - \
(fp['cop_l_y'] - marker['ankle_l_y']) * fp['for_l_x'] - \
(cm['foot_l_x'] - marker['ankle_l_x']) * mass['foot_l'] * g_y - \
(cm['foot_l_y'] - marker['ankle_l_y']) * mass['foot_l'] * g_x + \
(cm['foot_l_x'] - marker['ankle_l_x']) * mass['foot_l'] * cm_dd['foot_l_y'] + \
(cm['foot_l_y'] - marker['ankle_l_y']) * mass['foot_l'] * cm_dd['foot_l_x'])
temp = - (marker['ankle_l_y'] - marker['knee_l_y']) * force['ankle_l_z'] - \
(marker['ankle_l_z'] - marker['knee_l_z']) * force['ankle_l_y'] -\
(cm['shank_l_y'] - marker['knee_l_y']) * mass['shank_l'] * g_z -\
(cm['shank_l_z'] - marker['knee_l_z']) * mass['shank_l'] * g_y +\
(cm['shank_l_y'] - marker['knee_l_y']) * mass['shank_l'] * cm_dd['shank_l_z'] +\
(cm['shank_l_z'] - marker['knee_l_z']) * mass['shank_l'] * cm_dd['shank_l_y']
output.append(- output[0] + temp)
temp = - (marker['ankle_l_z'] - marker['knee_l_z']) * force['ankle_l_x'] -\
(marker['ankle_l_x'] - marker['knee_l_x']) * force['ankle_l_z'] -\
(cm['shank_l_z'] - marker['knee_l_z']) * mass['shank_l'] * g_x -\
(cm['shank_l_x'] - marker['knee_l_x']) * mass['shank_l'] * g_z +\
(cm['shank_l_z'] - marker['knee_l_z']) * mass['shank_l'] * cm_dd['shank_l_x'] +\
(cm['shank_l_x'] - marker['knee_l_x']) * mass['shank_l'] * cm_dd['shank_l_z']
output.append(- output[1] + temp)
temp = - (marker['ankle_l_x'] - marker['knee_l_x']) * force['ankle_l_y'] - \
(marker['ankle_l_y'] - marker['knee_l_y']) * force['ankle_l_x'] -\
(cm['shank_l_x'] - marker['knee_l_x']) * mass['shank_l'] * g_y - \
(cm['shank_l_y'] - marker['knee_l_y']) * mass['shank_l'] * g_x + \
(cm['shank_l_x'] - marker['knee_l_x']) * mass['shank_l'] * cm_dd['shank_l_y'] + \
(cm['shank_l_y'] - marker['knee_l_y']) * mass['shank_l'] * cm_dd['shank_l_x']
output.append(- output[2] + temp)
temp = - (marker['knee_l_y'] - marker['hip_l_y']) * force['knee_l_z'] -\
(marker['knee_l_z'] - marker['hip_l_z']) * force['knee_l_y'] -\
(cm['thigh_l_y'] - marker['hip_l_y']) * mass['thigh_l'] * g_z -\
(cm['thigh_l_z'] - marker['hip_l_z']) * mass['thigh_l'] * g_y +\
(cm['thigh_l_y'] - marker['hip_l_y']) * mass['thigh_l'] * cm_dd['thigh_l_z'] +\
(cm['thigh_l_z'] - marker['hip_l_z']) * mass['thigh_l'] * cm_dd['thigh_l_y']
output.append(- output[3] + temp)
temp = - (marker['knee_l_z'] - marker['hip_l_z']) * force['knee_l_x'] -\
(marker['knee_l_x'] - marker['hip_l_x']) * force['knee_l_z'] -\
(cm['thigh_l_z'] - marker['hip_l_z']) * mass['thigh_l'] * g_x -\
(cm['thigh_l_x'] - marker['hip_l_x']) * mass['thigh_l'] * g_z +\
(cm['thigh_l_z'] - marker['hip_l_z']) * mass['thigh_l'] * cm_dd['thigh_l_x'] +\
(cm['thigh_l_x'] - marker['hip_l_x']) * mass['thigh_l'] * cm_dd['thigh_l_z']
output.append(- output[4] + temp)
temp = - (marker['knee_l_x'] - marker['hip_l_x']) * force['knee_l_y'] -\
(marker['knee_l_y'] - marker['hip_l_y']) * force['knee_l_x'] -\
(cm['thigh_l_x'] - marker['hip_l_x']) * mass['thigh_l'] * g_y - \
(cm['thigh_l_y'] - marker['hip_l_y']) * mass['thigh_l'] * g_x + \
(cm['thigh_l_x'] - marker['hip_l_x']) * mass['thigh_l'] * cm_dd['thigh_l_y'] + \
(cm['thigh_l_y'] - marker['hip_l_y']) * mass['thigh_l'] * cm_dd['thigh_l_x']
output.append(- output[5] + temp)
output.append(- fp['mom_r_x'] - (fp['cop_r_y'] - marker['ankle_r_y']) * fp['for_r_z'] - \
(fp['cop_r_z'] - marker['ankle_r_z']) * fp['for_r_y'] - \
(cm['foot_r_y'] - marker['ankle_r_y']) * mass['foot_r'] * g_z -\
(cm['foot_r_z'] - marker['ankle_r_z']) * mass['foot_r'] * g_y +\
(cm['foot_r_y'] - marker['ankle_r_y']) * mass['foot_r'] * cm_dd['foot_r_z'] +\
(cm['foot_r_z'] - marker['ankle_r_z']) * mass['foot_r'] * cm_dd['foot_r_y'])
output.append(- fp['mom_r_y'] - (fp['cop_r_z'] - marker['ankle_r_z']) * fp['for_r_x'] - \
(fp['cop_r_x'] - marker['ankle_r_x']) * fp['for_r_z'] - \
(cm['foot_r_z'] - marker['ankle_r_z']) * mass['foot_l'] * g_x -\
(cm['foot_r_x'] - marker['ankle_r_x']) * mass['foot_l'] * g_z +\
(cm['foot_r_z'] - marker['ankle_r_z']) * mass['foot_l'] * cm_dd['foot_r_x'] +\
(cm['foot_r_x'] - marker['ankle_r_x']) * mass['foot_l'] * cm_dd['foot_r_z'])
output.append(- fp['mom_r_z'] - (fp['cop_r_x'] - marker['ankle_r_x']) * fp['for_r_y'] - \
(fp['cop_r_y'] - marker['ankle_r_y']) * fp['for_r_x'] - \
(cm['foot_r_x'] - marker['ankle_r_x']) * mass['foot_l'] * g_y - \
(cm['foot_r_y'] - marker['ankle_r_y']) * mass['foot_l'] * g_x + \
(cm['foot_r_x'] - marker['ankle_r_x']) * mass['foot_l'] * cm_dd['foot_r_y'] + \
(cm['foot_r_y'] - marker['ankle_r_y']) * mass['foot_l'] * cm_dd['foot_r_x'])
temp = - (marker['ankle_r_y'] - marker['knee_r_y']) * force['ankle_r_z'] - \
(marker['ankle_r_z'] - marker['knee_r_z']) * force['ankle_r_y'] -\
(cm['shank_r_y'] - marker['knee_r_y']) * mass['shank_l'] * g_z -\
(cm['shank_r_z'] - marker['knee_r_z']) * mass['shank_l'] * g_y +\
(cm['shank_r_y'] - marker['knee_r_y']) * mass['shank_l'] * cm_dd['shank_r_z'] +\
(cm['shank_r_z'] - marker['knee_r_z']) * mass['shank_l'] * cm_dd['shank_r_y']
output.append(- output[9] + temp)
temp = - (marker['ankle_r_z'] - marker['knee_r_z']) * force['ankle_r_x'] -\
(marker['ankle_r_x'] - marker['knee_r_x']) * force['ankle_r_z'] -\
(cm['shank_r_z'] - marker['knee_r_z']) * mass['shank_l'] * g_x -\
(cm['shank_r_x'] - marker['knee_r_x']) * mass['shank_l'] * g_z +\
(cm['shank_r_z'] - marker['knee_r_z']) * mass['shank_l'] * cm_dd['shank_r_x'] +\
(cm['shank_r_x'] - marker['knee_r_x']) * mass['shank_l'] * cm_dd['shank_r_z']
output.append(- output[10] + temp)
temp = - (marker['ankle_r_x'] - marker['knee_r_x']) * force['ankle_r_y'] - \
(marker['ankle_r_y'] - marker['knee_r_y']) * force['ankle_r_x'] -\
(cm['shank_r_x'] - marker['knee_r_x']) * mass['shank_l'] * g_y - \
(cm['shank_r_y'] - marker['knee_r_y']) * mass['shank_l'] * g_x + \
(cm['shank_r_x'] - marker['knee_r_x']) * mass['shank_l'] * cm_dd['shank_r_y'] + \
(cm['shank_r_y'] - marker['knee_r_y']) * mass['shank_l'] * cm_dd['shank_r_x']
output.append(- output[11] + temp)
temp = - (marker['knee_r_y'] - marker['hip_r_y']) * force['knee_r_z'] -\
(marker['knee_r_z'] - marker['hip_r_z']) * force['knee_r_y'] -\
(cm['thigh_r_y'] - marker['hip_r_y']) * mass['thigh_l'] * g_z -\
(cm['thigh_r_z'] - marker['hip_r_z']) * mass['thigh_l'] * g_y +\
(cm['thigh_r_y'] - marker['hip_r_y']) * mass['thigh_l'] * cm_dd['thigh_r_z'] +\
(cm['thigh_r_z'] - marker['hip_r_z']) * mass['thigh_l'] * cm_dd['thigh_r_y']
output.append(- output[12] + temp)
temp = - (marker['knee_r_z'] - marker['hip_r_z']) * force['knee_r_x'] -\
(marker['knee_r_x'] - marker['hip_r_x']) * force['knee_r_z'] -\
(cm['thigh_r_z'] - marker['hip_r_z']) * mass['thigh_l'] * g_x -\
(cm['thigh_r_x'] - marker['hip_r_x']) * mass['thigh_l'] * g_z +\
(cm['thigh_r_z'] - marker['hip_r_z']) * mass['thigh_l'] * cm_dd['thigh_r_x'] +\
(cm['thigh_r_x'] - marker['hip_r_x']) * mass['thigh_l'] * cm_dd['thigh_r_z']
output.append(- output[13] + temp)
temp = - (marker['knee_r_x'] - marker['hip_r_x']) * force['knee_r_y'] -\
(marker['knee_r_y'] - marker['hip_r_y']) * force['knee_r_x'] -\
(cm['thigh_r_x'] - marker['hip_r_x']) * mass['thigh_l'] * g_y - \
(cm['thigh_r_y'] - marker['hip_r_y']) * mass['thigh_l'] * g_x + \
(cm['thigh_r_x'] - marker['hip_r_x']) * mass['thigh_l'] * cm_dd['thigh_r_y'] + \
(cm['thigh_r_y'] - marker['hip_r_y']) * mass['thigh_l'] * cm_dd['thigh_r_x']
output.append(- output[14] + temp)
output = [list(i) for i in zip(*output)]
return pd.DataFrame(output, columns=['ankle_l_x', 'ankle_l_y', 'ankle_l_z',
'knee_l_x', 'knee_l_y', 'knee_l_z',
'hip_l_x', 'hip_l_y', 'hip_l_z',
'ankle_r_x', 'ankle_r_y', 'ankle_r_z',
'knee_r_x', 'knee_r_y', 'knee_r_z',
'hip_r_x', 'hip_r_y', 'hip_r_z'])
#to_do (power)