Input to coordinate actuator

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Re: Input to coordinate actuator

Post by Nithin Kurup » Tue Nov 11, 2014 12:01 pm

Hi Ajai,

I tried with double. and also tried with upd and getMutliBodySystem both are showing the same error. I think it must be some mistake in my coding. Sorry for troubling.
rror because:SimTK Exception thrown at State.cpp:2080:
State Cache entry was out of date at Stage Dynamics. This entry depends on version 6175 of Stage Dynamics but was last updated at version 6174.

manager.integrate(s);
osimModel.updMultibodySystem().realize(s, Stage::Dynamics);
const JointSet &JointSet = osimModel.getJointSet();
int joint = JointSet.getSize();
double Power = osimModel.updJointSet().get("crank_Joint").calcPower(s);
cout<<"Internal Power produced is :" << Power << std::endl;

Sorry again,

Nithin

User avatar
Jiang Ping
Posts: 132
Joined: Sun Aug 26, 2012 4:09 am

Re: Input to coordinate actuator

Post by Jiang Ping » Tue Nov 11, 2014 12:05 pm

ex10192 wrote:Dear Jiang,

Thanks a lot for your reply, I tried to put the dynamics section, but still get the error.
Error because:SimTK Exception thrown at State.cpp:2080:
State Cache entry was out of date at Stage Dynamics. This entry depends on version 6175 of Stage Dynamics but was last updated at version 6174.

Code: Select all

               manager.integrate(s);
		osimModel.getMultibodySystem().realize(s, Stage::Dynamics); 
		Array <double> Power = osimModel.getJointSet().get("crank_Joint").calcPower(s); 
		cout<<"Internal Power produced is :" << Power[0] << std::endl;

Let's have a last try.

Change the position of "osimModel.getMultibodySystem().realize(s, Stage::Dynamics);"
Let the system realize the dynamics stage before simulation.
Thanks again,

Code: Select all

osimModel.getMultibodySystem().realize(s, Stage::Dynamics);                
manager.integrate(s);
Array <double> Power = osimModel.getJointSet().get("crank_Joint").calcPower(s); 
cout<<"Internal Power produced is :" << Power[0] << std::endl;

User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Re: Input to coordinate actuator

Post by Nithin Kurup » Tue Nov 11, 2014 12:14 pm

Jiang,

I tried but got the first error I posted. I tried changing the joint incase I made some indexing error, but for all other joints which are not prescribed I get a 0 power value which is correct I guess. And the only problem is for the prescribed one.

I will keep on trying.. tks a ton.

nithin

User avatar
Michael Sherman
Posts: 806
Joined: Fri Apr 01, 2005 6:05 pm

Re: Input to coordinate actuator

Post by Michael Sherman » Tue Nov 11, 2014 12:17 pm

jp123909 wrote: if (s.getSystemStage() < Stage::Dynamics)
osimModel.getMultibodySystem().realize(s, Stage::Dynamics);
Actually you don't need to check the system stage first -- realize() does that internally. It really means "bring state up to this stage if it isn't already there".

Sherm

User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Re: Input to coordinate actuator

Post by Nithin Kurup » Tue Nov 11, 2014 12:29 pm

Dear Sherman ,

Thanks for the info,, I have changed upd and get for the MultibodySystem still getting error. I tried to run for other joints that dont have prescribed function, and get a power =0 as shown in attached output log. but only when I use the prescribed coordinate it shows this cache error.

Hope its not some coding error i made and will double check my osim model .

manager.integrate(s);
osimModel.updMultibodySystem().realize(s, Stage::Dynamics);
const JointSet &JointSet = osimModel.getJointSet();
int joint = JointSet.getSize();
double Power = osimModel.updJointSet().get("crank_Joint").calcPower(s);
cout<<"Internal Power produced is :" << Power << std::endl;

I tried to run the code couple of times, still getting the same cache error.. if anyone can run and find internal power for the prescribed controller, please let me too know.. thanks. :(

thanks
nitin

User avatar
Michael Sherman
Posts: 806
Joined: Fri Apr 01, 2005 6:05 pm

Re: Input to coordinate actuator

Post by Michael Sherman » Tue Nov 11, 2014 4:28 pm

Hi, Nithin. There are some odd things in your code that might not be causing the problem but should be taken care of just to get them out of the way.

(1) You have named a variable "JointSet" which is identical to the class name. The best way to avoid this when using OpenSim code is to follow OpenSim conventions -- if you start your variable names with lower case letters you won't have a conflict with class names.
(2) But then after creating that variable and obtaining its size, you aren't using either one.
(3) You have called "updJointSet()" rather than "getJointSet()". "upd" indicates you are adding a new joint to the model, which may cause the whole model to be reinitialized.

I don't think any of those necessarily explains the problem. But it does make it harder to think about the code.

Regards,
Sherm

User avatar
Michael Sherman
Posts: 806
Joined: Fri Apr 01, 2005 6:05 pm

Re: Input to coordinate actuator

Post by Michael Sherman » Tue Nov 11, 2014 4:30 pm

PS similar comment regarding updMultibodySystem() -- should be getMultibodySystem()

PPS you can just call realize(s) to calculate everything in a state; that is equivalent to realize(s,Stage::Acceleration).

User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Re: Input to coordinate actuator

Post by Nithin Kurup » Tue Nov 11, 2014 4:41 pm

Dear Sherman,

Thanks a lot for spending time on my problem. Really sorry for causing inconvenience. Its most probably my mistake and, I have inserted some wrong code in my program.

I will try to make the changes you have pointed out.


Thanking you again,

Nithin
Last edited by Nithin Kurup on Wed Nov 12, 2014 4:47 pm, edited 1 time in total.

User avatar
Nithin Kurup
Posts: 149
Joined: Sat Jan 18, 2014 5:13 am

Re: Input to coordinate actuator

Post by Nithin Kurup » Wed Nov 12, 2014 4:39 pm

Dear Sherman, Ajay & Jiang

Thanks a lot for all your comments, found the solution and error.


Error: osimModel.getMultibodySystem().realize(s, Stage::Dynamics);

Msg :SimTK Exception thrown at State.cpp:2080: State Cache entry was out of date at Stage Dynamics. This entry depends on version 6175 of Stage Dynamics but was last updated at version 6174.
Solution:
osimModel.getMultibodySystem().realize(s, Stage::Acceleration); or
osimModel.getMultibodySystem().realize(s);
Result:The Number of Joints in the Model is :15
Internal Power produced is :7.36069

Thanks again for the hint and help.

Nithin

User avatar
Michael Sherman
Posts: 806
Joined: Fri Apr 01, 2005 6:05 pm

Re: Input to coordinate actuator

Post by Michael Sherman » Wed Nov 12, 2014 4:57 pm

Glad that worked, Nithin! But there may be a bug there -- Ajay, shouldn't calcPower() work at Dynamics stage? Nithin got an exception unless he first realized to Acceleration stage.

Sherm

POST REPLY