opensim-core icon indicating copy to clipboard operation
opensim-core copied to clipboard

`Model::calcMassCenterPosition()` returns nan's when a coordinate in the model is locked

Open carmichaelong opened this issue 2 years ago • 0 comments

Related model and states file are attached below. The following code:

Model m("planarjoint_lockedcoord0.osim");
State s = m.initSystem();
auto sto = Storage("fwd.mot");
auto traj = StatesTrajectory::createFromStatesStorage(m, sto);
auto comPos = m.calcMassCenterPosition(traj[0]);

std::cout << comPos << std::endl;

outputs:

[info] Loaded model model from file planarjoint_lockedcoord0.osim
[info] Storage: read data file = fwd.mot (nr=4 nc=7)
[warning] Coordinate.setValue:  coordinate joint_coord_0 is locked. Unable to change its value.
~[-nan(ind),-nan(ind),-nan(ind)]

The issue seems to stem from this line as X_GB returns a Transform object that is filled with nan's. I have not dug into the Simbody code to debug this further.

calcmasscenterpositionfiles.zip

carmichaelong avatar Jan 12 '23 00:01 carmichaelong