Modify expressions of ExpressionBasedBushingForce through MATLAB...

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Stefan Schmid
Posts: 10
Joined: Wed Apr 05, 2017 4:50 am

Modify expressions of ExpressionBasedBushingForce through MATLAB...

Post by Stefan Schmid » Tue May 07, 2019 12:47 pm

Hi

It seems that I'm not able to figure out how to modify the expressions (e.g. <Mx_expression>) of an ExpressionBasedBushingForce through MATLAB. Can anyone help me with that?

Thanks
-Stefan

Tags:

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

Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...

Post by Thomas Uchida » Tue May 07, 2019 1:45 pm

Here is the documentation for the ExpressionBasedBushingForce class in OpenSim 3.3: https://simtk.org/api_docs/opensim/api_ ... Force.html. You can use the methodsview function in Matlab to see which methods are available from this class through the Matlab scripting interface (see https://simtk-confluence.stanford.edu:8 ... ith+Matlab). I don't have a test environment, but you could try setMxExpression() or set_Mx_expression().

User avatar
Stefan Schmid
Posts: 10
Joined: Wed Apr 05, 2017 4:50 am

Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...

Post by Stefan Schmid » Thu May 16, 2019 12:22 pm

Thanks for the reply Thomas!

However, I could still not figure out how to do it. I have a model, which includes the expression-based bushing force "L5S1_Disc_forces". In the OpenSim GUI, I can see this force under Forces/Other Forces. And when I run the following code in MATLAB, I can "see" the force as well.

import org.opensim.modeling.*
modelpath = ['xxxxxxxxx.osim'];
myModel = Model(modelpath);
BushingForce = myModel.getForceSet().get(635);


What would now be the code to read out the properties (e.g. Mx_Expression) of this force through MATLAB?

Please let me know if you need more information.

Thanks a lot for your help!
-Stefan

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

Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...

Post by Thomas Uchida » Thu May 16, 2019 12:51 pm

Please see the "Common Scripting Commands" page in the Confluence documentation (https://simtk-confluence.stanford.edu:8 ... g+Commands -- search the page for "downcast"). In short, you need to tell MATLAB that the object is of type ExpressionBasedBushingForce, not just a generic Force object. You should have something like this:

Code: Select all

myModel = Model('filename.osim');
force = myModel.getForceSet.get('nameOfComponent');
ebbf = ExpressionBasedBushingForce.safeDownCast(force);
ebbf.getMxExpression()
ebbf.setMxExpression('theta_x+2*theta_x^2')
ebbf.getMxExpression()

User avatar
Stefan Schmid
Posts: 10
Joined: Wed Apr 05, 2017 4:50 am

Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...

Post by Stefan Schmid » Thu May 16, 2019 1:21 pm

This is exactly what I was looking for and it works - thank you so much for your help Thomas!
-Stefan

POST REPLY