Page 1 of 1

Free joint makes state.getNY() return extra state!

Posted: Wed Jul 12, 2017 8:26 pm
by haolee
I am currently modified the model in "DynamicWalkingStarter", I replace the joint between pelvis and floor with a free joint. (original is 2 slider joints, which limits the DOF)
The model I modified is this provided in the link below
https://drive.google.com/file/d/0B4Av76 ... sp=sharing
And it is clear it only has 12 coordinates
http://imgur.com/a/oOigN
p.s. I set some range to 0 since I want to lock them, but I also called the "setLocked(osimState, true);" in my matlab code.

However, when I use

Code: Select all

osimModel = Model('../Model/selfDefined/osimModel_pelvis_act.osim');
osimState = osimModel.initSystem();
numVar = osimState.getY().size();
It returns me 25, which is one extra of what I expected.

Nevertheless, when I use

Code: Select all

osimModel.getStateVariableNames().getitem(index)
It gave me 24 values, which seems correct.
In other words, the model I provided have 12 different state variables, but initSystem() create the state that has an extra one, why is that?

Re: Free joint makes state.getNY() return extra state!

Posted: Wed Jul 12, 2017 10:44 pm
by tkuchida
the model I provided have 12 different state variables, but initSystem() create the state that has an extra one, why is that?
The underlying Simbody System represents the FreeJoint's orientation using quaternions to avoid singularities (see https://simtk.org/api_docs/simbody/3.5/ ... ml#details), but the OpenSim interface works with the corresponding Euler angles (of which there are 3, not 4).

Re: Free joint makes state.getNY() return extra state!

Posted: Thu Jul 13, 2017 10:59 am
by haolee
Dear Tom
I am confused about the 4th component. I understand euler angle will face singularity such as Gimbal lock, and the common way to solve it is changing the order of euler sequence. So what is the 4th coordinate doing here? Does that mean an extra rotation? Like x->y->z->x (which solves Gimbal lock), but how could I match these data to the coordinate in my model? I only have 3 rotation (rx, ry, rz)

Re: Free joint makes state.getNY() return extra state!

Posted: Thu Jul 13, 2017 12:22 pm
by tkuchida
I am confused about the 4th component. I understand euler angle will face singularity such as Gimbal lock, and the common way to solve it is changing the order of euler sequence. So what is the 4th coordinate doing here? Does that mean an extra rotation? Like x->y->z->x (which solves Gimbal lock), but how could I match these data to the coordinate in my model? I only have 3 rotation (rx, ry, rz)
Simbody uses quaternions (https://en.wikipedia.org/wiki/Quaternion). There are methods in the SimbodyEngine class (https://simtk.org/api_docs/opensim/api_ ... ngine.html) for converting between representations of orientation (e.g., convertQuaternionsToDirectionCosines(), https://simtk.org/api_docs/opensim/api_ ... d6e437fe5a).