OneLegStandingModel

Hello,
my name is Sven and I am new at AnyBody. To measure the forces in the hip joint, I try to make an “OneLegStandingModel” based on the “StandingModel”. But if I let the “InverseDynamics” run I get this Error:
ERROR(OBJ.MCH.MUS4) : U:/E…n/A…y/E…d/A…n/E…s/S…l/StandingModel.Main.any : Study.InverseDynamics : Muscle recruitment solver : maximum number of setbacks occured

Can anyone tell me what this ERROR means and how to eliminate it?
I am using AMS 5.1 and AMMR 1.4.1.
Best regards
Sven

Hi Sven,

Welcome to AnyBody world!

When I looked into your model, your model is ‘kinematcally’ right.
But not ‘kinetically’.

Attached please find the modified version of your model.

I did some change on your model, especially in ‘RightLegTDDrivers.any’ file.

  AnyKinEqSimpleDriver RToeLateralContactNode ={
    AnyKinLinear ToeLateralContactNodePos = {
      AnyFixedRefFrame &Ground = Main.Model.EnvironmentModel.GlobalRef;
      AnyRefNode &Ball = Main.Model.HumanModel.Right.Leg.Seg.Foot.ToeLateralContactNode;
    };
    MeasureOrganizer = {1};  // Only the y coordinate
    //DriverPos = {0.1};
    DriverPos = {0.0};

    DriverVel = {0};
    Reaction.Type = {Off};   // Provide ground reaction forces
    
  };
  
  AnyKinEqSimpleDriver RToeMedialContactNode ={
    AnyKinLinear ToeMedialContactNodePos = {
      AnyFixedRefFrame &Ground = Main.Model.EnvironmentModel.GlobalRef;
      AnyRefNode &Ball = Main.Model.HumanModel.Right.Leg.Seg.Foot.ToeMedialContactNode;
    };
    MeasureOrganizer = {1};  // Only the y coordinate
    //DriverPos = {0.1};
    DriverPos = {0.0};
    
    DriverVel = {0};
    Reaction.Type = {Off};   // Provide ground reaction forces
  };
  
  AnyKinEqSimpleDriver RHeelContactNode ={
    AnyKinLinear HeelContactNodePos = {
      AnyFixedRefFrame &Ground = Main.Model.EnvironmentModel.GlobalRef;
      AnyRefNode &Ball = Main.HumanModel.BodyModel.Right.Leg.Seg.Foot.HeelContactNodeLow;
    };
    MeasureOrganizer = {1};  // Only the y coordinate
    //DriverPos = {0.1};
    DriverPos = {0.0};
    
    DriverVel = {0};
    Reaction.Type = {Off};   // Provide ground reaction forces
  };

These three constraints determine the kinematic contact between the right foot and ground.

But in your original code, the ‘DriverPos’ values were all 0.1.

So actually, the right foot does not contact to the ground.
So I’ve changed these values as zero.

Let’s see the following code in the same file.

   AnyFolder ConditionalContact={
    AnyVar StaticFrictionCoefficient=0.9;
    AnyVar Strength=2000;
    
    
    AnyFolder ToeMedialContactNodeRight = {
      AnyRefNode &TargetObject = ..LegR.Seg.Foot.ToeMedialContactNode;
      AnyRefFrame &BaseObject=Main.Model.EnvironmentModel.GlobalRef; //Object which delivers the forces  
      AnyRefFrame &StrengthObject=TargetObject; //Node used for strength measurement, occasionally this is different from the target object
      
      AnyFolder &DrawRef=Main.DrawSettings; //reference to the folder which contains drawsettings
      //low limit for the strength measure function, if the distance measured along Direction[0] is below this val. the strength will be zero (negative)
      AnyVar UserDefinedLimitLow=-0.05; 
      //high limit for the strength measure function, if the distance measured along Direction[0] is above this val. the strength will be zero
      AnyVar UserDefinedLimitHigh=0.05; 
      
      //high limit for the strength measure function, if the radius measured along the plane with Direction[0] as normal is above this val. the strength will be zero
      AnyVar UserDefinedRadiusLimit=0.4; 
      
      AnyVar Strength =.Strength;  //strength of muscles
      AnyVar StaticFrictionCoefficient=.StaticFrictionCoefficient; //Friction coefficient
      AnyVar ScaleFactor =1; //scale factor for draw vectors it can be set differently than by the drawsettings
      
      
      AnyIntArray Direction={1,0,2}; //first element gives normal direction
      #include  "..\..\..\Body\AAUHuman\ToolBox\FrictionContactMuscles\ContactSurfaceLinPush.any"
    };
    
    AnyFolder ToeLateralContactNodeRight = {
      AnyRefNode &TargetObject  = ..LegR.Seg.Foot.ToeLateralContactNode;
      AnyRefFrame &BaseObject=Main.Model.EnvironmentModel.GlobalRef; //Object which delivers the forces  
      AnyRefFrame &StrengthObject=TargetObject; //Node used for strength measurement, occasionally this is different from the target object
      
      AnyFolder &DrawRef=Main.DrawSettings; //reference to the folder which contains drawsettings
      //low limit for the strength measure function, if the distance measured along Direction[0] is below this val. the strength will be zero (negative)
      AnyVar UserDefinedLimitLow=-0.05; 
      //high limit for the strength measure function, if the distance measured along Direction[0] is above this val. the strength will be zero
      AnyVar UserDefinedLimitHigh=0.05; 
      
      //high limit for the strength measure function, if the radius measured along the plane with Direction[0] as normal is above this val. the strength will be zero
      AnyVar UserDefinedRadiusLimit=0.4; 
      
      AnyVar Strength =.Strength;  //strength of muscles
      AnyVar StaticFrictionCoefficient=.StaticFrictionCoefficient; //Friction coefficient
      AnyVar ScaleFactor =1; //scale factor for draw vectors it can be set differently than by the drawsettings
      
      
      AnyIntArray Direction={1,0,2}; //first element gives normal direction
      #include  "..\..\..\Body\AAUHuman\ToolBox\FrictionContactMuscles\ContactSurfaceLinPush.any"
      
    };
    
    
    
    AnyFolder HeelSupportRight = {
      
      AnyRefNode &TargetObject = ..LegR.Seg.Foot.HeelJoint;
      AnyRefFrame &BaseObject=Main.Model.EnvironmentModel.GlobalRef; //Object which delivers the forces  
      AnyRefFrame &StrengthObject=TargetObject; //Node used for strength measurement, occasionally this is different from the target object
      
      AnyFolder &DrawRef=Main.DrawSettings; //reference to the folder which contains drawsettings
      //low limit for the strength measure function, if the distance measured along Direction[0] is below this val. the strength will be zero (negative)
      AnyVar UserDefinedLimitLow=-0.05; 
      //high limit for the strength measure function, if the distance measured along Direction[0] is above this val. the strength will be zero
      AnyVar UserDefinedLimitHigh=0.05; 
      
      //high limit for the strength measure function, if the radius measured along the plane with Direction[0] as normal is above this val. the strength will be zero
      AnyVar UserDefinedRadiusLimit=0.4; 
      
      AnyVar Strength =.Strength;  //strength of muscles
      AnyVar StaticFrictionCoefficient=.StaticFrictionCoefficient; //Friction coefficient
      AnyVar ScaleFactor =1; //scale factor for draw vectors it can be set differently than by the drawsettings
      
      
      AnyIntArray Direction={1,0,2}; //first element gives normal direction
      #include  "..\..\..\Body\AAUHuman\ToolBox\FrictionContactMuscles\ContactSurfaceLinPush.any"
      
      
    };
  };

The above code defines so-called ‘conditional contact elements’ using AnyGeneralMuscle objects.

These objects will create some reaction forces if the distance of those nodes are close to the GlobalRef node within some value.

So this is the reason why I had to move the position of the human model close to the ground.

I hope this may help to you.

Best regards,
Moonki

Thank you for the quick help!

Best regards
Sven

Hello!
Now I want to comment out a lot of muscles. This works but if I comment out the last muscle (BicepsFemorisCaputLongum1) and run the InverseDynamics appears this error message:
ERROR(OBJ.MCH.MUS4) : U:/E…n/A…y/B…t/E…n/A…n/E…s/O…l/StandingModel.Main.any : Study.InverseDynamics : Muscle recruitment solver : solver aborted due to singular KKT matrix

Does anyone know how to avoid this error?
Best regards
Sven

Hi Sven,

When I downloaded and run your model, there is no problem.

Did you change anything in the ‘Body’ folder in the repository?

Then you should upload all the modified ‘Body’ folder with your model folder.
If not then we can’t find see what the problem is.

Also it will be easier for you to let us know which files you modified.

Best regards,
Moonki

Hi Moonki!
I have two folders (“LegTD” and “OneLegStandingModel1”) uploaded in “model1”- folder. In “LegTD” are the files (“Mus.any” and “LegMuscleNames.any”) I modified in “Body”- folder.

Best regards
Sven

Hi,

It seems that you tried to delete muscle in the leg, right?

But the muscle you mentioned(BicepsFemorisCaputLongum1) is located in the arm.

And there is no muscle in the arm.

So, I can’t figure out what you want to delete more…

Best regards,
Moonki

Hi!

I think the “BicepsFemorisCaputLongum1” is on the backside of the thigh. It is the last muscle I want to comment out but it doesn´t work.

Best regards
Sven

Hi Sven,

First, sorry for my misunderstanding muscle position.

Yes, you are right. When I commented out that muscle, then the analysis will fail.

Can I ask of you what the purpose of your research is?

This fail means that AnyBody can’t find a solution of muscle forces that will generate this motion.

So it means that this muscle is required to generate this motion.

Why do you want to delete as many muscles as you can?

Best regards,
Moonki

Hi Moonki!
I would like to analyse the influence of the hip muscles on the resulting hip force. That´s why I commented out almost all muscles and then I will comment in the muscle I´m interested in (Glutaeus medius, Glutaeus minimus, Piriformis, Tensor fasciae latae, Rectus femoris).

Best regards
Sven

Hi Sven,

For that purpose, you don’t need to delete the muscles. :slight_smile:
Instead, you can use ‘AnyForceMomentMeasure2’ class.

When you use this class, you can only put some muscles that you are interested in.

You can refer to this file:
“\Body\AAUHuman\LegTD\LegMoments.any”

At there, you can see this piece of code:

AnyForceMomentMeasure2 HipNetMomentMuscle = {
  AnyRefNode &ref = ..HipNodeRef.RotNode;
  
  AnySeg &seg1=..Seg.Shank;      
  AnySeg &seg2=..Seg.Foot;      
  AnySeg &seg3=..Seg.Thigh;  
  AnySeg &seg4=..Seg.Talus;
  AnySeg &seg5=..Seg.Patella;
  #include  "LegMuscleNames.any"
  
   AnyVec3 Mlocal=M*ref.Axes;
   AnyVar MHipAbduction=Mlocal[0];
   AnyVar MHipFlexion=Mlocal[2];
   AnyVar MHipExternalRotation=Mlocal[1];   
};

In this code, this measure consider all muscles by including “LegMuscleNames.any” file.

So for you, you can just put some muscle names which you are interested in.

If you want to see forces, then you should refer to ‘F’ output of this measure.

Best regards,
Moonki

Hi!
I have got a new problem with my model. I want to bent the hip ±10° (see sketch). So I thought I change the HipAbduction (Mannequin/Right/Leg) ±10. But when I read out the “r” coordinates of RightHipTD and LeftHipTD and calculate the angle to the horizontal it is only 7.04°. (angle = tan^-1 (deltaRy/deltaRz))

Can anyone tell me how the HipAbduction is defined and where the “HipAbduction rotation center” is? Or can someone tell me how to bent the pelvic like it is in the sketch?

  Best regards 

  Sven

Hi Sven,

  1. All joint angle definitions in ‘Mannequin.any’ are located in the following folder:
    Main.HumanModel.BodyModel.Interface

  2. For hip abduction, you can refer to this definition:
    Main.HumanModel.BodyModel.Interface.Right.HipAbduction

And the definition of hip abduction is as follows( “…\AMMRV1.4\Body\AAUHuman\LegTD\Interface.any”) :

AnyKinMeasureOrg HipFlexion = {
  //create new rotated node 
  AnyFolder &HipNodeRef=..HipNodeRef;
  HipNodeRef={
    AnyRefNode RotNode={
      ARel= {{....Sign*-1,0,0},{0,....Sign*-1,0},{0,0,1}};
    };
  };
  AnyFolder &ThighNodeRef = ..Seg.Thigh.HipJoint;
  ThighNodeRef ={
    AnyRefNode RotNode={
      ARel={{....Sign*-1,0,0},{0,....Sign*-1,0},{0,0,1}};
    };
  };
  AnyKinRotational HipMeasure ={
    AnyRefNode &PelvisNode = ...HipNodeRef.RotNode;
    AnyRefNode &ThighNode = ...Seg.Thigh.HipJoint.RotNode;
    
    PelvisNode={//AnyDrawRefFrame drw={RGB={1,0,0};};
    };
    ThighNode={//AnyDrawRefFrame drw={RGB={0,1,0};};
    };

    Type=RotAxesAngles;
  };
  MeasureOrganizer={0};
};
[b]AnyKinMeasureOrg HipAbduction = {
  AnyKinRotational &HipJoint =.HipFlexion.HipMeasure; 
  MeasureOrganizer={2};
};[/b]
AnyKinMeasureOrg HipExternalRotation ={
  AnyKinRotational &HipJoint =.HipFlexion.HipMeasure; 
  MeasureOrganizer={1};
};

  1. So, if you want to see the geometrical aspect of this hip flexion inside AnyBody,
    you can add ‘AnyDrawRefFrame’ to related AnyRefNodes.
    Here is a way to avoid modifying AMMR models files. Instead, you can do as follows:
AnyFolder HumanRefNodes = 
{
  AnyRefNode& Hip_RotNode =  
  Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.PelvisSeg.HipJointRightTD.RotNode;
  AnyRefNode& Thigh_RotNode =
  Main.HumanModel.BodyModel.Right.Leg.Seg.Thigh.HipJoint.RotNode;
  
  Hip_RotNode = 
  {
      AnyDrawRefFrame drw_frame = 
      {
         RGB = {1, 0, 0};
         ScaleXYZ = 0.1*{1, 1, 1};
      };
  };
  Thigh_RotNode = 
  {
      AnyDrawRefFrame drw_frame = 
      {
         RGB = {0, 1, 0};
         ScaleXYZ = 0.1*{1, 1, 1};
      };    
  };
};

Attached please find a zip file which includes a simple model based on FreePosture example.

I hope this may help you.

Best regards,
Moonki

Hi!
Thank you for the answer. In this model I can visualize the rotation. But how can I measure or calculate the angle? I want to be sure that the angle between femur and pelvic changes exactly 10° (see sketch two posts ago) if I change the abduction value by 10.

Hi,

I added some code to calculate angles as you want:

AnyFolder HumanRefNodes = 
{
  AnyRefNode& Hip_RotNode =  
  Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.PelvisSeg.HipJointRightTD.RotNode;
  AnyRefNode& Thigh_RotNode =
  Main.HumanModel.BodyModel.Right.Leg.Seg.Thigh.HipJoint.RotNode;
  
  Hip_RotNode = 
  {
      AnyDrawRefFrame drw_frame = 
      {
         RGB = {1, 0, 0};
         ScaleXYZ = 0.1*{1, 1, 1};
      };
[b]      AnyRefNode Z_OFFSET_node = 
      {
          sRel = 0.1*{0, 0, 1};
          AnyDrawNode drw_node = 
          {
              RGB = {1, 0, 0};
              ScaleXYZ = 0.005*{1, 1, 1};
          };
      };[/b]
  };
  Thigh_RotNode = 
  {
      AnyDrawRefFrame drw_frame = 
      {
         RGB = {0, 1, 0};
         ScaleXYZ = 0.1*{1, 1, 1};
      }; 
[b]      AnyRefNode Z_OFFSET_node = 
      {
          sRel = 0.1*{0, 0, 1};
          AnyDrawNode drw_node = 
          {
              RGB = {0, 1, 0};
              ScaleXYZ = 0.005*{1, 1, 1};
          };
      };    [/b]  
  };
  
[b]  AnyVec3 vector_1 = ( Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.PelvisSeg.HipJointRightTD.RotNode.Z_OFFSET_node.r
                         - Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.PelvisSeg.HipJointRightTD.RotNode.r);
  AnyVec3 vector_2 = ( Main.HumanModel.BodyModel.Right.Leg.Seg.Thigh.HipJoint.RotNode.Z_OFFSET_node.r
                         - Main.HumanModel.BodyModel.Right.Leg.Seg.Thigh.HipJoint.RotNode.r);
  
  AnyVar vector_1_size = vnorm(vector_1);
  AnyVar vector_2_size = vnorm(vector_2);
  
  AnyVar vector_1_2_inner_product = vector_1*vector_2' ;
  
  AnyVar vector_1_2_angle_cosine = vector_1_2_inner_product / (vector_1_size * vector_2_size);
  
  AnyVar vector_1_2_angle_in_degree = 180/pi*acos(vector_1_2_angle_cosine);[/b]
                         
};

Attached please find the modified version of previous model.

I hope this may help you.

Best regards,
Moonki

Hi!
Thank you for this code, it helped me a lot!

Best regards

Sven