Forums Anyscript.org Changing force plates in Foot MoCAP model
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 Notices Meet us !

#31
11-20-2017, 04:45 PM
 Zach_Welshman Member Join Date: Sep 2016 Posts: 38
Altering Foot location and Final2 functions

Quote:
 Originally Posted by basialys2 Dear Zach and Soren, thanks to your conversation I was able to solve many problems I had on the way to make my GM foot model run. I am already able to load my model with #define InverseDynamicModel and #define FirstRun switched to 1. However I still need to work on reading pressure data. I was trying to analyze Footlocation and Final2 python files but there are some places when I am not sure how to change the code to work nicely with my data. The biggest concerns are about the line LongCoo = 0.049+(Rb+0.5+i)*CellL and LatCoo = 0.4 -0.049 -64*CellW + (Rl+0.5+i)*CellW I know the numbers in expressions concern foot location offset but do you have any hints how to set this numbers no work on my model? Does any number mean something exactly?
Hi,
It's good to see that you are making progress. I'm glad the thread has been helpful to you, as it has been to me. Are you working at an academic institution?

LongCoo and LatCoo correspond with the StrikeFootRef.

When you say:

LongCoo = 0.049+(Rb+0.5+i)*CellL
and
LatCoo = 0.4 -0.049 -64*CellW + (Rl+0.5+i)*CellW

Am I right in saying that you are referring to:

FootLocation4.py

...

Code:
```    #First time step CoP, correspond to heel strike location
#*******************************************************
Step1Vec = Data[0][1:]

LongWeightedStep1Vec = []
for i in range(Rh):
LongCoo = 0.049+(Rb+0.5+i)*CellL
#print(LongCoo)
for j in range(Rw):
LongWeightedStep1Vec.append(Step1Vec[i*Rw+j]*LongCoo)
#LongWeightedStep1Vec.append(Step1Vec[i*Rw+j]*LongCoo)

LongCooStrike = sum(LongWeightedStep1Vec)/sum(Step1Vec)
#print(LongCooStrike)

LatWeightedStep1Vec = []
for i in range(Rw):
LatCoo = 0.4 -0.049 -64*CellW + (Rl+0.5+i)*CellW
for j in range(Rh):
LatWeightedStep1Vec.append(Step1Vec[j*Rw+i]*LatCoo)

LatCooStrike = sum(LatWeightedStep1Vec)/sum(Step1Vec)

#print(Step1Vec)```
If so, Step1Vec refers to the first frame in your pressure file. If you remove the pound sign (hashtag) from:

Code:
```    #First time step CoP, correspond to heel strike location
#*******************************************************
Step1Vec = Data[0][1:]

LongWeightedStep1Vec = []
for i in range(Rh):
LongCoo = 0.049+(Rb+0.5+i)*CellL
#print(LongCoo)
for j in range(Rw):
LongWeightedStep1Vec.append(Step1Vec[i*Rw+j]*LongCoo)
#LongWeightedStep1Vec.append(Step1Vec[i*Rw+j]*LongCoo)

LongCooStrike = sum(LongWeightedStep1Vec)/sum(Step1Vec)
#print(LongCooStrike)

LatWeightedStep1Vec = []
for i in range(Rw):
LatCoo = 0.4 -0.049 -64*CellW + (Rl+0.5+i)*CellW
for j in range(Rh):
LatWeightedStep1Vec.append(Step1Vec[j*Rw+i]*LatCoo)

LatCooStrike = sum(LatWeightedStep1Vec)/sum(Step1Vec)

print(Step1Vec)```
This will print out the first frame directly from pressure.txt file on the python interpreter you are using. E.g. not the AnyBody system, but a separate python debugger. For me, this is really the first check to ensure that your pressure.txt data has been formatted correctly.

Also, when you run the model can you see the pressure nodes (below) on the force platform?

Environment.any:

Code:
```     AnyFolder &GlobalRef = .GlobalRef;
GlobalRef = {
AnyRefNode StrikeFootRef = {
sRel = {..FootLocationCooVec[0] , ..FootLocationCooVec[1], 0};
AnyDrawNode Draw = {ScaleXYZ=0.005*{1,1,1}; RGB={1,0,0};};
};
AnyRefNode PosteriorFootRef = {
sRel = {..FootLocationCooVec[2] , ..FootLocationCooVec[3], 0};
AnyDrawNode Draw = {ScaleXYZ=0.005*{1,1,1}; RGB={0,1,0};};
};
AnyRefNode AnteriorMedialFootRef = {
sRel = {..FootLocationCooVec[4] , ..FootLocationCooVec[5], 0};
AnyDrawNode Draw = {ScaleXYZ=0.005*{1,1,1}; RGB={0,0,1};};
};
AnyRefNode AnteriorLateralFootRef = {
sRel = {..FootLocationCooVec[6] , ..FootLocationCooVec[7] , 0};
AnyDrawNode Draw = {ScaleXYZ=0.005*{1,1,1}; RGB={1,1,0};};
};
AnyRefNode DistalFootRef = {
sRel = {..FootLocationCooVec[8], ..FootLocationCooVec[9], 0};
AnyDrawNode Draw = {ScaleXYZ=0.005*{1,1,1}; RGB={0,0,0};};
};
AnyRefNode DistalPhal1Ref = {
sRel = {..FootLocationCooVec[10] , ..FootLocationCooVec[11] , 0};
AnyDrawNode Draw = {ScaleXYZ=0.005*{1,1,1}; RGB={0,0,0};};
};
AnyRefNode DistalPhal2Ref = {
sRel = {..FootLocationCooVec[12] ..FootLocationCooVec[13], 0};
AnyDrawNode Draw = {ScaleXYZ=0.005*{1,1,1}; RGB={0,0,0};};
};```
As Søren suggested these are integers reading from the left corner, but depending on the format of your pressure data, these could be floating point numbers, which might need changing in the python scripts when reading the in the pressure data.

Hope this helps,

Thanks,
Zach
#32
11-29-2017, 07:34 PM
 basialys2 Junior Member Join Date: Oct 2017 Posts: 6

Dear Zach and Soren,

Soren, do you know what's the meaning of this "other values" you have mentioned? Acctualy I was able to deduct what does parameter Rb, Rv, CellW, CellL etc. mean but numbers 0.4, 0.049 and 64 are not described. Do they respond to any special dimensions in the laboratory?

Zach, I am PhD student at Warsaw University of Technology. Thank you a lot for nice description of the script. I was debbuging final2.py and FootLocation4.py and I was able to check If my data inputs properly. My biggest problem right now Is adjusting the numbers in the expression below and in other expressions where they occure.

LongCoo = 0.049+(Rb+0.5+i)*CellL
and
LatCoo = 0.4 -0.049 -64*CellW + (Rl+0.5+i)*CellW

Could you tell me more how did you adjust this expressions to fit your laboratory setup?

Best regards,
Barbara
#33
11-30-2017, 03:52 PM
 Zach_Welshman Member Join Date: Sep 2016 Posts: 38

Hi Barbara,

The numbers you mention (to my knowledge) represent a systematic offset that is specific to the labratory. Change the offset to alter the location. This requires a lot of experimentation, at least for me anyway.
Zach
#34
12-07-2017, 12:12 AM
 basialys2 Junior Member Join Date: Oct 2017 Posts: 6

Dear Zach, thanks for your sugestions. Pressure nodes after loading my model are not on the forceplate, because I havn't adjusted the offset yet.
I have hovewer another worry. I think some of my nodes are not located correctly. For example I have problem with AnteriorMedialFootRef. The x coordinate was very high (ca -93) what is rather wrong (the node was to far from global ref to appear in model view). When I have looked into FootLocation code I found if function which may multiply the result of LatCoo by 1000 what must have happened in my case, and caused the parameter to be wrong calculated. Did you need to change the code of FootLocation to calculate Pressure Nodes correctly, or you have only changed the offset and rotation?

And have you changed the offset by proposing some changes and than looking at the effect on visualisation, or you had different method to do so?

One more time thank you a lot for your help!

Best regards,
Barbara

Quote:
 Originally Posted by Zach_Welshman Hi Barbara, The numbers you mention (to my knowledge) represent a systematic offset that is specific to the labratory. Change the offset to alter the location. This requires a lot of experimentation, at least for me anyway. Zach
#35
12-11-2017, 04:20 PM
 Zach_Welshman Member Join Date: Sep 2016 Posts: 38

Hi Barbra,

If you are referring to specific code, perhaps it would be more beneficial to include it in your post.

Your issue could mean that the data is not being read in from the pressure.txt matrix correctly in which case I'd say it's a formatting issue. Depending on how you have formatted your pressure matrix, you can either change the offset of the pressure matrix or change the python script. I found the current repositry pressure set-up to be coincidental with the direction of the repositry mocap data - so you need to think about how your data relates and adjust accordingly.

you can see all the footprint variables if you run footlocation in a python interpreter:

FootLocation.py...

Code:
```CooVec = [LatCooStrike,LongCooStrike,
LatCooPosterior,LongCooPosterior,
LatCooAnteriorMedial,LongCooAnteriorMedial,
LatCooAnteriorLateral,LongCooAnteriorLateral,
LatCooDistal,LongCooDistal,
LatCooPhal1,LongCooPhal1,
LatCooPhal2,LongCooPhal2]

CooVecTuple = tuple(CooVec)```
...

Check your variable/tuple list to see if it is formatted like the repositry model, if it is not then adjust the python script to make it concurrent throughout the model.
Zach

Quote:
 Originally Posted by basialys2 Dear Zach, thanks for your sugestions. Pressure nodes after loading my model are not on the forceplate, because I havn't adjusted the offset yet. I have hovewer another worry. I think some of my nodes are not located correctly. For example I have problem with AnteriorMedialFootRef. The x coordinate was very high (ca -93) what is rather wrong (the node was to far from global ref to appear in model view). When I have looked into FootLocation code I found if function which may multiply the result of LatCoo by 1000 what must have happened in my case, and caused the parameter to be wrong calculated. Did you need to change the code of FootLocation to calculate Pressure Nodes correctly, or you have only changed the offset and rotation? And have you changed the offset by proposing some changes and than looking at the effect on visualisation, or you had different method to do so? One more time thank you a lot for your help! Best regards, Barbara
#36
12-28-2017, 12:53 PM
 basialys2 Junior Member Join Date: Oct 2017 Posts: 6

Dear Zach,
sorry for late reply but I wanted to check a couple of things in my model before I answer.

I was debuging final2 and footlocation python files and I know that my pressure data is read correctly. The problem Is that some of the functions inside final2.py contain if statements that cause FootPressureNodeCoeffVec to be filled with 0. In the result of that the force applied to the nodes is multiplied by 0 what in effect cause that 0 force is applied to the model. That is good reason why Inverse Dynamics fails with the error: ERROR(OBJ.MCH.MUS4) : D:/A..y/AMMR/A..n/Beta/M..a/M..l/InverseDynamics.any(22) : InverseDynamicStudy.InverseDynamics : Muscle recruitment solver : solver aborted due to singular KKT matrix

I was trying a lot to adjust the offset properly so that I get some valus in my
FootPressureNodeCoeffVec but unfortunately without sucess. I have decided to write my own function, which will create my FootPressureNodeCoeffVec. Because I am much better in Matlab than in Python (I have started using Python when I had to analyze final2.py and footlocation.py) I have created mat file in matlab which is later imported into python. FootPressureNodeCoeffVec should be loaded to Anybody depending on the timestep. Now I can see force applied to the nodes but unfortunately the error:

ERROR(OBJ.MCH.MUS4) : D:/A..y/AMMR/A..n/Beta/M..a/M..l/InverseDynamics.any(22) : InverseDynamicStudy.InverseDynamics : Muscle recruitment solver : solver aborted due to singular KKT matrix

appeared again and I am completely lost what to do next. Do you have any suggestions?

I have attached my model below
Attached Files
#37
01-02-2018, 05:24 PM
 Zach_Welshman Member Join Date: Sep 2016 Posts: 38
GM Model

Hello, sorry for the late reply

I've had a look at your model and have a few ideas that might be useful.

1. Your MoCap Data starts around 3.82 you try could reframing from 0 this could make the numbers easier to deal with.

2. Ensure the length of your mocap study (800ms) is same length as your pressure data input (817.38ms).

3. In the footlocation.py (or your equivalent) I see your CooVec Tuple output to be

Code:
`(0.7108815789473686, 1.782934210526317, 0.7101500000000001, 1.8015499999999984, 0.69925, 1.96725, 0.80975, 1.94175, 0.7077500000000001, 2.0267500000000003, 0.7188809523809522, 2.008333333333333, 0.765125, 2.0012499999999998)`
these numbers correspond to the LongCooStrike, LatCooStrike etc and may/may not make sense based on your labratory set up. I would check these numbers against the original GM model.

As the issue seems to be the interpolation of the data (When I run the model), I would start by ensuring the length of the study is exactly the same as the length of the pressure data e.g. your study should be 817.38ms.

Hope this helps.
Zach

Last edited by Zach_Welshman; 01-02-2018 at 06:13 PM. Reason: Clarification
#38
01-02-2018, 06:58 PM
 Zach_Welshman Member Join Date: Sep 2016 Posts: 38

The attached image, Looks as if you need to relocate your foot location nodes as well as the above suggestions about the length of study.

I also changed

Environment.any from

AnyFolder FootLocation = {

AnyFunEx FootLocationFun =
{
AnyVector Return = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
AnyFunExMonoPy LocationFunction =
{
ModuleFile = "FootLocation4.py";
ArgList =
{
AnyString path = " ";
};
};
};

// AnyVector FootLocationCooVec = FootLocationFun(Main.FootPrintFolderPath + "/Input/" +Main.TrialSpecificData.NameOfFile+ "-PressureData.txt");
AnyVector FootLocationCooVec = FootLocationFun(Main.FootPrintFolderPath + "/Input/stopaP.txt");

to

AnyFolder FootLocation = {

AnyFunEx FootLocationFun =
{
AnyVector Return = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
AnyFunExMonoPy LocationFunction =
{
ModuleFile = "FootLocation4.py";
ArgList =
{
AnyString path = " ";
};
};
};

// AnyVector FootLocationCooVec = FootLocationFun(Main.FootPrintFolderPath + "/Input/" +Main.TrialSpecificData.NameOfFile+ "-PressureData.txt");
AnyVector FootLocationCooVec = FootLocationFun(Main.FootPrintFolderPath + "/Input/ciesnienie_Stare/stopaP.txt");

As i thought that was what you were trying to do by using the matlab method of converting to a txt file for the Anybody script.

Try also changing foot location.py to

CellW = 0.005
CellL = 0.00762

offset_wys = -1.47;
offset_szer = 0.45;

Also, just a note, the scaling on your distal foot does not seem to look typical, but of course I could be wrong.

Thanks,
Zach
Attached Images
 GMModel_AnyBody_Usr_B.JPG (21.1 KB, 7 views)

Last edited by Zach_Welshman; 01-02-2018 at 07:30 PM. Reason: Adding information
#39
01-08-2018, 03:14 PM
 basialys2 Junior Member Join Date: Oct 2017 Posts: 6

Dear Zach,

thank you a lot for deeply analysing my case. I must say that I am a bit confused right now.

I will start with scalling isue. As you have noticed the calcaneus bone seems to be too narrow... I have no idea why... I have analysed scaling in MeshLab one more time but all points seem to be marked properly (anyscrip2.png, anyscript3.png) and they are also imported into Anybody without problems... Do you think the orientation of the model in space may influence scaling?

I have also checked all other scaling parameters in AnyManRBF and I havn't found anything what could cause the calcaneus bone to be not scaled properly...

Concerning pressure data:
That's wird that when you open model on your computer foot location points and coordinates are so far from the model. I have different view of this:

Concerning timing:
because final2.py was not giving me good results concerning pressure distribution I have decided to do this on my own in Matlab. I have devided pressure mat into four regions and I assigned pressure value coefficient to the corresponding node. In this case I used wczytawsp function instead of final2py. This function is only to read the matrix created in matlab in the specific time. I I have interpolated newly created pressure data in Matlab so that it maches simulation time in AnyBody. Where have you checked that the times do not mach? Maybe I missed something?
Attached Images
 anyscript1.PNG (184.4 KB, 27 views) anyscript2.PNG (152.4 KB, 4 views) anyscript3.PNG (57.6 KB, 5 views)
#40
05-09-2018, 04:29 PM
 chamannii Junior Member Join Date: Jan 2017 Posts: 9
marker & forceplate C3D to anybody

Hi
I input C3D file to anybody i change name of marker and type of forceplate. but when i save and load ,i can't see the forceplate and line of all markers connect to origin(0,0,0)(blue markers).
I try to check the SRel each a marker , input to new file and search the github but i can't to slove this problem. I don't understand that where's mistake. Even if ,a past file i do same with this file but it s successly.
i can't attach file zip but i attach my pic.
Thank youuntitled.bmp

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Professional Forum     AnyBody Managed Model Repository     Gallery of user models and videos     AnyGait     AnyBody Exporter for SOLIDWORKS     Debug model General Forum     AnyBody Modeling System     Wish list for AMS and AMMR     Announcements Self-Supported Forum     AnyBody Model Repository     Debug model Archive     AnyScript Message Archive

All times are GMT +2. The time now is 03:43 AM.