AnyScript
Home Up AnyScript 2-D Bicycle 3-D Skiing 3-D Bicycle Car Driver Squat Jump Crank Spring

 

Up

Main File: LowerExtremityModel.any

AnyScript files are structured much like software in C++ or Java. Each element, for instance a segment or a muscle, is an object with certain attributes. The object and its attributes are defined inside brackets {}.  The hierarchy of the model is symbolized by the brackets. Objects can refer to each other and depend on each other by symbolic expressions.

The structure of the code is improved by the use of include files. They break the text into digestible chunks and allow similar objects to be re-used several places in the file.

The text may look complicated, but our preliminary experience shows us that the structure is easy enough to understand to allow users to develop their own models very easily based on a few examples.

 

/* Demonstration model of shank and foot equipped with two
muscles built with AnyScript.

Mark de Zee
*/

AnyScript = {

  AnyFolder LowerExtremityModel = {
    #include "SegmentsRight.any"
    #include "DriversRight.any"
    #include "MusclesRight.any"

    AnyFixedRefFrame GlobalRef = {
      //AnyDrawRefFrame DrwGlobalRef = {};
    };

    AnyFolder WholeBodyParameters = {
      AnyVar BodyMass = 75;
      AnyVar BodyHeight = 1.88;
      AnyVar Density = 1000;
    };

    AnyFolder JointsRight = {

      AnyRevoluteJoint Ankle = {
        Axis = y;
        AnyRefNode &ShankNode = SegmentsRight.Shank.AnkleJoint;
        AnyRefNode &FootNode = SegmentsRight.Foot.AnkleJoint;
      }; //End of Ankle

      AnyRevoluteJoint Knee = {
        Axis = y;
        AnyFixedRefFrame &Ground = GlobalRef;
        AnyRefNode &ShankNode = SegmentsRight.Shank.KneeJoint;
      }; //End of knee

    };// End of JointsRight

  }; // End of lower extremity model

  AnyBodyStudy Study = {
    AnyFolder& Model = LowerExtremityModel;
    RecruitmentSolver = MinMaxSimplex;
    tEnd = 1.0; 
  }; // End of study

}; // End of file

Include File: SegmentsRight.any

/* Definitions of segments in the right lower
   extremity.
 
Mark de Zee

*/

AnyFolder SegmentsRight = {

  AnySeg Foot = {
    r = {0,0,0}; //Initial start positon
    Mass = 0.0145*WholeBodyParameters.BodyMass;
    AnyVar Length = 0.24; //Distance heel-toe
    AnyVar Radius = 0.038;
    AnyVar Ixx = 0.5*Mass*Radius*Radius;
    AnyVar Iyy = 0.25*Mass*Radius*Radius + 1/12*Mass*Length*Length;
    AnyVar Izz = Iyy;
    Jii = {0.000785, 0.005613, 0.005613};

    AnyRefNode AnkleJoint = {sRel = {-0.06,0,0.06};};

    AnyRefNode SoleusNode = {sRel = {-0.108,0.001,0.028};};

    AnyRefNode TibialisAnteriorNode = {sRel = {0.0,0.02,0.03};};
    AnyRefNode TibialisAnteriorViaNode = {sRel = {-0.03,0.01,0.05};};

    AnyDrawSTL DrwSTL = {
      FileName = "Rfoot_bone.stl";
      RGB = {0.6,0.6,0.6};
    };    

  }; // End of Foot

  AnySeg Shank = {
    r = {0,0,0.4}; //Initial start positon
    Axes = {{0,0,1},{0,1,0},{-1,0,0}};
    Mass = 0.0465*WholeBodyParameters.BodyMass;
    AnyVar Length = 0.46; //Distance heel-toe
    AnyVar Radius = 0.0491;
    AnyVar Ixx = 0.5*Mass*Radius*Radius;
    AnyVar Iyy = 0.25*Mass*Radius*Radius + 1/12*Mass*Length*Length;
    AnyVar Izz = Iyy;
    Jii = {0.002518, 0.062755, 0.062755};

    AnyRefNode AnkleJoint = {sRel = {0.2608,0.0,0.0};};
    AnyRefNode KneeJoint = {sRel = {-0.1992,0.0,0.0};};

    AnyRefNode SoleusNode = {sRel = {-0.1292,0.0,-0.020};};

    AnyRefNode TibialisAnteriorNode = {sRel = {-0.0115,0.01,0.0};};

    AnyDrawSTL DrwSTL = {
      FileName = "Rtibia_bone.stl";
      RGB = {0.6,0.6,0.6};
    };

  }; // End of Shank

};
 

Include File: DriversRight.any

/* Definition of Driver for the knee and ankle joint.
The knee is locked to the global reference frame and ankle makes
plantarflexion.

Mark de Zee
*/

AnyFolder DriversRight = {

  AnyKinEqSimpleDriver AnkleDriver = {
    AnyRevoluteJoint &AnkleJoint = JointsRight.Ankle;
    DriverPos = {1.8};
    DriverVel = {-1.0};
    Reaction.Type = {0.0};
  };

  AnyKinEqSimpleDriver KneeDriver = {
    AnyRevoluteJoint &KneeJoint = JointsRight.Knee;
    DriverPos = {-1.57};
    DriverVel = {0.0};
    Reaction.Type = {1.0};
  };

};

 

Include File: MusclesRight.any

/* Definitions of muscles in the right lower extremity

Mark de Zee

*/

AnyFolder MusclesRight = {

  AnyMuscleModel MusMdl = {F0 = 300;};

  AnyViaPointMuscle Soleus = {
    AnyMuscleModel &MusMdl = MusclesRight.MusMdl;
    AnyRefNode &Org = SegmentsRight.Shank.SoleusNode;
    AnyRefNode &Ins = SegmentsRight.Foot.SoleusNode;
    AnyDrawViaPointMuscle DrwMus = {};
  };

  AnyViaPointMuscle TibialisAnterior = {
    AnyMuscleModel &MusMdl = MusclesRight.MusMdl;
    AnyRefNode &Org = SegmentsRight.Shank.TibialisAnteriorNode;
    AnyRefNode &Via = SegmentsRight.Foot.TibialisAnteriorViaNode;
    AnyRefNode &Ins = SegmentsRight.Foot.TibialisAnteriorNode;
    AnyDrawViaPointMuscle DrwMus = {};
  };

};