Matlab API - 'model.setStateVariableValue()' unable to find coordinate name

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Wen Wu
Posts: 5
Joined: Tue Jun 13, 2017 8:49 pm

Matlab API - 'model.setStateVariableValue()' unable to find coordinate name

Post by Wen Wu » Thu Dec 06, 2018 5:46 pm

I found 'model.setStateVariable()' was updated to 'model.setStateVariableValue()' in OpenSim API 4.0. However, I had the following error when trying to use 'model.setStateVariableValue()', while same setup worked for previous version 'model.setStateVariable()'. I am wondering if the newer version has some modificatoin to the model coordinate name?

Code: Select all

Java exception occurred:
java.lang.RuntimeException: Component::setStateVariable: ERR- state named 'pelvis_tx' not found in Visual3d of type Model.


	at org.opensim.modeling.opensimCommonJNI.Component_setStateVariableValue(Native Method)

	at org.opensim.modeling.Component.setStateVariableValue(Component.java:214)
	
Thank you!

Tags:

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Matlab API - 'model.setStateVariableValue()' unable to find coordinate name

Post by Christopher Dembia » Thu Dec 06, 2018 6:13 pm

Use getStateVariableNames() to see the new names of state variables. It'll be something like `/jointset/pelvis_ground/pelvis_tx/value`.

User avatar
Wen Wu
Posts: 5
Joined: Tue Jun 13, 2017 8:49 pm

Re: Matlab API - 'model.setStateVariableValue()' unable to find coordinate name

Post by Wen Wu » Sun Dec 09, 2018 4:35 pm

chrisdembia wrote:
Thu Dec 06, 2018 6:13 pm
Use getStateVariableNames() to see the new names of state variables. It'll be something like `/jointset/pelvis_ground/pelvis_tx/value`.
Thank you for your reply. However, the return of the getStateVariableNames() is something like, 'org.opensim.modeling.ArrayStr@5bbc9f97', which also did not work.

Alternatively, I used 'my_coor_set.get('pelvis_tx').setValue(myState, 0.0)', but Matlab crashed (sreenshot attached)...
Attachments
setstatevalue_error.png
setstatevalue_error.png (18.41 KiB) Viewed 358 times

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

Re: Matlab API - 'model.setStateVariableValue()' unable to find coordinate name

Post by Thomas Uchida » Sun Dec 09, 2018 8:29 pm

However, the return of the getStateVariableNames() is something like, 'org.opensim.modeling.ArrayStr@5bbc9f97', which also did not work.
You can print each element of the array:

Code: Select all

svn = model.getStateVariableNames();
for i = 1:svn.getSize()
    svn.get(i-1)
end

User avatar
Wen Wu
Posts: 5
Joined: Tue Jun 13, 2017 8:49 pm

Re: Matlab API - 'model.setStateVariableValue()' unable to find coordinate name

Post by Wen Wu » Tue Dec 18, 2018 10:43 pm

Thank you Thomas!

In addtion to my previous post on Matlab crash, I found that it was caused by 'InverseDynamicsTool.run()'. It seems after 'InverseDynamicsTool.run()', calling any OpeSim API (e.g. 'model.setStateVariableValue()', 'model.equilibrateMuscles(state)', etc) would result in a Matlab crash...

POST REPLY