[38ba34]: / Body / AAUHuman / Arm / Jnt.any

Download this file

429 lines (315 with data), 11.8 kB

//This is the definition of the joints in the arm


#if BM_ARM_THORAX_SCAPULA_CONTACT == _MULTIPLE_POINT_CONTACT_


#endif


/// Definition of SternoClavicular (SC) joint
AnySphericalJoint SternoClavicularJoint = {
  AnyRefNode &thorax_sc = ..ShoulderRef.scj;
  AnyRefNode &clavicula_sc = ..Seg.Clavicula.scj;
  Orientation = {
    // These settings are kept to mimic the  
    // previous implementation.
    Type = RotAxesAngles;
    Axis1 = y;
    Axis2 = z;
    Axis3 = x;
  };
};


/// Defintion of Acromial-Clavicular (AC) joint
AnySphericalJoint AcromioClavicularJoint = {
  AnyRefNode &clavicula_ac = ..Seg.Clavicula.acj;
  AnyRefNode &scapula_ac = ..Seg.Scapula.acj;
  Orientation = {
    // These settings are kept to mimic the  
    // previous implementation.
    Type = RotAxesAngles;
    Axis1 = y;
    Axis2 = z;
    Axis3 = x;
  };

};


/// Definition of GH joint
AnySphericalJoint GlenoHumeralJoint = {
  AnyRefNode &scapula_gh = ..Seg.Scapula.gh;
  AnyRefNode &humerus_gh = ..Seg.Humerus.gh; 
  //These are the reactions of the GH joint they are normally set to "Off Off Off" if the file 
  // GHReactions.any is being used, if this is not the case the reactions should be set to "On On On"
  Constraints.Reaction.Type={Off,Off,Off};
  Orientation = {
    // These settings are kept to mimic the  
    // previous implementation.
    Type = RotAxesAngles;
    Axis1 = y;
    Axis2 = z;
    Axis3 = y;
  };

};

//This file includes the glenohumeral reactions created by a number of pushing muscles
//if this file is not include the normal reactions of the GH joint should be set to "On On On"6
#include "GHReactions.any"




///Definition of the HumeroUlnarJoint (elbow flexion extension).
AnyRevoluteJoint HumeroUlnarJoint = {
  Axis = x;
  AnyRefNode &HumerusFE = ..Seg.Humerus.fe;
  AnyRefNode &UlnaFE = ..Seg.Ulna.fe;
};


/// This binds one DOF between humerus and Radius. Since AnyBody
/// does not have a 5 DOF joint type we implement in manually here.
AnyFolder HumeroRadialJoint = {
   AnyKinLinear Linear = {
     AnyRefNode &RadiusPs = ...Seg.Radius.PointHumeralRadialJoint;
     AnyRefNode &UlnaPs = ...Seg.Humerus.fe; 
     Ref = 0;
   };
   AnyKinEq Constraints = {
     AnyKinMeasure& Linear  = .Linear;
     MeasureOrganizer = {0};
     // Reactions are implemented explicitly below
     Reaction.Type = {Off};
   };

  // Since the previous implementation implemented reaction forces   
  // between some explicit points 'ps2Reac' we do the same here. 
   AnyReacForce ReacForce = 
   {
     AnyKinMeasureOrg RadiusHumerus = {
       MeasureOrganizer = {0};
       AnyKinLinear Lin = 
       {
         Ref = 0;
         AnyRefFrame &Radius = .....Seg.Radius.PS2Reac;
         AnyRefFrame &Humerus = .....Seg.Humerus.fe;
       };
     };
   };

};


AnyTransSphericalJoint ProximalRadioUlnarJoint = { 
  AnyRefNode &RadiusPs = ..Seg.Radius.PointPS2;
  AnyRefNode &UlnaPs = ..Seg.Ulna.ps2; 
  // Reactions are disabled, because the are implemented explicitly below. 
  Constraints.Reaction.Type={Off,Off};
  Axis = x;
  Orientation = {
    // These settings are kept to mimic the previous  
    // implementation from the PSRotProximal measure.
    Axis1 = x;
    Axis2 = y;
    Axis3 = z;
    Type = RotAxesAngles;
  };
  
  // Since the previous implementation implemented reaction forces   
  // between some explicit points 'ps2Reac' we do the same here. 
  AnyReacForce ReacForce = 
  {
    AnyKinMeasureOrg RadiusUlna = {
      MeasureOrganizer = {0,2};
      AnyKinLinear Lin = 
      {
        Ref = 0;
        AnyRefFrame &Ulna = .....Seg.Ulna.ps2Reac;
        AnyRefFrame &Radius = .....Seg.Radius.PS2Reac;
      };
    };
  };

};







AnyTransSphericalJoint DistalRadioUlnarJoint = {
    AnyRefNode &UlnaPs = ..Seg.Ulna.ps2_usRot;
    AnyRefNode &RadiusPs = ..Seg.Radius.PS;
    Axis = y;
}; 






////Definition of wrist joint
AnyRevoluteJoint WristJointFlexion = {
  Axis = y; //flexion extension
  AnyRefNode &radius_wj = ..Seg.Radius.wj;
  AnyRefNode &hand_wj =..Seg.WristJointSeg.FlexionExtensionAxis;
};//End WristJoint

AnyRevoluteJoint WristJointDeviation = {
  Axis = z; //radial ulnar deviation
  AnyRefNode &radius_wj = ..Seg.WristJointSeg.RadialUlnarDeviation;
  AnyRefNode &hand_wj =..Seg.Hand.HandRef.wj;
};//End WristJoint



//Scapula thorax gliding plane

#if BM_ARM_THORAX_SCAPULA_CONTACT == _MULTIPLE_POINT_CONTACT_

AnyKinMeasureExpComb ScapulaAIThoraxMeasure = {
  // A large negative number for the exponential combination measures causes
  // the measure to put emphasis on the "penetration" of the points,
  // while "ignoring" points far from the surface.
  a ??= -200;
  AnyKinPointSurface point_surface_measure = 
  {
    #include "ThoraxScapulaContactPoints.any"
    AnyFolder &surf3 =...Seg.Scapula.Ellipsoid_ai.ellipsoid;
  };
  
};

AnyKinEqSimpleDriver ScapulaAIThoraxNodeDriver = {  
  
  AnyKinMeasure &Measure1=.ScapulaAIThoraxMeasure;
  
  DriverPos = {0};
  DriverVel = {0};
  Reaction.Type = {Off};
  
};

#endif



#if BM_ARM_THORAX_SCAPULA_CONTACT == _ELLIPSOID_CONTACT_




AnyKinEqSimpleDriver ScapulaAIThoraxNodeDriver = {
  
  AnyKinPointSurface Measure1 = {
    AnyRefFrame &r1 = ...Seg.Scapula.ScapulaSlidingAI;
    AnySurface &s1 = ...ShoulderRef.ScapulaEllipsoidOrigin.Elipse;
  };
  
  DriverPos = {0};
  DriverVel = {0};
  Reaction.Type = {Off};
};

#endif



  AnyReacForce ScapulaAIThorax_ContactReaction = {
    Type = NonNegative;
    AnyKinMeasure &ref=.ScapulaAIThoraxNodeDriver.Measure1 ;
  };



//Simple muscle model 
AnyMuscleModel ReactionMuscle = {
  F0 = 5000;
  /// This must have a value to work with volume weighted recruitment
  Vol0=1e-6; 
};



//Definitions of ligaments
AnyKinPLine ConoideumLigament = {
  AnyRefNode &scapula = ..Seg.Scapula.conoid;
  AnyRefNode &clavicle = ..Seg.Clavicula.conoid;   
  AnyDrawPLine drwline= {Thickness=0.005;RGB={1,0,0};};
};

//Artificial muscle will produce reaction in the ligament
AnyMuscleViaPoint ConoidLigamentReaction = {
  AnyRefNode &scapula = ..Seg.Scapula.conoid;
  AnyRefNode &clavicle = ..Seg.Clavicula.conoid; 
  AnyMuscleModel &ref = .ReactionMuscle; 
  viewMuscle = {RGB={0,0,1};MaxStress = 75000000.000000;};
  EXCLUDE_MUSCLE_METABOLISM
   
};
//Artificial muscle will produce reaction in the ligament
AnyMuscleViaPoint TrapezoidLigamentReaction = {
  AnyRefNode &scapula = ..Seg.Scapula.trapezoid;
  AnyRefNode &clavicle = ..Seg.Clavicula.trapezoid;   
  AnyMuscleModel &ref = .ReactionMuscle; 
  viewMuscle = {RGB={0,0,1};MaxStress = 75000000.000000;};
  EXCLUDE_MUSCLE_METABOLISM
   
};


#if BM_ARM_THORAX_SCAPULA_CONTACT == _MULTIPLE_POINT_CONTACT_

AnyKinMeasureExpComb ScapulaTSThoraxMeasure = 
{
  a ??= .ScapulaAIThoraxMeasure.a;
  AnyKinPointSurface point_surface_measure = 
  {
    #include "ThoraxScapulaContactPoints.any"
    AnyFolder &surf3 =...Seg.Scapula.Ellipsoid_ts.ellipsoid;
  };
  
};


AnyFolder &scapula_ai_org  =.Seg.Scapula.ai;
scapula_ai_org ={
  AnyRefNode node_org ={ 
    sRel= {-0.02,0,0};
    AnySurfEllipsoid  ellipsoid ={ 
      Radius={0.065,0.06,0.015};
      //      AnyDrawParamSurf drw ={RGB={0,1,0};};
    };
  };
};


AnyFolder &scapula_ts_org  =.Seg.Scapula.ts;
scapula_ts_org ={
  AnyRefNode node_org ={ 
    sRel= {-0.02,0,0};
    
    AnySurfEllipsoid  ellipsoid ={ 
      Radius={0.05,0.05,0.015};
      //      AnyDrawParamSurf drw ={RGB={0,1,0};};
    };
  };  
};

AnyFolder &scapula  =.Seg.Scapula;

scapula ={
  AnyRefNode ControlNode0_ai = {sRel= .ai.sRel+...Seg.Scapula.Scale({-0.02,...Sign*0.01,0.01}); 
//    AnyDrawNode drw ={RGB={1,0,0};ScaleXYZ={1,1,1}*0.005;};
  };
  AnyRefNode ControlNode1_ai = {sRel= .ControlNode0_ai.sRel+...Seg.Scapula.Scale({0.07,...Sign*0.01,0});
//    AnyDrawNode drw ={RGB={1,0,0};ScaleXYZ={1,1,1}*0.005;};
  };
  AnyRefNode ControlNode2_ai = {sRel= .ControlNode0_ai.sRel+...Seg.Scapula.Scale({0.0,...Sign*(0.07+0.01),0}); 
//    AnyDrawNode drw={RGB={1,0,0};ScaleXYZ={1,1,1}*0.005;};
  };
  AnyRefNode ControlNode3_ai = {sRel= .ControlNode0_ai.sRel+...Seg.Scapula.Scale({0,...Sign*0.01,0.015});
//    AnyDrawNode drw={RGB={1,0,0};ScaleXYZ={1,1,1}*0.005;};
  };
  
  AnyRefNode Ellipsoid_ai ={ 
    sRel=.ControlNode0_ai.sRel;
    
    AnySurfEllipsoid  ellipsoid ={ 
      AnyVar r1 = vnorm(..ControlNode0_ai.sRel-..ControlNode1_ai.sRel);
      AnyVar r2 = vnorm(..ControlNode0_ai.sRel-..ControlNode2_ai.sRel);
      AnyVar r3 = vnorm(..ControlNode0_ai.sRel-..ControlNode3_ai.sRel);
      Radius ={r1,r2,r3};
      // Radius={0.085,0.06,0.015};
      // Radius={0.07,0.06,0.015};
    //  AnyDrawParamSurf drw ={};
    };
  };
  
  AnyRefNode ControlNode0_ts = {sRel= .ts.sRel+...Seg.Scapula.Scale({-0.02,...Sign*(0.01),0.00});
//    AnyDrawNode drw ={RGB={1,0,0};ScaleXYZ={1,1,1}*0.005;};
  };
  AnyRefNode ControlNode1_ts = {sRel= ...Seg.Scapula.Scale({-0.094471940+0.005, ...Sign*(-0.034+0.01), 0.01015005});
//    AnyDrawNode drw ={RGB={1,0,0};ScaleXYZ={1,1,1}*0.005;};
};
  AnyRefNode ControlNode2_ts = {sRel= ...Seg.Scapula.Scale({-0.1319359, ...Sign*(-0.0667+0.01), 0.008610081}); 
//    AnyDrawNode drw={RGB={1,0,0};ScaleXYZ={1,1,1}*0.005;};
};
  AnyRefNode ControlNode3_ts = {sRel= .ControlNode0_ts.sRel+...Seg.Scapula.Scale({0,...Sign*(0.01),0.015}); 
//    AnyDrawNode drw={RGB={1,0,0};ScaleXYZ={1,1,1}*0.005;};
  };
  
  
  
  AnyRefNode Ellipsoid_ts ={
    
    sRel=.ControlNode0_ts.sRel;
    AnySurfEllipsoid  ellipsoid ={ 
      
      AnyVar r1 = vnorm(..ControlNode0_ts.sRel-..ControlNode1_ts.sRel);
      AnyVar r2 = vnorm(..ControlNode0_ts.sRel-..ControlNode2_ts.sRel);
      AnyVar r3 = vnorm(..ControlNode0_ts.sRel-..ControlNode3_ts.sRel);
   
      Radius ={r1,r2,r3};
//      AnyDrawParamSurf drw ={};
    };
  };  
};


#endif


#if BM_ARM_THORAX_SCAPULA_CONTACT == _ELLIPSOID_CONTACT_

//measure needs to always exist 
AnyKinPointSurface  ScapulaTSThoraxMeasure = {
    AnyRefFrame &r1 = ..Seg.Scapula.ScapulaSlidingTS;
    AnySurface &s1 = ..ShoulderRef.ScapulaEllipsoidOrigin.Elipse;
  };

#endif

AnyReacForce ScapulaTSThorax_ContactReaction = {
  Type = NonNegative;
  AnyKinMeasure &ref=.ScapulaTSThoraxMeasure ;
};  

#if BM_ARM_CLAVICULA_ROTATION_RHYTHM
/// Rhythm to distribute axial rotation of the clavicula 
/// equally between sterno-clavicula  and acromio-clavicual joint
AnyKinEq SternoClavicularRotationRhythm  = 
{
  AnyKinMeasureLinComb CombinedMeasure = 
  {
    AnyKinMeasure& SC = ...InterfaceFolder.SternoClavicular.BackwardAxialRotation;
    AnyKinMeasure& AC = ...InterfaceFolder.AcromioClavicular.PosteriorTilt;
    Coef = {{1,-1}};
    OutDim = 1;
  };

  // Use a template to create the weight function, so
  // the weight values can be overridden by the user. 
  Template_AnyFunConst Weights (NUMBER_OF_ELEMENTS=..nDim) = {};
  WeightFun ={&Weights.Fun};
  #if (BM_ARM_SHOULDER_RHYTHM == _RHYTHM_SOFT_) | (BM_ARM_CLAVICULA_ROTATION_RHYTHM == _RHYTHM_SOFT_)
  CType= repmat(nDim,Soft);
  #endif

};
#endif



 #include "ScapulaConoideumDriver.any"
  

#if BM_ARM_SHOULDER_RHYTHM

  #include "ShoulderRhythm.any"

#endif


// Deprecated, Use the name HumeroUlnarJoint instead. Left here for backwards Compatibility.
AnyFolder &FE = HumeroUlnarJoint;


/// Deprecated. Please use the forearm rotation measure
/// in the interface folder. Left here for backwards compatibility. 
AnyKinMeasureOrg PS = {
  AnyKinRotational &Jnt = .ProximalRadioUlnarJoint.Orientation;
  MeasureOrganizer = {0};
};