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
Center of Mass velocity
- Sophie Fleischmann
- Posts: 3
- Joined: Tue Feb 15, 2022 6:58 am
- Nicholas Bianco
- Posts: 1050
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Center of Mass velocity
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:
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);