I'm working on a problem that requires me to set the state of a model for every row in a .sto state file. To that end I'm creating a StateTrajectory() object and then realizeAccelerations of the model;
Code: Select all
OpenSim::Model model(modelPath);
model.initSystem();
// load in state data and create 'StatesTrajectory' object which can be
// indexed to extract the correct state.
OpenSim::Storage storage(statesPath);
OpenSim::StatesTrajectory stateTrajectory =
OpenSim::StatesTrajectory::createFromStatesStorage(model,storage);
SimTK::State state;
for(int i=0; i<stateTrajectory.getSize(); i++){
state = stateTrajectory[i];
std::cout << "Q:" << std::endl;
state.getQ().dump();
std::cout << "---NEW ITERATION---" << std::endl;
}
int nRows = stateTrajectory.getSize();
std::cout << "Detected " << nRows << " states!" << std::endl;
for(int i=0; i<nRows; i++){
// The state of this iteration
state = stateTrajectory[i];
state.setTime(0.0);
// Set the model to the correct state
model.realizeAcceleration(state);
// OTHER CODE
The .sto state file is attached and does not seem to have any glaring problems. The model file is working.
Code: Select all
<Vector name=q size=39>
0.070386039999999997
-0.14616630999999999
0.059225710000000001
0.028397269999999999
1.0103145899999999
-0.22515103
0.21716084999999999
0.22423939000000001
-0.076024019999999998
-0.13515421999999999
-0.26453270000000001
-0.16344834999999999
-0.17244311000000001
0.17887336000000001
-0.071199520000000002
0.24554582999999999
0.24554582999999999
0.82330634000000003
0.82330634000000003
-0.18445331000000001
-0.18795624999999999
-0.24812118999999999
0.0060301900000000004
-0.17551496
-0.22645839000000001
0.00147401
-0.31521786000000002
0.51667315000000003
0.54912039000000001
NaN
NaN
0.53777010999999997
0.53066696000000002
NaN
NaN
NaN
NaN
NaN
NaN
All in all, does anyone know why these NaN values appear and what I need to do to solve it? Ignoring it is not an option because in the rest of the code I compute the CoM of the pelvis and feet for which the feet is now also a SimTK::Vec3 ~[nan,nan,nan]...
Thanks in advance!
(files too large, please see https://we.tl/t-SbXgDox5kE (weTransfer link))