Lesson 1: Starting with a New Model

Lesson 1: Starting with a New Model#

In this tutorial, we will create a model of a single leg stepping on a pedal.

Creating a model from templates#

The toolbar button “Template” will generate a pop-up menu that looks like the image below. Select the “Human” template, set the “Target Folder” as per your convenience, but you must set the target name as “MyPedal”:

New template model button New Template dialog

If you press the OK button, it will open an editor window of “MyPedal.main.any” file that includes the following lines:

#include "libdef.any"

Main = {  

  // Body Model configuration:
  #include "Model/BodyModelConfiguration.any"

  // Using your own Mannequin.any file in the Model folder of your model
  #include "Model/Mannequin.any"

  // Include default human model
  #include "<ANYBODY_PATH_BODY>/HumanModel.any"

  AnyFolder Model = {
    // A link to the human model
    AnyFolder &BodyModel = .HumanModel.BodyModel;
    AnyFolder &DefaultMannequinDrivers = .HumanModel.DefaultMannequinDrivers;
    
    // Environment files are used to include objects surrounding human
    #include "Model/Environment.any"  
 
    AnyFolder ModelEnvironmentConnection = {
      //'JointsAndDrivers.any' file can include all kinematic constraints such as joints and drivers
      #include "Model/JointsAndDrivers.any"
      // Additional reactions which are required to run the inverse dynamics analysis
      #include "Model/Reactions.any"
    };
  };
 
  AnyBodyStudy Study = {
    AnyFolder &Model = .Model;  
    
    Gravity={0.0, -9.81, 0.0};
    nStep = 11;
    // Overdeterminate solver is needed while using the 
    // soft default mannequin drivers.
    Kinematics.SolverType = KinSolOverDeterminate;
    InitialConditions.SolverType = Kinematics.SolverType ;
  };

    #include "Model/RunAppSequence.any"
}; //Main

When you load the model, you should see the following image in your model view:

Model view Full body

Double-clicking the following line:

#include "Model/Environment.any" 

Opens up the “Environment.any” file which is created by the Human template.

//This is a place holder for the modeling of the environment.
AnyFolder Environment = {

};

For this model, the only environment objects will be the global reference frame (i.e. ground), and the pedal which the foot will be stepping on. You can define the global reference frame within the environment folder as follows:

//This is a place holder for the modeling of the environment.
AnyFolder Environment = {
  AnyFixedRefFrame GlobalRef = {
    viewRefFrame.Visible=On;
    viewRefFrame.ScaleXYZ = 0.5*{1,1,1};
    };
};

Click the “Save” button or Ctrl-S to save what you have typed in this Environment.any file and reload the model.

The model structure#

Let us first review the structure of the model in slightly more detail. This structure creates a clear division between the human body parts and the applications we hook them up to.

ModelTree

Just below “Main”, you see the “HumanModel” folder which holds all the body parts that are imported from the AMMR, such as segments (bones), joints, muscles etc.

Information for scaling the size of the default human model is also stored here. In general, you won’t need to modify this information directly.

The “Model” folder comes next this holds information specific to the application you’re creating. In this case, this is the pedal model. The “Model” folder is sub-divided into three sub-folders:

  • HumanModel - This is a local reference to the “Main.HumanModel”, located within the “Model” folder. This section can help you recollect what reference objects are.

  • Environment - This contains external hardware such as chairs, bicycles, tools, or, in the present case, a pedal.

  • ModelEnvironmentConnection - This holds the measures and drivers that link the body model together to the environment.

Add pedal segment#

The pedal will be hinged at one end, with the foot pushing down at the other. We will define the pedal segment and the hinge in the “Environment.any” file:

This is achieved by the following lines:

AnyFolder Environment = {
  AnyFixedRefFrame GlobalRef = {
    viewRefFrame.Visible=On;
    viewRefFrame.ScaleXYZ = 0.5*{1,1,1};
    };
  AnySeg Pedal = {
    viewInertia.Visible = On;
    Mass = 2;
    Jii = {0.05, 0.001, 0.05};
    AnyRefNode Hinge = {
      sRel = {0, -0.15, 0};
    };
    AnyRefNode FootNode = {
      sRel = {0, 0.15, 0};
    };
  };
  AnyRevoluteJoint HingeJoint = {
    Axis = z;
    AnyFixedRefFrame &Ground = .GlobalRef;
    AnyRefNode &Pedal = .Pedal.Hinge;
  };
};

If you reload the model, you will see the new segment in the model:

Model view new segment

In the next lesson, we shall look at how you can customize the human model to fit the purpose of your simulation using AnyBody.