Hello,
I would like to extract the position in ground of a body in Opensim 3.3 with Matlab, how can I do? With the 4.0 version I can use getPositionInGround() but I didn't find this function in 3.3.
Thank you!
Bye
Get body position in ground using Opensim 3.3
- Marco Marchitto
- Posts: 5
- Joined: Mon Oct 07, 2019 6:03 am
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: Get body position in ground using Opensim 3.3
Hello Marco,
In the past I have done the following (just change the body of interest):
% Import the OpenSim modeling classes
import org.opensim.modeling.*
% Read in the osim model
osimModel = Model([pathModel,'yourModelFile.osim']);
% Initialize the model
osimState = osimModel.initSystem();
% Get Simbody Engine
simbodyEngine = osimModel.getSimbodyEngine();
% Get body of interest - e.g. humerus
humerus = osimModel.getBodySet().get('r_humerus');
% Define blank Vec3 - humerus mass center
humerus_mc = Vec3(0);
% Populate humerus mc with mass center position in local body frame
humerus.getMassCenter(humerus_mc);
% Define blank Vec3
humerus_MCpos_G = Vec3(0);
% Populate humerus_MCpos_G with humerus mass center position in global/ground frame
simbodyEngine.getPosition(osimState,humerus,humerus_mc,humerus_MCpos_G);
Cheers,
Nicos
In the past I have done the following (just change the body of interest):
% Import the OpenSim modeling classes
import org.opensim.modeling.*
% Read in the osim model
osimModel = Model([pathModel,'yourModelFile.osim']);
% Initialize the model
osimState = osimModel.initSystem();
% Get Simbody Engine
simbodyEngine = osimModel.getSimbodyEngine();
% Get body of interest - e.g. humerus
humerus = osimModel.getBodySet().get('r_humerus');
% Define blank Vec3 - humerus mass center
humerus_mc = Vec3(0);
% Populate humerus mc with mass center position in local body frame
humerus.getMassCenter(humerus_mc);
% Define blank Vec3
humerus_MCpos_G = Vec3(0);
% Populate humerus_MCpos_G with humerus mass center position in global/ground frame
simbodyEngine.getPosition(osimState,humerus,humerus_mc,humerus_MCpos_G);
Cheers,
Nicos
- Marco Marchitto
- Posts: 5
- Joined: Mon Oct 07, 2019 6:03 am
Re: Get body position in ground using Opensim 3.3
Thank you! It works!
Best,
Marco
Best,
Marco