problem with setting up the initial condition

Dear AnyBody Team,

We are working on project dealing with study of whole body motion performed in supine posture. We are using marker based system to collect the kinematic data. We have the marker data in the .C3D format. To run the AnyBody model we are trying to match the initial position of the model with the marker data. To do so following rotation are applied to pelvis:

AnyVar PelvisRotZ = 270;
AnyVar PelvisRotY = -90;
AnyVar PelvisRotX = -90;

With this rotations, skull, upper arms and legs segments take the right orientation, however, orientations of pelvis and trunk segments get messed up big time (please see attached). We also tried applying different rotations however with all the attempts, we are facing the same problem.

Your advise on rectifying this problem will be greatly appreciated.

Thank you.


It is hard to say what exactly went wrong without seeing the model. Could you please send it to us - we will debug it? (

Best regards,


I had a look at the model. The main problem is that the rotations you applied to the pelvis creates a gimbal lock, that means the last axis of rotation X becomes exactly parallel to the initial orientation of the first axis of rotation Z. To avoid this you can simply add a few degrees to the values like this:

AnyVar PelvisRotZ = 270;
AnyVar PelvisRotY = -92;
AnyVar PelvisRotX = -91;

I think the fact that the pelvis and trunk were strangely rotated is a graphical bug. Even with the gimbal lock the trunk should have appeared correctly rotated at load time. You can see that with just the 2 additional degrees it suddenly comes back in place. I also adjusted the pelvis pos:

AnyVar PelvisPosX = 1.95;//0.5* (RPSI(Main.ModelSetup.tStart)[0]+LPSI(Main.ModelSetup.tStart)[0]);
AnyVar PelvisPosY =  0.6;//0.5* (RPSI(Main.ModelSetup.tStart)[1]+LPSI(Main.ModelSetup.tStart)[1]);
AnyVar PelvisPosZ = 0.6;//0.5* (RPSI(Main.ModelSetup.tStart)[2]+LPSI(Main.ModelSetup.tStart)[2]);

And the elbow flexion to 105 degrees on both arms.

With this the model runs.

Best regards, Sylvain.

Dear Sylvain
I see that you are talking about gimbal lock in AnyBody models. How do you find a gimbal in your model?

I faced the problem of rotations of 90 deg in AnyBody too. The model can not converge when you set rotation of trunk to 90 degrees or abduction of 90 deg to Upper arm in an upright posture. Do you mean that these problems lie in gimbal lock? How you can explain this?

Thank you in advance and regards,


it is possible that this is based on gimbal lock, but there are also several other reasons that it does not converge. What model etc. are you using?

Dear Amir,
If it is due to gimbal lock, as you said, what are the three gimbals? Gimbal lock occurs when axes of two of three gimbals are driven into a parallel configuration. How do you attribute a musculoskeletal model to a gimbal?
I’m using StandingModel.
Many Thanks

Dear Mohammed,

I looked into your problem and the reason is not the Gimbal Lock. The warning you get before the kinematic error appears when the joint angles are close to gimbal lock and not defined perfectly. This usually will not lead to kinematic error.

In the case of the standing model, the problem is in the foot drivers. The drivers for the feet constrain the foot in the height to the y axis. That’s pk, but additionally, the RAnkleX driver drives the foot to stand on the x axis. If you want to turn the subject around you will have a conflict there. You can easily fix this:

Solution one (easy):
if you are only interested in a 90 degree turn, switch the RAnkleX to use the z axis instead.
from MeasureOrganizer = {0}; // Only the x coordinate
to MeasureOrganizer = {2}; // Only the x coordinate

Solution two (more elegant):
you can introduce another reference frame, and instead of using all rotations in regard to the Main.Model.EnvironmentModel.GlobalRef, use the new reference frame. You can then rotate that new reference frame.

I hope that helps