Get body position in ground using Opensim 3.3

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Marco Marchitto
Posts: 5
Joined: Mon Oct 07, 2019 6:03 am

Get body position in ground using Opensim 3.3

Post by Marco Marchitto » Wed Mar 18, 2020 8:06 am

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

Tags:

User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

Re: Get body position in ground using Opensim 3.3

Post by Nicos Haralabidis » Thu Mar 19, 2020 3:46 am

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

User avatar
Marco Marchitto
Posts: 5
Joined: Mon Oct 07, 2019 6:03 am

Re: Get body position in ground using Opensim 3.3

Post by Marco Marchitto » Fri Mar 20, 2020 11:35 am

Thank you! It works!

Best,

Marco

POST REPLY