Where can I find the modified .osim file?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Caesar Lin
Posts: 9
Joined: Sun Apr 05, 2020 6:38 pm

Where can I find the modified .osim file?

Post by Caesar Lin » Wed May 06, 2020 6:04 am

Hi all,

After I successfully run the .m file to add a torque actuator to the gait2354_simbody.osim file, where can I find the modified model and open it in OpenSim? I tried to open the original gait2354_simbody.file but the actuator doesn't exist.

As a reference, the .m file is shown below:
import org.opensim.modeling.*

myModel = Model('gait2354_simbody.osim'); % Create a Model Object from file
femur_r = myModel.getBodySet().get('femur_r'); % Get a handle to the femur
tibia_r = myModel.getBodySet().get('tibia_r'); % Get a handle to the tibia
zAxis = Vec3(0,0,1); % A Vec3 of the z-axis
torqueActuator = TorqueActuator(); % Create a TorqueActuator Object
torqueActuator.setBodyA(femur_r); % Set BodyA
torqueActuator.setBodyB(tibia_r); % Set BodyB
torqueActuator.setAxis(zAxis); % Set the axis about which the torque will act
torqueActuator.setOptimalForce(10); % Set the optimal force (gain) of the actuator
Thank you for your help!
Caesar

Tags:

User avatar
Ayman Habib
Posts: 2252
Joined: Fri Apr 01, 2005 12:24 pm

Re: Where can I find the modified .osim file?

Post by Ayman Habib » Wed May 06, 2020 10:18 am

Hello,

The code snippet you sent modifies a model in memory but never writes it to a file so no wonder you can't find it. After you modify the model you ca add the line

Code: Select all

myModel.print("mymodifiedModel.osim")
and then the model will be written to a file.

Best regards,
-Ayman

User avatar
Caesar Lin
Posts: 9
Joined: Sun Apr 05, 2020 6:38 pm

Re: Where can I find the modified .osim file?

Post by Caesar Lin » Wed May 06, 2020 7:51 pm

Hi Ayman,

Thank you so much for your reply!

I added this line of code and a new .osim file appears. But there is no torque actuator added to this new model. I wonder why is it the case?

Appreciatively,
Caesar

User avatar
Ayman Habib
Posts: 2252
Joined: Fri Apr 01, 2005 12:24 pm

Re: Where can I find the modified .osim file?

Post by Ayman Habib » Thu May 07, 2020 11:15 am

Hello Caesar,

The code snippet above creates a TorqueActuator but does not add it to the model, you'll need to call:

Code: Select all

myModel.addForce(torqueActuator)
In general I suggest you check the matlab examples available here
https://simtk-confluence.stanford.edu/d ... pleScripts

as they demonstrate how to use OpenSim from Matlab, including model building functions and running tools.

Hope this helps,
-Ayman

User avatar
Caesar Lin
Posts: 9
Joined: Sun Apr 05, 2020 6:38 pm

Re: Where can I find the modified .osim file?

Post by Caesar Lin » Fri May 08, 2020 8:05 pm

Hi Ayman,

Thank you so much for your help!

Appreciatively,
Caesar

POST REPLY