Hi there,
I am trying to tracking center of mass position for a model. However, I am unable to find what goes inside the function model.calcCenterMassPosition() as argument. All I have found on Doxygen is that it accepts const SimTK::State & s. I have Moco solved state trajectories of size 102x2. I have tried passing in one of the rows to it but to no avail. Kindly guide.
Umer
What is State in Model.calcCenterMassPosition
- Umer Huzaifa
- Posts: 10
- Joined: Wed Mar 04, 2020 11:41 pm
- Aravind Sundararajan
- Posts: 17
- Joined: Mon Aug 29, 2016 2:59 pm
Re: What is State in Model.calcCenterMassPosition
if you are trying to do some post-hoc analysis with your moco solution in matlab or python, I think you can turn this into a StatesTrajectory and use get(index) to grab states from it
and you can get iterate over states in the states trajectory and realizing the model to positions or whatever else you need. There might be an easier way though
Code: Select all
states_storage = org.opensim.modeling.Storage(storagePath);
states_trajectory = org.opensim.modeling.StatesTrajectory().createFromStatesStorage(model, states_storage,true,true,false);
- Nicholas Bianco
- Posts: 1041
- Joined: Thu Oct 04, 2012 8:09 pm
Re: What is State in Model.calcCenterMassPosition
Thanks for the response Aravind. I can provide a little more context if it's useful.
OpenSim has two main concepts regarding modeling and simulation: the Model and the State. The Model is the mathematical description of your system, but alone it cannot provide any information about your model at a given time point in a simulation. For that you need a State (i.e., SimTK::State), which is essentially a vector of numerical values that define the kinematics and kinetics of your system at a given time point.
When you solve a problem in Moco, you get back a trajectory of values, which is essentially a bunch of concatenated States. You can easily return a StatesTrajectory object from a MocoTrajectory:
OpenSim has two main concepts regarding modeling and simulation: the Model and the State. The Model is the mathematical description of your system, but alone it cannot provide any information about your model at a given time point in a simulation. For that you need a State (i.e., SimTK::State), which is essentially a vector of numerical values that define the kinematics and kinetics of your system at a given time point.
When you solve a problem in Moco, you get back a trajectory of values, which is essentially a bunch of concatenated States. You can easily return a StatesTrajectory object from a MocoTrajectory:
Code: Select all
study = MocoStudy();
problem = study.updProblem();
% Your problem and solver settings here.
solution = study.solve();
statesTrajectory = solution.exportToStatesTrajectory(problem);