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
Inverse Dynamic
- Samane Amini
- Posts: 101
- Joined: Sun Jan 12, 2020 3:48 am
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Inverse Dynamic
This works in Python:
Code: Select all
v = osim.Vector([1.1,1.2,1.3,1.4,1.5])
- Samane Amini
- Posts: 101
- Joined: Sun Jan 12, 2020 3:48 am
Re: Inverse Dynamic
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])
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])
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Inverse Dynamic
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]"