AnyBody™ Tutorials
Lesson 6: Importing a Leg Model

Having defined the environment, the next step is to introduce a leg into the model. We are going to pick one from the repository. The body model is divided into individual body parts: legs, arms and trunk. In top of that each body part presents several versions: with or without muscles, simple or advanced muscle model, etc.

In earlier versions it was not easy to pick individual body parts to construct your model because the necessary interfaces had to be provided manually, so a collection of predefined body part collections ready to was located in a folder named BodyModels. However this simple solution has limitations. A new set of files has to be created for each possible body combination, so this predefined collection contains the fifteen most used body models. These are enough in the majority of the cases, but it is not possible to list all the variations that could be needed for more advanced modeling, this would lead to thousands of predefined bodies to choose from, which is certainly not convenient.

In the AnyBody Managed Model Repository it is now possible to easily create custom body models by simply picking out individual parts. All interface files which are needed will then be included automatically. The selection of the body parts is done using a file called BodyPartsSetup.any. This file is typically found in the applications (as it is application dependent) but a template is available in the Body section of the repository. For this tutorial you may use this model . Please locate the directory AMMRV1BlockTutorial\Body\AAUHuman\BodyModels\Include and the BodyPartsSetup file, copy and paste it inside the PedalModel directory. We should also include the file in the AnyScript code.

Main = {
  // The actual body model goes in this folder    
    AnyFolder HumanModel={
      // Select the body model:
      // ----------------------
      // This file contains a list of all body parts, select them to create
      // the body model wanted.
      #include  "BodyPartsSetup.any"
    };

AnyFolder MyPedal = {    
    #include "Environment.any"
  }; // MyPedal

  // The study: Operations to be performed on the model
  AnyBodyStudy MyStudy = {
    AnyFolder &Model = .MyPedal;
    Gravity = {0.0, -9.81, 0.0};
  };
};  // Main

Notice that we have created a new folder named 'HumanModel' and inserted the include statement into it. The separate folder for the human model allows us to add a few necessary additional items. As we said the file BodyPartsSetup.any allows you to pick the body parts. But it is actually just a list, and it will not assemble the body. We need a second file that will read the list in BodyPartsSetup and create the body model according to it. Please insert the following line.

AnyFolder HumanModel={
      // Select the body mode
      // ----------------------
      // This file contains a list of all body parts, select them to create
      // the body model wanted.
      #include  "BodyPartsSetup.any"

    // This file creates the body model from the selected list.
      #include  "..\..\..\Body\AAUHuman\BodyModels\GenericBodyModel\BodyModel.any"
    };

This last file is in general to be left untouched, it creates the body model automatically by using a number of IF functions. The BodyPartsSetup file is more interesting; double click on the line to open the file. You should see the following.

// Trunk: 1 included, 0 not included
// *********************************
#define TRUNK 1
// This is just the bones,
// Choose one of the following options to add muscles
#define TRUNK_SIMPLE_MUSCLES 0


// Trunk with neck: 1 included, 0 not included
// *********************************
#define TRUNK_NECK 0
// This is just the bones,
// Choose one of the following options to add muscles
#define TRUNK_NECK_SIMPLE_MUSCLES 0
#define TRUNK_NECK_SIMPLE_MUSCLES_ONLY_ON_NECK 0


// RightArm: 1 included, 0 not included
// ************************************
#define RIGHT_ARM 1
// This is just the bones,
// Choose one of the following options to add muscles
#define RIGHT_ARM_SIMPLE_MUSCLE 0
#define RIGHT_ARM_SIMPLE_MUSCLE_ONLY_ON_NECK 0
#define RIGHT_ARM_MUS_3E 0


// LeftArm: 1 included, 0 not included
// ***********************************
#define LEFT_ARM 1
// This is just the bones,
// Choose one of the following options to add muscles
#define LEFT_ARM_SIMPLE_MUSCLES 0
#define LEFT_ARM_SIMPLE_MUSCLES_ONLY_ON_NECK 0
#define LEFT_ARM_MUS_3E 0


// RightLeg: 1 included, 0 not included
// ************************************
#define RIGHT_LEG 1
// This is just the bones,
// Choose one of the following options to add muscles
#define RIGHT_LEG_SIMPLE_MUSCLES 0
#define RIGHT_LEG_MUS_3E 0


// LeftLeg: 1 included, 0 not included
// ***********************************
#define LEFT_LEG 1
// This is just the bones,
// Choose one of the following options to add muscles
#define LEFT_LEG_SIMPLE_MUSCLES 0
#define LEFT_LEG_MUS_3E 0


// RightLegTD: 1 included, 0 not included
// ************************************
#define RIGHT_LEG_TD 0
// This is just the bones,
// Choose one of the following options to add muscles
#define RIGHT_LEG_TD_SIMPLE_MUSCLES 0
#define RIGHT_LEG_TD_MUS_3E 0


// LeftLegTD: 1 included, 0 not included
// ***********************************
#define LEFT_LEG_TD 0
// This is just the bones,
// Choose one of the following options to add muscles
#define LEFT_LEG_TD_SIMPLE_MUSCLES 0
#define LEFT_LEG_TD_MUS_3E 0

As you see the file lists all the individual body parts, each one with its different available versions. Lets have a closer look at the right leg.

The first define statement is a global switch for the leg. When set to 1 the leg is included and when set to 0 the leg is not included. Please notice that RIGHT_LEG includes the leg without muscle. You want the muscles to be included you have to set one of the muscle models to 1. So typically for a body part you can choose the three following version:

  1. With no muscles: a version where all the anatomical muscles have been replaced by simple joint torque muscles. This is useful for development, because the model loads and runs much faster in this version, and for traditional joint-torque-type inverse dynamics.
  2. With simple muscles: the basic version including simple muscle models, i.e. muscles that have constant strength regardless of length and contraction velocity.
  3. With three-elements muscles, also called Mus3E: the version with Hill-type, three-element muscles that take the complexities of contraction dynamics, tendon elasticity, and many other physiological properties into account.

Of course you cannot switch on both muscle models at the same time, that will generate an error message. You should also notice that the two last define statement are really for the muscles only, so if RIGHT_LEG is set to 0 then nothing will be included at all, no matter if you select a muscle model or not.

So now that we learned to use the body setup we should practice and create the body model we are interested in, the right leg. We will also include the trunk because the psoas muscles of the trunk model have their insertion point on the femur. The template of the BodyPartsSetup file we just copied is defining a full body model without muscles. Lets modify it to create our right leg and trunk model, without muscles also for the moment as we said it is useful for the development phase.

// Trunk: 1 included, 0 not included
// *********************************
#define TRUNK 1
// This is just the bones,
// Choose one of the following options to add muscles
#define TRUNK_SIMPLE_MUSCLES 0

...

// RightArm: 1 included, 0 not included
// ************************************
#define RIGHT_ARM 0
// This is just the bones,
// Choose one of the following options to add muscles
#define RIGHT_ARM_SIMPLE_MUSCLE 0
#define RIGHT_ARM_SIMPLE_MUSCLE_ONLY_ON_NECK 0
#define RIGHT_ARM_MUS_3E 0


// LeftArm: 1 included, 0 not included
// ***********************************
#define LEFT_ARM 0
// This is just the bones,
// Choose one of the following options to add muscles
#define LEFT_ARM_SIMPLE_MUSCLES 0
#define LEFT_ARM_SIMPLE_MUSCLES_ONLY_ON_NECK 0
#define LEFT_ARM_MUS_3E 0


// RightLeg: 1 included, 0 not included
// ************************************
#define RIGHT_LEG 1
// This is just the bones,
// Choose one of the following options to add muscles
#define RIGHT_LEG_SIMPLE_MUSCLES 0
#define RIGHT_LEG_MUS_3E 0


// LeftLeg: 1 included, 0 not included
// ***********************************
#define LEFT_LEG 0
// This is just the bones,
// Choose one of the following options to add muscles
#define LEFT_LEG_SIMPLE_MUSCLES 0
#define LEFT_LEG_MUS_3E 0

We previously mentioned that the body model was included into the folder named 'HumanModel' to allows us to add a few necessary additional items. You will see the necessity of this if you try to load the model by pressing F7. This should produce the following error message:

ERROR(SCR.PRS9) : R..l/Body/A..n/T..k/PelvisSeg.any : 'ScaleFunction' : Unresolved object

It appears that an object named ' ScaleFunction ' is missing from the model. All the body models in the repository are set up to expect some sort of scaling to be defined by the user. The repository comes with a number of different scaling laws, and it is possible for the advanced user to define new scaling laws. This, however, is a worthy subject of a separate tutorial, so here we shall just chose the simplest solution, which is to use the standard scaling. This really means that we do not scale at all but simply use the body models in the size they were originally defined, i.e. roughly like a 50th percentile European male:

AnyFolder HumanModel={
     // Select the body model:
      // ----------------------
      // This file contains a list of all body parts, select them to create
      // the body model wanted.
      #include  "BodyPartsSetup.any"

      // This file creates the body model from the selected list.
      #include  "..\..\..\Body\AAUHuman\BodyModels\GenericBodyModel\BodyModel.any"

      #include "..\..\..\Body\AAUHuman\Scaling\ScalingStandard.any"
    };

Now we are at it, we also need to set the basic strength of muscles in the different body parts:

AnyFolder HumanModel={
      ...
     #include "..\..\..\Body\AAUHuman\Scaling\ScalingStandard.any"
      AnyFolder StrengthParameters={
        AnyVar SpecificMuscleTensionSpine= 90; //N/cm^2
        AnyVar StrengthIndexLeg= 1; 
        AnyVar SpecificMuscleTensionShoulderArm= 90; //N/cm^2
      };
     #include "..\..\..\Body\AAUHuman\Scaling\ScalingStandard.any"
    };

The strengths of the body parts scale differently. For the spine and shoulder complex the model needs a specific stress of the muscle tissue, while the legs need a strength index. However, in both cases a change of the numbers will scale the strength of the body part accordingly. This gives easy opportunity to, for instance, reduce the strength of the body when modeling an elderly individual.

When you load the model again you will get a new error message:

ERROR(SCR.PRS9) : R..l/Body/A..n/B..s/I..e/SettingsTrunk.any : 'Colors' : Unresolved object

Colors is the local name of a folder inside the body models. It expects a folder defined in the model containing definitions of colors of the various objects in the model. All the applications in the repository use the same color setup, which is responsible for the graphical similarity between the different applications, i.e. bones, muscles and such with the same colors. To use the same settings here, click the New Include icon,

and fill the following into the new file:

AnyFolder DrawSettings ={
    
  //This is the color definitions of the nodes and segments
  AnyFolder  Colors = {
    AnyVec3 AnyBodyRed = {149/256,51/256,55/256};    //AnyBody standard red
    AnyVec3 AnyBodyGreen = {47/256,131/256,80/256};  //AnyBody standard green
    AnyVec3 AnyBodyBlue = {82/256,85/256,111/256};   //AnyBody standard blue
    AnyVec3 AnyBodyYellow= {235/256,197/256,17/256}; //AnyBody standard yellow
    AnyVec3 AnyBodyPaleYellow = {248/256,204/256,115/256}; //AnyBody standard pale yellow
    
    AnyVec3 Nodes = AnyBodyPaleYellow; 
    AnyVec3 Segments =  AnyBodyPaleYellow; 
  };
  
  AnyFolder Muscle ={ 
    AnyVec3 RGB = .Colors.AnyBodyRed;
    AnySwitch Visible = On;
    AnyVar Bulging = 1.0;
    AnyVar ColorScale =1.0;
    AnyVec3 RGBColorScale = {0.957031, 0.785156, 0.785156};
    AnyVar MaxStress = 100000.000000; //N/m^2 //This number is for graphics only!
    AnyVar Opacity =1.0;
    
  }; 
  
  AnyFolder BonesOpacity ={
    
    AnyVar GlobalCoef = 1;
    
    AnyVar Skull = 1*GlobalCoef;
    AnyVar Thorax = 1*GlobalCoef;
    AnyVar Pelvis = 1*GlobalCoef;
    AnyVar Sacrum = 1*GlobalCoef;
    AnyVar L5 = 1*GlobalCoef;
    AnyVar L4 = 1*GlobalCoef;
    AnyVar L3 = 1*GlobalCoef;
    AnyVar L2 = 1*GlobalCoef;
    AnyVar L1 = 1*GlobalCoef;
    
    AnyVar RightFoot = 1*GlobalCoef;
    AnyVar RightShank = 1*GlobalCoef;
    AnyVar RightThigh = 1*GlobalCoef;
    
    AnyVar LeftFoot = 1*GlobalCoef;
    AnyVar LeftShank = 1*GlobalCoef;
    AnyVar LeftThigh = 1*GlobalCoef;

    
    AnyVar RightClavicula = 1*GlobalCoef;
    AnyVar RightScapula = 1*GlobalCoef;
    AnyVar RightHumerus = 1*GlobalCoef;
    AnyVar RightUlna = 1*GlobalCoef;
    AnyVar RightRadius = 1*GlobalCoef;
    AnyVar RightHand = 1*GlobalCoef;
    
    AnyVar LeftClavicula = 1*GlobalCoef;
    AnyVar LeftScapula = 1*GlobalCoef;
    AnyVar LeftHumerus = 1*GlobalCoef;
    AnyVar LeftUlna = 1*GlobalCoef;
    AnyVar LeftRadius = 1*GlobalCoef;
    AnyVar LeftHand = 1*GlobalCoef;

    
    // For leg TD only.
    AnyVar RightTalus = 1*GlobalCoef;
    AnyVar RightPatella = 1*GlobalCoef;
    
    AnyVar LeftTalus = 1*GlobalCoef;
    AnyVar LeftPatella = 1*GlobalCoef;
    
    // For detailed cervical model only.
    AnyVar C1 = 1*GlobalCoef;
    AnyVar C2 = 1*GlobalCoef;
    AnyVar C3 = 1*GlobalCoef;
    AnyVar C4 = 1*GlobalCoef;
    AnyVar C5 = 1*GlobalCoef;
    AnyVar C6 = 1*GlobalCoef;
    AnyVar C7 = 1*GlobalCoef;
  };
  
  AnyFolder SegmentAxes ={
    AnyVec3 RGB ={0,0,1};
    AnyVec3 ScaleXYZ ={0.0001,0.00001,0.00001};
  };
  AnyFolder BML ={
    AnyVec3 ScaleXYZ ={0.0006,0.0006,0.0006};
    AnyVec3 RGB = .Colors.AnyBodyBlue;
  };
  AnyFolder JointAxesProximal = {
    AnyVec3 RGB = .Colors.AnyBodyRed;
    AnyVec3 ScaleXYZ = {0.015,0.015,0.015};
  };
  AnyFolder JointAxesDistal = {
    AnyVec3 RGB = .Colors.AnyBodyGreen;
    AnyVec3 ScaleXYZ = {0.01,0.01,0.01};
  };
  
  
  AnyFolder SegmentNodes ={
    AnyVec3 ScaleXYZ ={0.0005,0.0005,0.0005};
    AnyVec3 RGB = .Colors.AnyBodyRed;
  };
  AnyFolder WrapGeometry ={
    AnyVec3 RGB ={1,1,1};
  };
  
  
  
  AnyFolder   DrawSettingsSupport={
    AnyFolder Lin={ 
      AnyVar   ScaleFactor=0.004; 
      AnyVec3  RGB = {0,0,1};
      AnyVar Thickness = 0.004;
      AnyVar HeadThickness = 2*Thickness;
      AnyVar HeadLength = 3*Thickness;
    };
    AnyFolder Rot={ 
      AnyVar  ScaleFactor=0.08; 
      AnyVec3 RGB = {1,0,0};
      AnyVar  Thickness = 0.075;
      AnyVar  HeadThickness = 2*Thickness;
      AnyVar  HeadLength = 5*Thickness;
    };
  };
  
  AnyFolder   DrawSettingsJointReactions={
    AnyFolder Lin={ 
      AnyVar   ScaleFactor=0.0005; 
      AnyVec3  RGB = {0,0,1};
      AnyVar Thickness = 0.01;
      AnyVar HeadThickness = 2*Thickness;
      AnyVar HeadLength = 3*Thickness;
    };
    AnyFolder Rot={ 
      AnyVar  ScaleFactor=0.001; 
      AnyVec3 RGB = {1,0,0};
      AnyVar  Thickness = 0.01;
      AnyVar  HeadThickness = 2*Thickness;
      AnyVar  HeadLength = 5*Thickness;
    };
  };
  
  AnyFolder   Names={
  AnyVec3  RGB={0,0,1};
  AnyVec3 ScaleXYZ={0.01,0.01,0.01};
  };
  
  AnyFolder Marker={
  AnyVec3 Color={0,0,1};
  AnyVar Radius=0.005;
  
  };
}; //DrawSettings

Then save the new file under the name "DrawSettings.any". The beauty of all this is that it allows you to very easily change many of the graphical settings of the entire model just by changing a few numbers in this file. For instance, if you want to give all the bones in the modela newcolor, then simply edit the blend of red, green and blue for the AnyBodyPaleYellow setting near the top of the file.

To use these settings, the following must be added to the Pedal.Main.any file:

Main = {

  #include "DrawSettings.any"
  
  // The actual body model goes in this folder
  AnyFolder HumanModel = {

Try loading the model again. F7 should produce one last error message:

ERROR(SCR.PRS9) : R..l/Body/A..n/T..k/InitialPositionsPelvis.any : 'JointPos' : Unresolved object

The system needs to be given some initial positions for the segments. This is done by the Mannequin.any file. As it is quite a long file we will simply copy the one of the standing model. Go into the StandingModel directory, copy the Mannequin file and paste it in the PedalModel directory. We also need to include the file in the code, for structural reason it is included in the folder MyPedal and then referred to in the folder HumanModel

AnyFolder HumanModel={
      
      AnyFolder &Mannequin=.MyPedal.Mannequin;
...
};

AnyFolder MyPedal = {
      #include "Environment.any"
      
      #include "Mannequin.any"
      
    }; // MyPedal

As we are into structural adjustments, maybe you noticed that we have now two folders: HumanModel containing the human body and MyPedal containing the pedal and the connection elements. However if you look in the AnyBodyStudy you will see that it only perform the study on the folder MyPedal. The HumanModel is not part of the study yet. The easy solution is to simply make a reference to HumanModel inside MyPedal.

AnyFolder MyPedal = {

    AnyFolder &HumanModel=.HumanModel.BodyModel; 

      #include "Environment.any"
      
      #include "Mannequin.any"
      
    }; // MyPedal

Try loading the model again. F7 should produce the encouraging message:

Model Warning: Study 'Main.MyStudy' contains too few kinematic constraints to be kinematically determinate.
Evaluating model...
Loaded successfully.
Elapsed Time : 0.831000

The model view should show you the following picture:

The warning message about the model containing too few kinematic constraints means that it is not ready yet to perform any movement. We have not made any specifications yet of how everything in the model is connected. This will be the topic of Lesson 7: Making Ends Meet .

AnyBody Technology A/S · Niels Jernes vej 10 · DK-9220 Aalborg Ø · Denmark · Tel. +45 9635 4286 · Fax. +45 9635 4599            Sitemap