Hi Pavel,
Thanks for your last help, Now using Python(x,y) AnyBody is running. Nevertheless I have another problem, I´m using this function of Python to calculate and save the velocity of the ligament ( with the pickleACL1.txt file I´m saving the length of ligaments at previous step ):
import pickle
def doit(context, x0, x1):
inFile = open('pickleACL1.txt','rb')
posizione = pickle.load(inFile)
inFile.close()
if x1==0:
position = x0[0]
tempo = 0
else:
tempo = 0
position = x0[0]
tempo = tempo + 0.0537
if tempo==0:
vel=0
else:
vel=(position-posizione)
outFile = open('pickleACL1.txt','wb')
pickle.dump(position,outFile)
outFile.close()
t = (vel,posizione)
return t
This is linked with the following AnyBody request:
[SIZE=3]AnyForce[/SIZE] ACL1 =
{
[SIZE=3]AnyKinPLine[/SIZE] lin =
{
[SIZE=3]AnyRefNode[/SIZE] &Ori = Main.HumanModel.BodyModel.Right.Leg.Seg.Thigh.CruciatumAnterior1;
[SIZE=3]AnyRefNode[/SIZE] &Ins = Main.HumanModel.BodyModel.Right.Leg.Seg.Shank.CruciatumAnterior1;
[SIZE=3]AnyDrawPLine[/SIZE] drw =
{
Thickness = 0.0019;
RGB = {1,0,0};
};
};
[SIZE=3]AnyFloat[/SIZE] Dt = div (Main.Study.tEnd, Main.Study.nStep) ;
[SIZE=3]AnyFloat[/SIZE] i = div(Main.Study.t,Dt);
[SIZE=3]AnyVar[/SIZE] CSA = 0.000070*0.24;
[SIZE=3]AnyVar[/SIZE] eps0 = 0.02;
[SIZE=3]AnyVar[/SIZE] L0 = 0.03399856/(1+eps0);
[SIZE=3]AnyFloat[/SIZE] eps_a = (lin.Pos - L0)/L0*100;
[SIZE=3]AnyFloat[/SIZE] a = lin.Pos - L0;
[SIZE=3]AnyFloat[/SIZE] eps_e = (200000 * CSA+13);
[SIZE=3]AnyFloat[/SIZE] eps_h = (200000 * CSA+25);
[SIZE=3]AnyFloat[/SIZE] eps_r = (200000 * CSA+29);
[SIZE=3]AnyFunEx[/SIZE] FunPEx =
{
[SIZE=3]AnyVector[/SIZE] Return = {0,0};
[SIZE=3]AnyFunExMonoPy[/SIZE] doit =
{
ModuleFile = "AnyFunExACL1.py";
ArgList =
{
[SIZE=3]AnyVector[/SIZE] I = {0,0,0,0};
[SIZE=3]AnyFloat[/SIZE] Fe = 0.0;
};
};
};
[SIZE=3]AnyFunEx[/SIZE]& Fe = FunPEx;
[SIZE=3]AnyFloat[/SIZE] S2 = FunPEx({lin.Pos[0],CSA,Dt,L0}, i);
[SIZE=3][/SIZE]
[SIZE=3]AnyFloat[/SIZE] Length = 0.035^2/L0^2;
[SIZE=3][/SIZE][SIZE=3]AnyFloat[/SIZE][SIZE=3] [/SIZE]c_vog[SIZE=3] [/SIZE]=[SIZE=3] [/SIZE]2.2e8*[SIZE=3] [/SIZE]CSA[SIZE=3] [/SIZE]*[SIZE=3] [/SIZE]eps_a/Length;
[SIZE=3][/SIZE][SIZE=3]AnyFloat[/SIZE][SIZE=3] [/SIZE]c_max[SIZE=3] [/SIZE]=[SIZE=3] [/SIZE]c_vog;
[SIZE=3][/SIZE][SIZE=3]AnyFloat[/SIZE][SIZE=3] [/SIZE]damp[SIZE=3] [/SIZE]=[SIZE=3] [/SIZE]c_vog*0.5;
[SIZE=3]AnyFloat[/SIZE] h = iffun(gteqfun(eps_a[0],0.0),1.0,0.0);
[SIZE=3][/SIZE][SIZE=3]AnyFloat[/SIZE][SIZE=3] [/SIZE]v[SIZE=3] [/SIZE]=[SIZE=3] [/SIZE]S2[0]/Dt;
[SIZE=3][/SIZE][SIZE=3]AnyFloat[/SIZE][SIZE=3] [/SIZE]F_I[SIZE=3] [/SIZE]=[SIZE=3] [/SIZE]mult(c_max,a)[SIZE=3] [/SIZE]+[SIZE=3] [/SIZE]mult(damp,v);
F = F_I[0];
};
I haven´t understood why with the kinematics, the Python function, gives me right values, but when I use the Inverse dynamics the function save wrong ligaments lengths!!!
Why the function works differently between kinematics and Inverse dynamics? Should AnyBody wait for the function answer before continue???
Thanks,
best regards,
Giovanni