Problem with the position of the model

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Zuren Arrh
Posts: 6
Joined: Tue Sep 18, 2018 6:07 am

Problem with the position of the model

Post by Zuren Arrh » Sat Oct 13, 2018 5:38 am

Hi all,

I'm a beginner with OpenSim, and recently I'm trying to import model file and visualize it through Python. According to the official document, I wrote some code to import the standard model file 'gait2345_simbody.osim' as follow:

Code: Select all

import opensim


folderName = 'E:/OpenSim 3.3/Models/Gait2354_Simbody'


modelFileName = folderName + '/gait2354_simbody_test.osim'
myModel = opensim.Model(modelFileName)

myModel.setUseVisualizer(True)
myState = myModel.initSystem()

while 1:
	myModel.getVisualizer().show(myState)
When I ran my code, the visualizer runs fine, but the funny thing is that half part of the model is buried under ground as shown below:
Image
Does anyone know how to adjust the position of the model in the visualizer so that the model can 'stand' on the ground? I'm trying to edit the '.osim' file through notepad++, but nothing works yet. Besides, is there some advice about how to deal with the interaction between the feet of model and the ground?

Thanks,
Zurenarrh

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Problem with the position of the model

Post by Dimitar Stanev » Sun Oct 14, 2018 2:27 am

You can change the position of the pelvis body:

Code: Select all

model.updCoordinateSet().get(coordinate_name).setValue(state, value)

User avatar
Zuren Arrh
Posts: 6
Joined: Tue Sep 18, 2018 6:07 am

Re: Problem with the position of the model

Post by Zuren Arrh » Sun Oct 14, 2018 6:43 am

Sorry to bother again, I try to fix it myself through the official document, but the API part are all c++, and there's no detailed explanation about 'updCoordinateSet()'. I'm not sure what the variables 'coordinate_name' and 'value' mean in the code and how to get their values before adding them into the code.(I tried to use the code, but failed.)

Thanks,
Zurenarrh
Last edited by Zuren Arrh on Sun Oct 14, 2018 6:50 am, edited 2 times in total.

User avatar
Zuren Arrh
Posts: 6
Joined: Tue Sep 18, 2018 6:07 am

Re: Problem with the position of the model

Post by Zuren Arrh » Sun Oct 14, 2018 6:46 am

mitkof6 wrote:
Sun Oct 14, 2018 2:27 am
You can change the position of the pelvis body:

Code: Select all

model.updCoordinateSet().get(coordinate_name).setValue(state, value)
Sorry to bother again, I try to fix it myself through the official document, but the API part are all c++, and there's no detailed explanation about 'updCoordinateSet()'. I'm not sure what the variables 'coordinate_name' and 'value' mean in the code and how to get their values before adding them into the code.(I tried to use the code, but failed.)

Thanks,
Zurenarrh

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

Re: Problem with the position of the model

Post by Thomas Uchida » Sun Oct 14, 2018 10:58 am

Here's a MATLAB version; Python should be analogous.

Code: Select all

% OpenSim 3.3
import org.opensim.modeling.*;
model = Model('gait2354_simbody.osim');
model.setUseVisualizer(true);
state = model.initSystem();
model.updCoordinateSet().get('pelvis_ty').setValue(state, 0.95);
model.getVisualizer().show(state);
The following pages in the Confluence documentation may be useful:
- "Common Scripting Commands", https://simtk-confluence.stanford.edu/d ... g+Commands
- "Scripting in Python", https://simtk-confluence.stanford.edu/d ... +in+Python

User avatar
Zuren Arrh
Posts: 6
Joined: Tue Sep 18, 2018 6:07 am

Re: Problem with the position of the model

Post by Zuren Arrh » Tue Oct 16, 2018 3:38 am

tkuchida wrote:
Sun Oct 14, 2018 10:58 am
Here's a MATLAB version; Python should be analogous.

Code: Select all

% OpenSim 3.3
import org.opensim.modeling.*;
model = Model('gait2354_simbody.osim');
model.setUseVisualizer(true);
state = model.initSystem();
model.updCoordinateSet().get('pelvis_ty').setValue(state, 0.95);
model.getVisualizer().show(state);
The following pages in the Confluence documentation may be useful:
- "Common Scripting Commands", https://simtk-confluence.stanford.edu/d ... g+Commands
- "Scripting in Python", https://simtk-confluence.stanford.edu/d ... +in+Python
Thanks for your advice, the documentation you offered helps a lot!

POST REPLY