Center of Mass velocity

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Sophie Fleischmann
Posts: 3
Joined: Tue Feb 15, 2022 6:58 am

Center of Mass velocity

Post by Sophie Fleischmann » Fri Jan 20, 2023 1:11 pm

Hello,

i have a .trc file that stores the results of an Inverse Kinematics Analysis.
In Matlab, I load this file as a StatesTrajectory. Then, for every state, I assemble my model to match this state. I then want to extract the position and velocity of the assebled state. This works well for the center of mass position, but not for the center of mass velocity.
I do it like this:
state = model.initSystem()
current_state = traj.get(i); (where traj is the state trajectory)
model.assemble(current_state);
model.realizePosition(current_state);
com = model.calcMassCenterPosition(current_state)
model.realizeVelocity(current_state);
current_state.setSystemTopologyStageVersion(7);
comdot = model.calcMassCenterVelocity(current_state);

Nevertheless, for comdot I only get NaNs.

What do I do wrong?
I really appreciate your help!!

Thanks and best regards,
Sophie

Tags:

User avatar
Nicholas Bianco
Posts: 1050
Joined: Thu Oct 04, 2012 8:09 pm

Re: Center of Mass velocity

Post by Nicholas Bianco » Mon Jan 23, 2023 11:57 am

Hi Sophie,

Do you have any locked coordinates in your model? There's a known bug where COM values get returned as NaN when locked coordinates exist in the model.

You also might consider using 'SimulationUtilities::analyze<T>()', which might work better than manually assembling the model for your trajectory.

Matlab example:

Code: Select all

model.initSystem();
statesTable = traj.exportToTable(model);
% create an empty controls table (not needed for velocity-level info)
controlsTable = TimeSeriesTable(statesTable.getIndependentColumn());

outputPaths = StdVectorString();
outputPaths.add('/com_position');
outputPaths.add('/com_velocity');

com = opensimSimulation.analyzeVec3(model, statesTable, controlsTable, outputPaths);

POST REPLY