Page 1 of 1
Get body position in ground using Opensim 3.3
Posted: Wed Mar 18, 2020 8:06 am
by marcus_95
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
Re: Get body position in ground using Opensim 3.3
Posted: Thu Mar 19, 2020 3:46 am
by nicos1993
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
Re: Get body position in ground using Opensim 3.3
Posted: Fri Mar 20, 2020 11:35 am
by marcus_95
Thank you! It works!
Best,
Marco