Lesson 6: Importing a Leg Model

Having defined the environment, the next step is to introduce a leg into the model. We are gong to pick one from the repository. The repository has several layers from which you can pick models. At the low level you can pick individual body parts but will have to manually provide the necessary interfaces or handles to connect the body parts to each other and to the environment.

A much simpler solution is to use a set of popular, pre-defined assemblies of body parts that come with the necessary interfaces to hook them up to the environment. This is what we shall do here, and it is not much more than specifying an include file. If you open up the BRep branch of the repository and go to the Aalborg section, you will find the following directories:

Some of these directories are specfic body parts, while others contain various useful utilities. The BodyModels directory is a bit of each. It contains the pre-defined assemblies of body models that you can easily insert into your model. Opening BodyModels reveals the following (please notice that this collection is subject to constant updates and hence changes a bit over time):

 

As the names indicate most of these directories contain one body model that you can include into your application. For the simple pedal example we are going to use the RightLeg model. Opening it up reveals that there is more to it than a single file:

Each of these body models comes in three different forms:

  1. BodyModel.any is the basic version including simple muscle models, i.e. muscles that have constant strength regardless of length and contraction velocity.
  2. BodyModel_Mus3E.any is the version with Hill-type, three-element muscles that take the complexities of contraction dynamics, tendon elasticity, and many other physiological properties into account.
  3. BodyModel_NoMuscles.any is 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.

To use a body model simply add an include statement for the version you want into the Main file of your application. In our case it goes like this:

Main = {
  // The actual body model goes in this folder
  AnyFolder MyPedal = {
    #include "Environment.any"

    AnyFolder HumanModel={
      #include  "../../../BRep/Aalborg/BodyModels/RightLeg/BodyModel_NoMuscles.any"
    };
  }; // MyPedal

  // The study: Operations to be performed on the model
  AnyBodyStudy MyStudy = {
    AnyFolder &Model = .MyPedal;
    RecruitmentSolver = MinMaxSimplex;
    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. We are using the model without muscles during the development because it loads much faster. The separate folder for the human model 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) :   Repository.6.3/BRep/Aalborg/BodyModels/Include/SettingsTrunk.any(14)  :   'Scaling'  :  Unresolved object

It appears that an object named 'Scaling' 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={
  #include  "../../../BRep/Aalborg/BodyModels/RightLeg/BodyModel_NoMuscles.any"
  #include "../../../BRep/Aalborg/Scaling/ScalingStandard.any"
};

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

AnyFolder HumanModel={
  #include  "../../../BRep/Aalborg/BodyModels/RightLeg/BodyModel_NoMuscles.any"
  #include "../../../BRepAalborg/Scaling/ScalingStandard.any"
  AnyFolder StrengthParameters={
    AnyVar SpecificMuscleTensionSpine= 90; //N/cm^2
    AnyVar StrengthIndexLeg= 1;
    AnyVar SpecificMuscleTensionShoulderArm= 90; //N/cm^2
  };
};

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) :   Repository.6.3/BRep/Aalborg/BodyModels/Include/SettingsTrunk.any(36)  :   'ColorRef'  :  Unresolved object

ColorRef 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;
    AnyVar DrawOnOff = 1.0;
    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 Transparency =1.0;

  };
  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 model a new color, then simply edit the blend of red, green and blue for the AnyBodyPaleYellow setting near the top opt 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 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 pedal seems to be located in the middle of the pelvis, which is really a symptom of the warning that the model contains too few kinematic constraints. 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
Copyright (c) AnyBody Technology A/S · 2006 · All rights reserved · Email webmaster@anybodytech.com