Inverse Dynamic

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

Inverse Dynamic

Post by Samane Amini » Mon Nov 23, 2020 7:00 am

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

Tags:

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: Inverse Dynamic

Post by Thomas Uchida » Mon Nov 23, 2020 8:10 am

This works in Python:

Code: Select all

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

User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

Re: Inverse Dynamic

Post by Samane Amini » Mon Nov 23, 2020 9:01 am

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])

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: Inverse Dynamic

Post by Thomas Uchida » Tue Nov 24, 2020 3:26 pm

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]"

POST REPLY