Seg Driven Using EulerParam

I posted a message in the thread in the link below asking about driving a segment using EulerParam rather than RotAxesAngles.

Attached is a basic demo (AnyBody v5.2.0 AMMRV1.4.1). I used the Pendulum demo to try to create a very simple scenario…
[li]Create one segment with two nodes on segment
[/li][li]Constrain origin node on segment at Global origin using Spherical Joint
[/li][li]Measure using EulerParam between a node on the segment and the Global origin
[/li][li]Drive measure using data read in from .txt file

From looking at a few other posts I’m not even sure if AnyBody will allow an EulerParam type to be driven. Which seems unfortunate.
Any help as always, greatly appreciated.


Hi Chris,

Attached please find my test model based on your model.

When you load this new model, you can find that there are two #if statements like this:

#define EulerParamData_Generation 0
#define EulerParamData_Drive 1

First, if you set like this:

#define EulerParamData_Generation 1
#define EulerParamData_Drive 0

Then if you run Kinematics operation then AnyBody will create a text file which contains euler parameters.

Next, if you set like this:

#define EulerParamData_Generation 0
#define EulerParamData_Drive 1

Then your Pendulum segment will be driven by euler parameters.

One thing that you should know that is because there are 4 constraints when you are using euler parameters, then this model becomes over-constrained system.
To solve this situation, the solver type for AnyBodyStudy class should be ‘KinSolOverDeterminate’ like this:

InitialConditions.SolverType = KinSolOverDeterminate;
Kinematics.SolverType = KinSolOverDeterminate;

So, what I would suggest you is to compare this new-generated euler parameter text file with your own euler parameter text file.

I hope this may help you.

Best regards,

Many thanks Moonki, I’ll have a play.

Many thanks for your help to date - I certainly wouldn’t have progressed without it!

I think one of the main issues was not having the lines…

InitialConditions.SolverType = KinSolOverDeterminate;
Kinematics.SolverType = KinSolOverDeterminate;

A new, but similar issue. I’ve been trying to progress this to a skeletal model rather than just a segment. I have a node on the skeleton that I’m trying to drive with quaternions that I have generated from elsewhere. (Actually there are three examples that are just exported from a Matlab script, the Matlab figures are also in the folder should you want to look at the data etc.)

Anyway, so trying to drive the pelvis from this node. All OK, except when the x-axis on the sensor is nearly aligned with the global -x axis.

I’ve attached three files that should hopefully demonstrate the case.
If you toggle the three #define at the top between using My_Quat4, My_Quat5 and My_Quat6, the first works but not quite as it should, My_Quat5 doesn’t work at all and My_Quat6 only work until the local x aligns with the global negative x

I think there is often an issue with the initial conditions, however, I think there is probably more of an issue when, in this example, the local x axis gets close the negative x global axis, and somehow it gets confused as to which quadrant it should be in. But driving it with quaternions, or the EulerParms, this should not be the problem it is.

So this means that it’s not possible to ‘yaw’ the model over 180.

I don’t know if you have seen this before and or what your suggestions would be to resolve it as it’s potentially quite prohibitive.

Many thanks,

Hi Chris,

  1. First, I would recommend you to let us know which version of AnyBody and AMMR you are using.
    If you can access to the latest version of AnyBody,
    then I would recommend you to use AMMR V1.5. And the FreePostureMove example in the AMMR V1.5 is more flexible to use.

  2. The meaning of the following two settings in AnyBodyStudy class:

InitialConditions.SolverType = KinSolOverDeterminate;
Kinematics.SolverType = KinSolOverDeterminate;

Basically, three constraints are enough to drive a segment’s rotation kinematics.
But as we know, because euler parameter(quaternion) contains four information,
so if we use euler parameter driver for a segment rotation then it will give one more constraints on the system.
To solve this kinematically over-constrained situation we have to change the solver type of AnyBodyStudy object in your model.

  1. When I load your model, I’ve found that you might remove all necessary drivers for human model except your euler parameter drivers.
    When I loaded your model I could see the following message:
Model Warning: Study 'Main.Study' contains too few kinematic constraints to be kinematically determinate.

This message means that you might not define enough numbers of drivers which are necessary to run this model in terms of kinematics.
So, to make your model run in a easy way, I would recommend you to exclude both of arms and one leg.
Then you only need to consider the DOFs of pelvis(6 DOF), pelvis-thorax rotations(3 DOF), neck-joint(1 DOF), hip-joints(3 DOF), knee-joint(1 DOF), ankle-joint(2 DOF).
All human-related joint angles can be identified in the ‘Mannequin.any’ file. Then you can use your euler-parameter drivers to replace one of above.

So my conclusion is,
try to remove both of arms and one leg, then check whether you define all necessary joint drivers for human joint angles.

I hope this may help you.

Best regards,

Hi Moonki,
Many thanks for your reply as ever. I had already made model without arms and legs, but it was such a mess I made a new one to save the embarrassment of uploading the messy one, and in doing this I forgot to copy the “BodyModel_NoMuscles.any” file with it!

I’m using AnyBody v5.2.0 AMMR 1.4.1. Maybe I should look to use the AMMR1.5,but I’m not sure it will solve the problems in this case.

The problem is when the “yaw” angle of the pelvis rotation approaches 180 degrees, the system fails. If you run the file I uploaded before with the case “#define Use_Quat6 1” hopefully this should illustrate the problem.

Thanks as always,

Hi Chris,

Sorry to late answer.

As I told already, even if I use your previous uploaded model with the setting of ‘Use_Quat6’, your model still does not contain enough number of constraints.

The total number of rigid-body DOF(degrees of freedom) is 234,
but the total number of constraints is 203. So 31 is missing.

So first I would like to suggest you to upload your new model which contains more drivers or which removes some unnecessary segments like arms, because I can’t edit your model by myself.

Best regards,

Hi Moonki,

Thanks for your reply, and congratulations on your recent webcast!
I thought I had uploaded a model with no muscles and only the trunk segments selected. However, I now realise that Body_Model file is in a folder further up the tree and hence not in the file I uploaded. Is it possible for you to copy the attached file into the folder “…\Body\AAUHuman\BodyModels\FullBodyModel”. This essentially sets the body to have no muscles and only trunk segments.

I have loaded the .main on my computer and it seems to work, so will hopefully on yours too - please let me know if this is not the case.

As i mentioned before, the main issue I’m having is when the pelvis segment yaw exceeds + or - 180degrees.
Look forward to hearing from you.

Hi Chris.

I’m still investigating your models. But to make it correct, you should provide us more information.

Let’s assume that your final model will have only 1 leg and no arms.

Then this is the list of human joint angles that you should drive:

PelvisPosX, PelvisPosY, PelvisPoSZ, PelvisRotX, PelvisRotY, PelvisRotz
PelvisThoroaxExtension, PelvisThoraxLateralBending, PelvisThoraxRotation,

AnklePlantarFlexion, SubTalarEversion,
HipFlexion, HipAbduction, HipExternalRotation

And your quaternion driver will take care of 3 rotation values.

Then my question is, which joint angles you want to fix,
and which rotation of segment you want to drive?

Do you want to drive to rotation of pelvis with respect to global?
Then how could you get the global location of pelvis?

Or, do you want to driver the relative rotation between pelvis and thigh?

All of unknown joint angles should be fixed.

I hope that you can clarify which joint angles should be fixed, and which rotation you want to drive.

Best regards,

Hi Moonki,
For now at least to try to keep things simple, I’m only trying to model the trunk with no limbs.
The only parameters I want to drive, are effectively PelvisRotX, PelvisRotY, PelvisRotz using quaternion method. And these angles are relative to the global origin.

For now, all other parameters should remain constant…
PelvisPosX, PelvisPosY, PelvisPoSZ, PelvisThoroaxExtension, PelvisThoraxLateralBending, PelvisThoraxRotation, NectJoin …all fixed.

I guess the problem is less biomechanical and more to do with the program fundamentals, and the same still applies to just a single segment whose translation is fixed and rotations are driven. When the quaternion ‘yaw’ angle approach the equivalent to ±180 the program fails. Is this something you are aware of and are you able to resolve / work around it?

Many thanks,

Hi Chris,

Now I could reproduce the same problem that you’ve experienced.

I think that it will take some time to investigate this problem of your model using euler parameter because not many users are using this option for their research activities.
As far as I remember, you are almost the first guy who use this feature. :slight_smile:
So even though we will look at your model in detail, I can’t promise when we can solve the problem from this euler parameter driver.

By the way, I would recommend you to use the AnyKinRotational class with ‘Type=RotVector’.
It will use the instant axis of rotation and the rotation angle.
Attached please find my example file which shows how to use it.
I guess that you may be able to transform your quaternion values into this axis rotation and angles.

I hope this may be helpful to you.

Sorry for not helping you as you want.

Best regards,