[770c98]: / Application / Examples / JumpingJack / JumpingJack.main.any

Download this file

391 lines (313 with data), 10.7 kB

#include "../libdef.any"

/** This is a stand-alone instructional model of a jumping driven by
a pull string. The model shows how to create segments, joints and drivers
and how AnyScript as s declarative language frees allows the user to
simply declare the presence of objects whereafter the system sorts out
the connections and computes the dynamics. */
Main = {
  
  // The actual body model goes in this folder
  AnyFolder MyModel = {
    
    /// The Global Reference Frame, i.e. ground.
    AnyFixedRefFrame GlobalRef = {
      AnyRefNode HandleBase={
        sRel={0,-0.4,0};
      };
    };  // Global reference frame
    
    #include "Model/DrawSettings.any"    
    
    AnySeg Body = {
      Mass=0.00013025*750;
      Jii={6.038*10^-7,6.14*10^-8,6.61*10^-7}*750;
      sCoM={0,-0.0768,0};
      
      AnyDrawSTL drw1={
        FileName ="Input/BodyBase.stl";
        RGB=..DrawSettings.Colors.AnyBodyGreen;
        Opacity=1;
        AnyStyleDrawMaterial1 style = 
        {
          EnableCreasing = On;
          CreasingAngle = 0.524;
          SpecularRGB = 0.05*{1,1,1};
        };
      };
      
      AnyDrawSTL drw2={
        FileName ="Input/BodyDecor.stl";
        RGB=..DrawSettings.Colors.AnyBodyRed;
        Opacity=1;
        AnyStyleDrawMaterial1 style = 
        {
          EnableCreasing = On;
          CreasingAngle = 0.524;
          SpecularRGB = 0.05*{1,1,1};
        };
      };
      
      AnyRefNode NailHole ={
        sRel={0,0,0};
      };
      
      AnyRefNode RightArmJntNode={
        sRel={-0.043,-0.082,0};
      };
      
      AnyRefNode LeftArmJntNode={
        sRel={0.043,-0.082,0};
      };
      
      AnyRefNode RightLegJntNode={
        sRel={-0.037,-0.207,0};
      };
      
      AnyRefNode LeftLegJntNode={
        sRel={0.037,-0.207,0};
      };  
      
      AnyRefNode StringNodeTop={
        sRel={-0.0,-0.12,0};
      };
      
      AnyRefNode StringNodeBottom={
        sRel={-0.0,-0.217,0};
      };      
      
      AnyRefNode LogoLocation={
        sRel={-0.0,-0.12,0.0045};
      };
    };
    
    AnySeg RightArm = {
      Jii={7.7863*10^-10,2.1221*10^-8,2.196*10^-8}*750;
      Mass=1.403*10^-5*750; // The mass should always be defined
      r0 ={-0.097000, -0.083000, 0.000000};
      
      AnyDrawSTL drw={
        FileName ="Input/arm.stl";
        RGB=..DrawSettings.Colors.AnyBodyBlue;
        Opacity=1;
        AnyStyleDrawMaterial1 style = 
        {
          EnableCreasing = On;
          CreasingAngle = 0.524;
          SpecularRGB = 0.05*{1,1,1};
        };
      };
      
      AnyRefNode JntNode={        sRel={0.054,0.001,0};      };
      AnyRefNode StringNode={        sRel={0.065,0.001,0};      };  
    };
    
    
    AnySeg LeftArm = {
      Jii={7.7863*10^-10,2.1221*10^-8,2.196*10^-8}*750;
      //Jij={-4.492*10^-11,0,0}*750;
      Mass=1.403*10^-5*750;
      Axes0 = {{-1.000000, -0.000000, 0.000000}, {0.000000, -1.000000, 0.000000}, {0.000000, 0.000000, 1.000000}};
      r0 ={0.097000, -0.083000, 0.000000};
      
      AnyDrawSTL drw={
        FileName ="Input/arm.stl";
        RGB=..DrawSettings.Colors.AnyBodyBlue;
        ScaleXYZ={1,-1,1};
        Opacity= 1;
        AnyStyleDrawMaterial1 style = 
        {
          EnableCreasing = On;
          CreasingAngle = 0.524;
          SpecularRGB = 0.05*{1,1,1};
        };
      };
      
      AnyRefNode JntNode={
        sRel={0.054,-0.001,0};
      };
      
      AnyRefNode StringNode={
        sRel={0.065,-0.001,0};
      };
    };
    
    AnySeg RightLeg = {
      Mass=2.5*10^-5*750;  //volume(from CAD program) * density (guestimate for wood)
      Jii={7.64*10^-8,4.605*10^-9,8.0946*10^-8}*750;
      //Jij={-1.02*10^-9,0,0}*750;
      r0 ={-0.046000, -0.283000, 0.000000};
      
      AnyDrawSTL drw={
        FileName ="Input/leg.stl";
        RGB=..DrawSettings.Colors.AnyBodyBlue;
        Opacity= 1;
        AnyStyleDrawMaterial1 style = 
        {
          EnableCreasing = On;
          CreasingAngle = 0.524;
          SpecularRGB = 0.05*{1,1,1};
        };
      };
      
      AnyRefNode StringNode={
        sRel={0.013,0.089,0};
      };
      
      AnyRefNode JntNode={
        sRel={0.009,0.076,0};
      };      
    };
    
    AnySeg LeftLeg = {
      Mass=2.5*10^-5*750;  //volume(from CAD program) * density (guestimate for wood)
      Jii={7.64*10^-8,4.605*10^-9,8.0946*10^-8}*750;
      //Jij={-1.02*10^-9,0,0}*750;
      r0 ={0.046000, -0.283000, 0.000000};
      AnyDrawSTL drw={
        FileName ="Input/leg.stl";
        RGB=..DrawSettings.Colors.AnyBodyBlue;
        ScaleXYZ={-1,1,1};
        Opacity= 1;
        AnyStyleDrawMaterial1 style = 
        {
          EnableCreasing = On;
          CreasingAngle = 0.524;
          SpecularRGB = 0.05*{1,1,1};
        };
      };
      
      AnyRefNode StringNode={
        sRel={-0.013,0.089,0};
      };
      
      AnyRefNode JntNode={
        sRel={-0.009,0.076,0};
      };
    };
    
    AnyFixedRefFrame  Handle ={
      //      Mass=9.869*10^-6*750;
      //      Jii={2.13*10^-9,2.13*10^-9,4.147*10^-9}*750;
      Origin={0.000000, -0.399000, 0.000000};
      AnyDrawSurf drw={
        FileName ="Input/handle";
        RGB=..DrawSettings.Colors.AnyBodyGreen;
      };
    };
    
        AnySeg Logo={
          Mass=0;
          Jii={0,0,0};
          r0 = {0, -0.12, 0.0045};
          Axes0 = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
          AnyDrawSTL Body = {
            FileName = ANYBODY_PATH_MODELUTILS + "/DrawObjects/Body-grey.stl";
            RGB = ..DrawSettings.Colors.AnyBodyRed;
            
            ScaleXYZ={0.002,0.002,0.002};
            Opacity= 1;
          };
          
          AnyDrawSTL AnyTechnology = {
            FileName = ANYBODY_PATH_MODELUTILS + "/DrawObjects/AnyTechnology-red.stl";
            RGB = ..DrawSettings.Colors.AnyBodyGrey;
            
            ScaleXYZ={0.002,0.002,0.002};
            Opacity= 1;
          };
        };
    
        AnySphericalJoint LogoJnt={
          AnyRefNode &ref1=.Body.LogoLocation;
          AnySeg &ref2=.Logo;
        };
        
        AnyKinEqSimpleDriver LogoJntDrv={
          AnySphericalJoint &ref1=.LogoJnt;
          DriverPos={0,0,0};
          DriverVel={0,0.0,0};
        };
        
    AnyKinEq NailBodyJnt={
      AnyKinLinear lin ={
        AnyRefFrame &ref1=..GlobalRef;
        AnyRefFrame &ref2=..Body.NailHole;
      };
      
      AnyKinRotational rot ={
        AnyRefFrame &ref1=..GlobalRef;
        AnyRefFrame &ref2=..Body.NailHole;
        Type=RotAxesAngles;
      };
    };
    AnyFunConst WeightFun ={Value = {0.001};};
    
    AnyRevoluteJoint RightArmJnt={
      AnyRefFrame &ref1=.Body.RightArmJntNode;
      AnyRefFrame &ref2=.RightArm.JntNode;
    };
    AnyKinEqSimpleDriver RightArmDrv ={
      AnyRevoluteJoint &ref=.RightArmJnt;
      DriverPos={0.6};
      DriverVel={0.0};
      CType={Soft};
      Reaction.Type={Off};
      WeightFun={&.WeightFun };
      
    };
    
    
    
    AnyRevoluteJoint LeftArmJnt={
      AnyRefFrame &ref1=.Body.LeftArmJntNode;
      AnyRefFrame &ref2=.LeftArm.JntNode;
    }; 
    AnyKinEqSimpleDriver LeftArmDrv ={
      AnyRevoluteJoint &ref=.LeftArmJnt;
      DriverPos={2.544869};
      DriverVel={0};
      CType={Soft};
      Reaction.Type={Off};
      WeightFun={&.WeightFun };
      
    };
    
    
    AnyRevoluteJoint RightLegJnt={
      AnyRefFrame &ref1=.Body.RightLegJntNode;
      AnyRefFrame &ref2=.RightLeg.JntNode;
    }; 
    
    AnyRevoluteJoint LeftLegJnt={
      AnyRefFrame &ref1=.Body.LeftLegJntNode;
      AnyRefFrame &ref2=.LeftLeg.JntNode;
    }; 
    
    AnyKinEqSimpleDriver RightLegJntDrv={
      AnyRevoluteJoint &ref=.RightLegJnt;
      DriverPos={0.09828748};
      DriverVel={0};
      CType={Soft};
      Reaction.Type={Off};
      WeightFun={&.WeightFun };
      
    };
    
    AnyKinEqSimpleDriver LeftLegJntDrv={
      AnyRevoluteJoint &ref=.LeftLegJnt;
      DriverPos={-0.09828748};
      DriverVel={0};
      CType={Soft};
      Reaction.Type={Off};
      WeightFun={&.WeightFun };
      
    };
    
    
    
    
    
    
    
    AnyKinPLine RightArmString ={
      AnyRefNode &ref1=.RightArm.StringNode;
      AnyRefNode &ref2=.Body.StringNodeTop;
      AnyRefFrame &ref3=.Handle;   
      AnyDrawPLine drw={Thickness=0.0015; RGB={1,0,0};};
    };
    
    AnyKinPLine LeftArmString ={
      AnyRefNode &ref1=.LeftArm.StringNode;
      AnyRefNode &ref2=.Body.StringNodeTop;
      AnyRefFrame &ref3=.Handle;   
      AnyDrawPLine drw={Thickness=0.0015; RGB={1,0,0};};
    };    
    
    AnyKinPLine RightLegString ={
      AnyRefNode &ref1=.RightLeg.StringNode;
      AnyRefNode &ref2=.Body.StringNodeBottom;
      AnyRefFrame &ref3=.Handle;   
      AnyDrawPLine drw={Thickness=0.0015; RGB={1,0,0};};
    };
    
    AnyKinPLine LeftLegString ={
      AnyRefNode &ref1=.LeftLeg.StringNode;
      AnyRefNode &ref2=.Body.StringNodeBottom;
      AnyRefFrame &ref3=.Handle;   
      AnyDrawPLine drw={Thickness=0.0015; RGB={1,0,0};};
    }; 
    
    AnyKinEqSimpleDriver ArmStringsDrv={
      AnyKinPLine &ref1=.RightArmString;
      AnyKinPLine &ref2=.LeftArmString;
      DriverPos={1,1}*0.334689;
      DriverVel={0.00,0.00}; 
      
      CType = {Soft,Soft};
      
    };
    
    AnyKinEqSimpleDriver LegStringsDrv={
      AnyKinPLine &ref1=.RightLegString;  
      AnyKinPLine &ref2=.LeftLegString;
      DriverPos={1,1}*0.223478;
      DriverVel={0.0,0.0}; 
      CType = {Soft,Soft};
      
    };
    
    
    AnyDrawWidgetLin handle =         {
      Operation = &Main.Study.Kinematics;
      UpdateEvent = OnMouseRelease;
      MaxDrawSize = 0.1;
      MinDrawSize = 0.1;
      RefFrame = &Main.MyModel.GlobalRef;
      Target = &.Main.MyModel.Handle.Origin ;
      AxisOnOff = {Off, On, Off};
    };
    
  }; // MyModel
  
  // The study: Operations to be performed on the model
  AnyBodyStudy Study = {
    AnyFolder &Model = .MyModel;
    
    InitialConditions.SolverType = KinSolOverDeterminate;
    Kinematics.SolverType = KinSolOverDeterminate;
    
    
    Gravity = {0.0, -9.81, 0.0};
    tEnd=10;
    nStep=1;
  };
  
  // Include an operation sequence to run all required steps of your application (see Operations tab)
  #include "Model\RunAppSequence.any"  
  
};  // Main