biorbd
biorbd copied to clipboard
Correct presentation of joint angles from biorbd?
Hi,
I have a Vicon data where an IOR marker set is used for a human motion. I was able to get angles from biorbd. The angles which are reported are not the joint angles I expect. How can I to get the correct joint angles for example for the middle trunk? When I look at the motion the middle trunk is not moving but the results reported by biorbd shows a considerable range of motion for the middle trunk? The following figure shows the output I get from biorbd for each segment!
Hi @MahsaP !
What do you mean by When I look at the motion the middle trunk is not moving
? Based on the data reported I say that the trunk was definitely moving!
Please provide me with a minimal script you ran so I can have a look at your code and also a copy of you bioMod file
Cheers
Hi @pariterre Thanks for your response. I meant, in the movie the trunk is almost flat, but the range in the figure shows the middle trunk moved around 1 rad.
Here is my biomod file:
`version 4
segment Pelvis
parent ROOT
translations xyz
rotations xyz
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
mass 8.337875049516422
inertia
0.06305158360728123 0.0 0.0
0.0 0.050611471570504836 0.0
0.0 0.0 0.057440997057247103
com 0.0 0.0 0.05493336658105289
//mesh 0.088450796878699 0.13656664190870346 0.07683169008363594
//mesh 0.11459455316716964 -0.11792980944026601 0.07683169008363594
//mesh -0.09866366253477166 -0.06707383876858337 0.10210700025320275
//mesh -0.10438168751109742 0.04843700630014591 0.10337656202078088
//mesh 0.088450796878699 0.13656664190870346 0.07683169008363594
meshfile mesh/pelvis.stl
meshrt 0 0 -pi/2 xyz 0 0 0
endsegment
// Markers
marker LV5
parent Pelvis
position 0.09750433977912426 -0.025128778934478836 0.14139862697825695
endmarker
marker L_IAS
parent Pelvis
position -0.11787379949233141 -0.12162736915139599 0.08499073979994849
endmarker
marker L_IPS
parent Pelvis
position 0.08291919573615553 -0.12555555138868446 0.10489331153420864
endmarker
marker R_IAS
parent Pelvis
position -0.07752342987060573 0.15878492759255838 0.08499073979994849
endmarker
marker R_IPS
parent Pelvis
position 0.11247804215375085 0.08839799331216242 0.11167407953598942
endmarker
segment Thigh_R
parent Pelvis
rotations xyz
rtinmatrix 1
rt
1 0 0 0
0 1 0 -0.10198888775993796
0 0 1 0
0 0 0 1
mass 10.549229958048972
inertia
0.19095493546195783 0.0 0.0
0.0 0.19095493546195783 0.0
0.0 0.0 0.03916621725770203
com 0 0 -0.16746076556221495
//mesh 0.0 -0.050891810386428586 -0.3608796029923878
//mesh 0.0 0.050891810386428586 -0.356766846552254
//mesh 0.0 -0.10178362077285717 -0.04230324385043132
//mesh 0.0 -0.050891810386428586 -0.3608796029923878
meshfile mesh/thigh.stl
endsegment
// Markers
marker R_FLE
parent Thigh_R
position 0.0 -0.05491790883681364 -0.4013714289048136
endmarker
marker R_FME
parent Thigh_R
position 0.0 0.05491790883681364 -0.41354462513643125
endmarker
marker R_FTC
parent Thigh_R
position 0.0 -0.10983581767362728 -0.12823036229750664
endmarker
segment Thigh_L
parent Pelvis
rotations xyz
rtinmatrix 1
rt
1 0 0 0
0 1 0 0.10198888775993796
0 0 1 0
0 0 0 1
mass 10.549229958048972
inertia
0.19095493546195783 0.0 0.0
0.0 0.19095493546195783 0.0
0.0 0.0 0.03916621725770203
com 0 0 -0.16746076556221495
//mesh 0.0 0.046471983189009324 -0.37396995721824006
//mesh 0.0 -0.046471983189009324 -0.4054773817750878
//mesh 0.0 0.09294396637801865 -0.2657857665259164
//mesh 0.0 0.046471983189009324 -0.37396995721824006
meshfile mesh/thigh.stl
endsegment
// Markers
marker L_FLE
parent Thigh_L
position 0.0 0.05089110893361704 -0.4174332979090071
endmarker
marker L_FME
parent Thigh_L
position 0.0 -0.05089110893361704 -0.42990042509191145
endmarker
marker L_FTC
parent Thigh_L
position 0.0 0.10178221786723408 -0.24957049820843835
endmarker
segment Shank_R
parent Thigh_R
rotations y
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 -0.40893959844252736
0 0 0 1
mass 3.2121263027720586
inertia
0.03649334933762763 0.0 0.0
0.0 0.035053912295294885 0.0
0.0 0.0 0.006026520317275563
com 0 0 -0.18663612689915823
//mesh 0.0 -0.042488092447081856 -0.34849877189867423
//mesh 0.0 0.042488092447081856 -0.33772776135531335
//mesh 0.0 -0.042488092447081856 -0.11616625729955808
//mesh 0.0 -0.042488092447081856 -0.34849877189867423
meshfile mesh/leg_left.stl
endsegment
// Markers
marker R_FAL
parent Shank_R
position 0.0 -0.04510804333406329 -0.42926350559907805
endmarker
marker R_TAM
parent Shank_R
position 0.0 0.04510804333406329 -0.4266743148354923
endmarker
marker R_TIB
parent Shank_R
position 0.0 -0.04510804333406329 -0.1430878351996927
endmarker
segment Shank_L
parent Thigh_L
rotations y
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 -0.40893959844252736
0 0 0 1
mass 3.2121263027720586
inertia
0.03649334933762763 0.0 0.0
0.0 0.035053912295294885 0.0
0.0 0.0 0.006026520317275563
com 0 0 -0.18663612689915823
//mesh 0.0 0.04150169865897549 -0.33805748887495557
//mesh 0.0 -0.04150169865897549 -0.34107343107281307
//mesh 0.0 0.04150169865897549 -0.11268582962498518
//mesh 0.0 0.04150169865897549 -0.33805748887495557
meshfile mesh/leg_left.stl
endsegment
// Markers
marker L_FAL
parent Shank_L
position 0.0 0.04411432521483487 -0.4125657263363109
endmarker
marker L_TAM
parent Shank_L
position 0.0 -0.04411432521483487 -0.412637861364028
endmarker
marker L_TIB
parent Shank_L
position 0.0 0.04411432521483487 -0.13752190877877024
endmarker
segment Foot_R
parent Shank_R
rotations xyz
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 -0.4246555788376752
0 0 0 1
mass 1.0671178120983507,
inertia
0.0048150975619743654 0.0 0.0
0.0 0.004375936519213178 0.0
0.0 0.0 0.00112093960715405
com 0.11539684775973069 0 0
//mesh -0.044498831084280384 0.0 0.0012093205307469224
//mesh 0.11906149451273941 0.04830416015100567 -0.03506182976925012
//mesh 0.12205435748803847 -0.04830416015100567 -0.04350189474857215
//mesh -0.044498831084280384 0.0 0.0012093205307469224
meshfile mesh/foot.stl
meshrt 0 -pi/2 -pi/2 xyz 0 0 0
endsegment
// Markers
marker R_FCC
parent Foot_R
position 0.06963536341050086 0.0 -0.015657525230856503
endmarker
marker R_FM1
parent Foot_R
position 0.14313807364071116 0.045059714177075626 -0.023306470983168657
endmarker
marker R_FM5
parent Foot_R
position 0.11069393864799949 -0.045059714177075626 -0.03527813328013701
endmarker
segment Foot_L
parent Shank_L
rotations xyz
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 -0.4246555788376752
0 0 0 1
mass 1.0671178120983507
inertia
0.0048150975619743654 0.0 0.0
0.0 0.004375936519213178 0.0
0.0 0.0 0.00112093960715405
com 0.11539684775973069 0 0
//mesh -0.04825176262133071 0.0 -0.003024471745346532
//mesh 0.12322698988952124 -0.04622250436791515 -0.0397889488104618
//mesh 0.11253306829035734 0.04622250436791515 -0.05726605617638791
//mesh -0.04825176262133071 0.0 -0.003024471745346532
meshfile mesh/foot.stl
meshrt 0 -pi/2 -pi/2 xyz 0 0 0
endsegment
// Markers
marker L_FCC
parent Foot_L
position 0.07475817512063422 0.0 -0.016671631420359892
endmarker
marker L_FM1
parent Foot_L
position 0.1426534626904656 -0.041966827981612345 -0.014661617896136117
endmarker
marker L_FM5
parent Foot_L
position 0.1014650889564963 0.041966827981612345 -0.03667793172948501
endmarker
segment MiddleTrunk
parent Pelvis
rotations yz
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 0.14139862697825714
0 0 0 1
mass 11.043201190610532,
inertia
0.09210179017065682 0.0 0.0
0.0 0.05815292220495291 0.0
0.0 0.0 0.08682918032720657
com 0 0 0.10417037818657371
endsegment
// Markers
marker LV1
parent MiddleTrunk
position 0.08957425510182074 -0.022962042191449403 0.06933753069709328
endmarker
marker LV3
parent MiddleTrunk
position 0.09391093355066608 -0.025107197312747805 0.038236601885627296
endmarker
marker TV10
parent MiddleTrunk
position 0.1061483284445367 -0.023687619040994153 0.18946958564309513
endmarker
marker SXS
parent MiddleTrunk
position -0.12400541507496585 -0.0035962982177734307 0.1923660951502183
endmarker
segment UpperTrunk
parent MiddleTrunk
rotations xy
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 0.18946958564309513
0 0 0 1
mass 15.560837763437057
inertia
0.3737423808093975 0.0 0.0
0.0 0.1500685022836283 0.0
0.0 0.0 0.31688048736599145
com 0 0 0.15141798187525132
//mesh 0.0 0.17853078290370225 0.19507410407788825
//mesh 0.0 -0.17853078290370225 0.2017967880711411
//mesh 0.0 0.17853078290370225 0.19507410407788825
//mesh -0.05939979322028877 -0.016789356578480095 0.2509607821377841
//mesh 0.0 -0.17853078290370225 0.2017967880711411
//mesh 0.0 0.17853078290370225 0.19507410407788825
//mesh -0.08565213475082854 -0.012735786206794497 0.20711534534801138
//mesh 0.0 -0.17853078290370225 0.2017967880711411
//mesh -0.05939979322028877 -0.016789356578480095 0.2509607821377841
//mesh -0.08565213475082854 -0.012735786206794497 0.20711534534801138
//mesh 0.0 0.17853078290370225 0.19507410407788825
//mesh 0.06103903845584759 0.0037135407418915642 0.16894611890388256
//mesh 0.0 -0.17853078290370225 0.2017967880711411
//mesh -0.12790647518273568 -0.012838220639662327 0.1335141277891217
//mesh 0.13194821120753422 0.003517740553075618 0.09904863114790483
//mesh 0.06103903845584759 0.0037135407418915642 0.16894611890388256
//mesh 0.13194821120753422 0.003517740553075618 0.09904863114790483
//mesh -0.12790647518273568 -0.012838220639662327 0.1335141277891217
meshfile mesh/thorax.stl
meshrt 0 0 -pi/2 xyz 0 0 0
endsegment
// Markers
marker CV7
parent UpperTrunk
position 0.08762083390179828 -0.0026533530740176763 0.3068868704403148
endmarker
marker L_SAE
parent UpperTrunk
position 0.0 0.17657099847232555 0.24862443362965303
endmarker
marker R_SAE
parent UpperTrunk
position 0.0 -0.17657099847232555 0.24872706514246323
endmarker
marker SJN
parent UpperTrunk
position -0.04180081580666923 -0.0015974643370684305 0.22197727338005516
endmarker
marker TV2
parent UpperTrunk
position 0.10211828344008529 -0.008442377763635968 0.27363148498535156
endmarker
segment UpperArm_R
parent UpperTrunk
rotations xyz
rtinmatrix 1
rt
1 0 0 0
0 1 0 -0.17657099847232596
0 0 1 0.18864161125183096
0 0 0 1
mass 2.238133710327379
inertia
0.01663220312009175 0.0 0.0
0.0 0.014817148045219568 0.0
0.0 0.0 0.005111804477561965
com 0 0 -0.1745875772121873
//mesh 0.0 -0.0317241491787163 -0.24767055095859483
//mesh 0.0 0.0317241491787163 -0.25190305384269657
//mesh 0.0 -0.04229886557162173 -0.12184678124186149
//mesh 0.0 -0.0317241491787163 -0.24767055095859483
meshfile mesh/arm.stl
endsegment
// Markers
marker R_HLE
parent UpperArm_R
position 0.0 -0.03213910602120803 -0.3035102252242151
endmarker
marker R_HME
parent UpperArm_R
position 0.0 0.03213910602120803 -0.3036270007369104
endmarker
marker R_HUM
parent UpperArm_R
position 0.0 -0.0428521413616106 -0.1037368980138441
endmarker
segment UpperArm_L
parent UpperTrunk
rotations xyz
rtinmatrix 1
rt
1 0 0 0
0 1 0 0.17657099847232596
0 0 1 0.18864161125183096
0 0 0 1
mass 2.238133710327379
inertia
0.01663220312009175 0.0 0.0
0.0 0.014817148045219568 0.0
0.0 0.0 0.005111804477561965
com 0 0 -0.1745875772121873
//mesh 0.0 0.03140385220979574 -0.2360119528157429
//mesh 0.0 -0.03140385220979574 -0.23998057213698823
//mesh 0.0 0.04187180294639434 -0.17214637068734528
//mesh 0.0 0.03140385220979574 -0.2360119528157429
meshfile mesh/arm.stl
endsegment
// Markers
marker L_HLE
parent UpperArm_L
position 0.0 0.03973289397183578 -0.3014363347625738
endmarker
marker L_HME
parent UpperArm_L
position 0.0 -0.03973289397183578 -0.3031826800581994
endmarker
marker L_HUM
parent UpperArm_L
position 0.0 0.05297719196244792 -0.19504947845907758
endmarker
segment LowerArm_R
parent UpperArm_R
rotations yz
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 -0.30247327999339446
0 0 0 1
mass 1.2803555549721726
inertia
0.007446091556412999 0.0 0.0
0.0 0.006864390090699209 0.0
0.0 0.0 0.0014311361383827284
com 0 0 -0.12638221690045523
//mesh 0.0317241491787163 0.0 -0.23122175600168265
//mesh -0.0317241491787163 0.0 -0.221330710300937
meshfile mesh/fore_arm.stl
endsegment
// Markers
marker R_RSP
parent LowerArm_R
position 0.03213910602120803 0.0 -0.2686563052009134
endmarker
marker R_USP
parent LowerArm_R
position -0.03213910602120803 0.0 -0.27305076060575595
endmarker
segment LowerArm_L
parent UpperArm_L
rotations yz
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 -0.30247327999339446
0 0 0 1
mass 1.2803555549721726
inertia
0.007446091556412999 0.0 0.0
0.0 0.006864390090699209 0.0
0.0 0.0 0.0014311361383827284
com 0 0 -0.12638221690045523
//mesh 0.03140385220979574 0.0 -0.21844156238051074
//mesh -0.03140385220979574 0.0 -0.21916329121507858
meshfile mesh/fore_arm.stl
endsegment
// Markers
marker L_RSP
parent LowerArm_L
position 0.03973289397183578 0.0 -0.26782847123987535
endmarker
marker L_USP
parent LowerArm_L
position -0.03973289397183578 0.0 -0.2795605944465189
endmarker
segment Hand_R
parent LowerArm_R
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 -0.2763056775261374
0 0 0 1
mass 0.4646361379755198
inertia
0.001334395849964151 0.0 0.0
0.0 0.0008884549914914911 0.0
0.0 0.0 0.0005446723801165401
com 0.0 0.0 -0.0674344081381854
meshfile mesh/hand.stl
endsegment
// Markers
marker R_HM2
parent Hand_R
position 0.03213910602120803 -0.025 -0.08970219269920798
endmarker
segment Hand_L
parent LowerArm_L
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 -0.2763056775261374
0 0 0 1
mass 0.4646361379755198
inertia
0.001334395849964151 0.0 0.0
0.0 0.0008884549914914911 0.0
0.0 0.0 0.0005446723801165401
com 0.0 0.0 -0.0674344081381854
meshfile mesh/hand.stl
endsegment
marker L_HM2
parent Hand_L
position 0.03973289397183578 0.025 -0.0963750924503102
endmarker
segment Head
parent UpperTrunk
rotations xyz
rtinmatrix 1
rt
1 0 0 0
0 1 0 0
0 0 1 0.3068868704403148
0 0 0 1
mass 5.4348870440470725
inertia
0.030518260450842074 0.0 0.0
0.0 0.032983415495591986 0.0
0.0 0.0 0.022644124434116626
com 0.0 0.0 0.12360562919311524
//mesh 0.09977740848425669 0.05482644728458293 0.14256724964488637
//mesh 0.12916754890210705 0.0008667377125133154 0.15315495531486745
//mesh 0.11782985247987694 -0.05352141282052701 0.14438226688269412
//mesh 0.09977740848425669 0.05482644728458293 0.14256724964488637
meshfile mesh/head.stl
meshrt 0 0 -pi/2 xyz 0 0 0
endsegment
// Markers
marker L_HEAD
parent Head
position -0.06423318391687707 0.05829173329297221 0.18817324290556067
endmarker
marker R_HEAD
parent Head
position -0.06625820922851539 -0.06374916857831633 0.18030619722254135
endmarker
marker SGL
parent Head
position -0.09297313465791561 -0.008102281289942113 0.19660839664234833
endmarker`
Could you also send my a c3d file. You can send it via email if you prefer
@pariterre I sent the files to your hotmail email. Thanks!
@MahsaP Based on the biorbd reconstruction vizualized using bioviz, on the C3D file you provided me, the subject is performing repeated squats which is in accordance I think with the graphs. Are you sure the video you watching and the C3D are actually the same trials?
@pariterre Thanks for looking at the code. Yes I am sure. The upper body is moving a little bit. For example, based on the graph above the middle trunk is moving around 60 deg while in practice it is not bending. If you look at the following screenshot it is flat:
Also, one thing that I am just confused here is that when the person starts at the standing pose all the angles must be zero but there is some offset, and I am not sure how to present ankle, knee and hip angles properly if my model starts from a fix foot on the ground. Do you know what is the transformation between the biorbd angles to that model? I came up with something for ankle, knee, and hip and I am not sure if it is correct but do not know what to do for the upper trunk and the mid trunk!
Dear Mahsa,
I also loaded the experimental markers in the visualization (using b.load_movement(q_recons)
). It appears the reconstruction fails drastically.
Each fine red line is linking the experimental markers with its corresponding marker from the model. Two quick observations. The lower-half of the pelvis is properly reconstructed, while the upper half of the pelvis is backward. Also the left marker on the left leg is at the near the ankle while in the model it seems to be near the knee.
These two observations don't make sense. It is as if the marker placement during your static trial that you used to create the bioMod was not the same as the marker placement for the reconstructed trials... How did you create your bioMod? Did you replaced the markers between the static and the rest of the data collection?
Also, one thing that I am just confused here is that when the person starts at the standing pose all the angles must be zero but there is some offset
You are the one that created these offsets in the bioMod. The RT
matrix for each segment is that offset. Right now the rotation part of these matrices are all set to identity matrix, meaning the "zero" position correspond to the position of the marker when the segment was created. If you want to introduce a zero position you should define a value for these rotation matrice.
Please note that rotation are hard to vizualize for human, so instead of defining rtinmatrix 1
and providing the full transformation matrix, remove this flag, then you can use Euler angles for these values. For example: rt 1 2 3 yzx 4 5 6
will be interpreted as translations of x=4, y=5 and z=6 followed by rotation of 1 rad about y, 2 rad about z, 3 rad about x (the sequence is given by the three axes name, here yzx).
you know what is the transformation between the biorbd angles to that model?
This sentence suggest that you downloaded the model somewhere and tried to use directly. If it is the case, it cannot work. You have to create your own bioMod based on the dimension of your subject. It is possible though to use this one as a reference to create your own. But unless your subject is exactly the same size as the model and the markers are exactly placed at the same position on your subject and on the one that created this model, the reconstruction will give random results
Hope this helps
@pariterre
Thanks a lot for your detailed explanation.
To make the bioMod model I used a few trials from one the trials captured from Vicon that the participant did not move and they were at the static posture. Then I used lua model converter from IOR marker set and from the lua file I created the bioMod file. It seems my static trial might have caused the error.
Is there any recommendation to extract the static trial?
The static trial should be either in T-pose or in a relax position (arms almost rested along the body). Using the mean of the data is trickier than it seems as a slight movement of the subject can cause great damage to the resulting model. I personnally never use more than 5 to 50 frames during my static trial, which is long enough to mitigate the electric noise of the camera while being short enough to not pick-up movement such as respiration or natural sway.
For the converter of lua model to bioMod, I don't see major issues with that approach
In order to convince yourself that your static trial is good (and the underlying model too), you can reconstruct the static trial and it should be almost perfect
@pariterre
Thanks a lot for your explanation. I generated a new model. But cannot get the output you showed above.
I also used the same method as yours.
Are you talking about the red markers? If so, I added a line before the "b.exec()" which is b.load_experimental_markers(markers / 1000)
@pariterre yes thanks a lot.
Hi everyone !
I'm really interested by your approach since I recorded subjects too with a full body plug-in gait. Is it possible to share your code since I'm new to biorbd and I'm struggling with it please ?
Thank you in advance and I wish you a very good day !
Dear @NicolasGrandin !
You will find an example on how to reconstruct kinematics using biorbd over here: https://github.com/pyomeca/biorbd/blob/master/examples/python3/inverseKinematicsKalman.py
Please note, that biorbd, by virtue of using Generalized Coordinates, will not emulate the behavior of the Plug-in-Gait. If your goal is to match the results from PiG, I suggest to use PyCGM (https://pycgm2.netlify.app/cgm/cgm1.1/). If ressembling the PiG is enough, I am working (part-time) on using PiG in a kinematic chain manner. You can find the source code here: https://github.com/cr-crme/walkerKinematicReconstruction Please note it is an internal project... So it is not as near much documented as a proper project and probably still buggy!
If you need further assistance, you are welcomed to open a new issue!
@NicolasGrandin Please open a new issue for this continuation of conversation so @MahsaP don't get too spammed!