Page 1 of 1

Inverse Dynamic

Posted: Mon Nov 23, 2020 7:00 am
by amini_opensim
Hello guys
I want to know if how I define the acceleration vector (u_dot) for the following code in Matlab

ID = InverseDynamicsSolver(Model);
uS = Model.getNumSpeeds();
u_dot = Vector(uS,1)
ID.solve(state,u_dot)

In the above code I defined : u_dot = Vector(uS,1). this code yields:
~[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]

but I define the acceleration vector with different values. like: [10 8 1 14 10 15 1 1 1 51 1 61 1 1 1 74 1 7 1 1 -1 1 1]
by Vector(uS,1) I just defined only value. How do I get it?
Thanks

Re: Inverse Dynamic

Posted: Mon Nov 23, 2020 8:10 am
by tkuchida
This works in Python:

Code: Select all

v = osim.Vector([1.1,1.2,1.3,1.4,1.5])

Re: Inverse Dynamic

Posted: Mon Nov 23, 2020 9:01 am
by amini_opensim
Sorry Dear Uchida
This doesn't work in matlab.
u_dot = Vector([1.1,1.2,1.3,1.4,1.5,1.1,1.2,1.3,1.4,1.5,1.1,1.2,1.3,1.4,1.5,1.1,1.2,1.3,1.4,1.5,1.1,1.2,1.3])

answers:
No constructor 'org.opensim.modeling.Vector' with matching signature found.

Error in MOpensim2 (line 136)
u_dot = Vector([1.1,1.2,1.3,1.4,1.5,1.1,1.2,1.3,1.4,1.5,1.1,1.2,1.3,1.4,1.5,1.1,1.2,1.3,1.4,1.5,1.1,1.2,1.3])

Re: Inverse Dynamic

Posted: Tue Nov 24, 2020 3:26 pm
by tkuchida
Unfortunately, I don't have Matlab to investigate but you should at least be able to set each element like this:

Code: Select all

import opensim as osim
L = [1.1,1.2,1.3,1.4,1.5]
v = osim.Vector(5,0)
print v  #prints "~[0 0 0 0 0]"
for i in range(len(L)):
    v.set(i,L[i])
print v  #prints "~[1.1 1.2 1.3 1.4 1.5]"