Switch to side-by-side view

--- a
+++ b/Application/Examples/StandingLift/Model/JointsAndDrivers.any
@@ -0,0 +1,497 @@
+/**    Drivers for a box lift model: This is like the standing model, except
+
+- There is a box present in the model (+ 6 dofs)
+- The box cannot rotate about x, y and z (- 3 dofs)
+- The box is driven in 3 spatial coords (-3 dofs)
+- The hands are now connected to the box by spherical jnts (-6 dofs)
+- GH rotation is no longer driven (+ 2 dofs)
+- GH abduction is no longer driven (+ 2 dofs)
+- GH Flextion/extension is no longer drven (+ 2 dofs)
+- Elbow flexion/extension is no longer driven (+2 dofs)
+- Elbow lateral position is driven (-2 dofs)
+
+John Rasmussen, March 10, 2005.
+*/
+AnyFolder Joints = {
+  
+  
+  AnyKinEqSimpleDriver RHBoxDriver = {
+    AnyRevoluteJoint RHBox = {
+      AnyRefNode &Box = Main.Model.EnvironmentModel.Box.Right;
+      AnySeg &Hand = ....BodyModel.Right.ShoulderArm.Seg.Glove;
+      Axis = z;
+      Constraints.Reaction.Type={Off,Off,Off,Off,Off};
+    };
+    DriverPos = {-15}*pi/180;
+    DriverVel = {0};
+    Reaction.Type = {Off};
+    
+  };
+  AnyKinEqSimpleDriver LHBoxDriver = {
+    AnyRevoluteJoint LHBox = {
+      AnyRefNode &Box = Main.Model.EnvironmentModel.Box.Left;
+      AnySeg &Hand = Main.Model.BodyModel.Left.ShoulderArm.Seg.Glove;
+      Axis = z;
+      Constraints.Reaction.Type={Off,Off,Off,Off,Off};
+    };
+    DriverPos = {-15}*pi/180;
+    DriverVel = {0};
+    Reaction.Type = {Off};
+  };
+  
+  AnyReacForce RHBoxRot ={
+    AnyKinRotational Rot = {
+      AnyRefNode &Box = Main.Model.EnvironmentModel.Box.Right;
+      AnySeg &Hand = Main.Model.BodyModel.Right.ShoulderArm.Seg.Glove;
+      Type=RotVector;  };
+  };
+  
+  AnyReacForce LHBoxRot={
+    AnyKinRotational Rot = {
+      AnyRefNode &Box = Main.Model.EnvironmentModel.Box.Left;
+      AnySeg &Hand = Main.Model.BodyModel.Left.ShoulderArm.Seg.Glove;
+      Type=RotVector;
+      
+    };
+  };
+  
+  
+  AnyVar FrictionStrength=200;
+  AnyVar Strength =4000;
+  
+  AnyFolder HandSupportLeft = {
+    AnyRefNode &StartNode = Main.Model.EnvironmentModel.Box.Left2;
+    AnySeg &EndNode = Main.Model.BodyModel.Left.ShoulderArm.Seg.Glove;    //The terms push and pull are determined wrt. the coordinate system of the StartNode!
+    
+    AnyVector StrengthOfReactionsLin = {.FrictionStrength,.FrictionStrength,.Strength,.FrictionStrength,.FrictionStrength,.FrictionStrength}; //List of strengths for the linear muscles
+    AnyFolder &DrawRef=Main.DrawSettings;
+    AnyVar ScaleFactor =0.5;
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/XPush.any"
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/XPull.any"
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/YPush.any"
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/YPull.any"
+    //#include "<ANYBODY_PATH_MODELUTILS>/Reactions/ZPush.any" 
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/ZPull.any" 
+    
+  };
+  
+  AnyFolder HandSupportRight = {
+    AnyRefNode &StartNode = Main.Model.EnvironmentModel.Box.Right2;
+    
+    AnySeg &EndNode = Main.Model.BodyModel.Right.ShoulderArm.Seg.Glove;    //The terms push and pull are determined wrt. the coordinate system of the StartNode!
+    
+    AnyVector StrengthOfReactionsLin = {.FrictionStrength,.FrictionStrength,.Strength,.FrictionStrength,.FrictionStrength,.FrictionStrength}; //List of strengths for the linear muscles
+    AnyFolder &DrawRef=Main.DrawSettings;
+    AnyVar ScaleFactor =0.5;
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/XPush.any"
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/XPull.any"
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/YPush.any"
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/YPull.any"
+    #include "<ANYBODY_PATH_MODELUTILS>/Reactions/ZPush.any" 
+    //#include "<ANYBODY_PATH_MODELUTILS>/Reactions/ZPull.any" 
+    
+  };
+};
+
+AnyFolder Drivers = {
+  
+  // Aliases for convenient referencing
+  AnyFolder &JntPos=..Mannequin.Posture;  
+  AnyFolder &JntVel=..Mannequin.PostureVel;  
+  AnyFolder &Thorax = ..BodyModel.Trunk.SegmentsThorax.ThoraxSeg;
+  AnyFolder &LegR = ..BodyModel.Right.Leg;
+  AnyFolder &LegL = ..BodyModel.Left.Leg;
+  AnyFolder &RefHM = Main.Model.BodyModel;
+  AnyFolder &ref=Main.Model.BodyModel.Trunk;
+  
+  
+  
+  AnyKinEqSimpleDriver BoxRot = {
+    AnyKinRotational Rot = {
+      Type = RotAxesAngles;
+      AnyFixedRefFrame &ground = Main.Model.EnvironmentModel.GlobalRef;
+      AnySeg &box = Main.Model.EnvironmentModel.Box;
+    };
+    MeasureOrganizer = {0,1,2};
+    DriverPos = {0,0,0};
+    DriverVel = {0,0,0};
+    Reaction.Type = {Off,Off,Off};
+  };
+  
+  AnyKinEqInterPolDriver Box = {
+    AnyKinLinear pos = {
+      AnyFixedRefFrame &ground = Main.Model.EnvironmentModel.GlobalRef;
+      AnySeg &box = Main.Model.EnvironmentModel.Box;
+    };
+    Type = Bspline;
+    T = Main.Study.tEnd*{0,1,2,3}/2.99;
+    Data = {
+      { 0.35, 0.35, 0.35, 0.35},
+      { 1.2,  1.25, 1.25, 1.25},
+      {-0.1, -0.0, 0.0, 0.1}
+    };
+    Reaction.Type = {Off,Off,Off};
+  };
+  
+  
+  
+  // Position the Ankles right above the z axis
+  AnyKinEqSimpleDriver RAnkleX = {
+    AnyKinLinear AnklePos = {
+      AnyFixedRefFrame &Ground = Main.Model.EnvironmentModel.GlobalRef;
+      #if BM_LEG_MODEL == _LEG_MODEL_LEG_
+        AnyRefNode &Ankle = ..LegR.Seg.Foot.AnkleJoint;
+      #else
+        AnyRefNode &Ankle = ..LegR.Seg.Talus.AnkleJoint;      
+      #endif
+    };
+    MeasureOrganizer = {0};  // Only the x coordinate
+    DriverPos = {0.0};
+    DriverVel = {0.0};
+    Reaction.Type = {Off};
+  };
+  
+  AnyKinEqSimpleDriver LAnkleX ={
+    AnyKinLinear AnklePos = {
+      AnyFixedRefFrame &Ground = Main.Model.EnvironmentModel.GlobalRef;
+      #if BM_LEG_MODEL == _LEG_MODEL_LEG_
+        AnyRefNode &Ankle = ..LegL.Seg.Foot.AnkleJoint;
+      #else
+        AnyRefNode &Ankle = ..LegL.Seg.Talus.AnkleJoint;      
+      #endif
+    };
+    MeasureOrganizer = {0};  // Only the x coordinate
+    DriverPos = {0.0};
+    DriverVel = {0.0};
+    Reaction.Type = {Off};
+  };
+  
+  //Constrain the collective CoM to be right above the GlobalRef
+  AnyKinEqSimpleDriver CoMDriver = {
+    AnyKinCoM CoM = {
+      AnyFolder &Body = Main.Model.BodyModel;
+      AnyFolder &Environment = Main.Model.EnvironmentModel;      
+    };
+    MeasureOrganizer = {0,2};  // Only the x and z directions
+    DriverPos = {0.1, -0.05};
+    DriverVel = {0.0, 0.1};
+    Reaction.Type = {Off,Off};
+  };  
+  
+  //Constrain the feet to be symmetrical about the xy plane
+  AnyKinEqSimpleDriver FeetXDriver = {
+    AnyKinCoM CoM = {
+      AnySeg &rf = Main.Model.BodyModel.Right.Leg.Seg.Foot;
+      AnySeg &ff = Main.Model.BodyModel.Left.Leg.Seg.Foot;
+    };
+    MeasureOrganizer = {2};  // Only the z direction
+    DriverPos = {0};
+    DriverVel = {0};
+    Reaction.Type = {Off};  // Carried by friction muscles.
+  };
+  
+  
+  // ************************************
+  // Drivers for the spine
+  // ************************************
+  
+  //Neck driver 
+  AnyKinEqSimpleDriver NeckJntDriver = {
+    AnyKinMeasure& lb = ...BodyModel.Interface.Trunk.SkullThoraxLateralBending;
+    AnyKinMeasure& ar = ...BodyModel.Interface.Trunk.SkullThoraxRotation;
+    AnyKinMeasure& fe = ...BodyModel.Interface.Trunk.SkullThoraxFlexion;
+    DriverPos = pi/180*{.JntPos.NeckLateralBending, .JntPos.NeckRotation, -1*.JntPos.NeckExtension};
+    DriverVel = pi/180*{.JntVel.NeckLateralBending, .JntVel.NeckRotation, -1*.JntVel.NeckExtension};
+    Reaction.Type = {Off, Off, Off};
+  };
+  
+  //Thorax pelvis rotation driver
+  AnyKinEqSimpleDriver PostureDriver ={
+    //AnyKinMeasure& Ref2 = ...BodyModel.Interface.Trunk.PelvisThoraxLateralBending;        
+    AnyKinMeasure& Ref3 = ...BodyModel.Interface.Trunk.PelvisThoraxRotation;   
+    AnyKinMeasure& Ref1 = ...BodyModel.Interface.Trunk.PelvisThoraxExtension;
+    
+    DriverPos = pi/180*{
+      //    .JntPos.PelvisThoraxLateralBending,
+      .JntPos.PelvisThoraxRotation,
+      .JntPos.PelvisThoraxExtension
+    };
+    DriverVel = pi/180*{
+      //JntVel.PelvisThoraxLateralBending,
+      .JntVel.PelvisThoraxRotation,
+      .JntVel.PelvisThoraxExtension
+    };
+    Reaction.Type = {Off,Off};  
+  };  
+  
+  
+  // ************************************
+  // Drivers for the right arm
+  // ************************************
+  
+  
+  //Sterno clavicular joint driver
+  AnyKinEqSimpleDriver SCDriverRight ={
+    AnyKinMeasure& ref1 =...BodyModel.Interface.Right.SternoClavicularProtraction;
+    AnyKinMeasure& ref2 =...BodyModel.Interface.Right.SternoClavicularElevation;
+    DriverPos = pi/180*{
+      .JntPos.Right.SternoClavicularProtraction,
+      .JntPos.Right.SternoClavicularElevation
+    };
+    DriverVel = {
+      .JntVel.Right.SternoClavicularProtraction,
+      .JntVel.Right.SternoClavicularElevation
+    };
+    Reaction.Type={Off,Off};
+  };
+  
+  
+  //Wrist driver 
+  AnyKinEqSimpleDriver WristDriverRight ={
+    // AnyKinMeasure& ref1 =...BodyModel.Interface.Right.WristFlexion;
+    AnyKinMeasure& ref2 =...BodyModel.Interface.Right.WristAbduction;
+    DriverPos = pi/180*{         .JntPos.Right.WristAbduction       };
+    DriverVel = pi/180*{         .JntVel.Right.WristAbduction       };
+    Reaction.Type={Off};
+  };
+  
+  // ************************************
+  // Drivers for the left arm
+  // ************************************
+  
+  //Sterno clavicular joint driver
+  AnyKinEqSimpleDriver SCDriverLeft ={
+    AnyKinMeasure& ref1 =...BodyModel.Interface.Left.SternoClavicularProtraction;
+    AnyKinMeasure& ref2 =...BodyModel.Interface.Left.SternoClavicularElevation;
+    
+    DriverPos = pi/180*{
+      .JntPos.Left.SternoClavicularProtraction,
+      .JntPos.Left.SternoClavicularElevation
+    };
+    
+    DriverVel = pi/180*{
+      .JntVel.Left.SternoClavicularProtraction,
+      .JntVel.Left.SternoClavicularElevation
+    };
+    
+    Reaction.Type={Off,Off};
+  };
+  
+  
+  
+  
+  //Wrist driver
+  AnyKinEqSimpleDriver WristDriverLeft ={
+    //  AnyKinMeasure& ref1 =...BodyModel.Interface.Left.WristFlexion;
+    AnyKinMeasure& ref2 =...BodyModel.Interface.Left.WristAbduction;
+    DriverPos = pi/180*{
+      //  .JntPos.Left.WristFlexion,
+      .JntPos.Left.WristAbduction
+    };
+    
+    DriverVel = pi/180*{
+      //.JntVel.Left.WristFlexion,
+      .JntVel.Left.WristAbduction
+    };
+    Reaction.Type={Off};
+  };
+  
+  
+  
+  // ************************************
+  // Drivers for the right leg
+  // ************************************
+  
+  //Hip driver 
+  AnyKinEqSimpleDriver HipDriverRight={
+    AnyKinMeasure& ref1 =...BodyModel.Interface.Right.HipFlexion;
+    AnyKinMeasure& ref2 =...BodyModel.Interface.Right.HipExternalRotation;
+    AnyKinMeasure& ref3 =...BodyModel.Interface.Right.HipAbduction;
+    DriverPos= pi/180*{
+      .JntPos.Right.HipFlexion,
+      .JntPos.Right.HipExternalRotation,
+      .JntPos.Right.HipAbduction
+    };    
+    DriverVel = pi/180*{
+      .JntVel.Right.HipFlexion,
+      .JntVel.Right.HipExternalRotation,
+      .JntVel.Right.HipAbduction
+    };    
+    Reaction.Type={Off,Off,Off};
+    
+  };
+  
+  //Knee driver
+  AnyKinEqSimpleDriver KneeDriverRight={
+    AnyKinMeasureOrg  &Knee = ...BodyModel.Interface.Right.KneeFlexion;
+    DriverPos=pi/180*{.JntPos.Right.KneeFlexion};  
+    DriverVel = pi/180*{.JntVel.Right.KneeFlexion};  
+    Reaction.Type={Off};
+  };
+  
+  //Ankle driver
+  AnyKinEqSimpleDriver AnkleDriverRight={
+    #if BM_LEG_MODEL == _LEG_MODEL_LEG_
+      AnyKinMeasure& ref2=...BodyModel.Interface.Right.AnkleEversion;
+    #else
+      AnyKinMeasure& ref2=...BodyModel.Interface.Right.SubTalarEversion;
+    #endif
+    DriverPos = pi/180*{      .JntPos.Right.SubTalarEversion    };  
+    DriverVel=pi/180*{      .JntVel.Right.SubTalarEversion    };  
+    Reaction.Type={Off};
+  };
+  
+  
+  
+  
+  // ************************************
+  // Drivers for the left leg
+  // ************************************
+  
+  //Hip driver 
+  AnyKinEqSimpleDriver HipDriverLeft={
+    AnyKinMeasure& ref1 =...BodyModel.Interface.Left.HipFlexion;
+    AnyKinMeasure& ref2 =...BodyModel.Interface.Left.HipExternalRotation;
+    AnyKinMeasure& ref3 =...BodyModel.Interface.Left.HipAbduction;
+    DriverPos= pi/180*{
+      .JntPos.Left.HipFlexion,
+      .JntPos.Left.HipExternalRotation,
+      .JntPos.Left.HipAbduction
+    };    
+    DriverVel = pi/180*{
+      .JntVel.Left.HipFlexion,
+      .JntVel.Left.HipExternalRotation,
+      .JntVel.Left.HipAbduction
+    };    
+    Reaction.Type={Off,Off,Off};
+    
+  };
+  
+  //Knee driver
+  AnyKinEqSimpleDriver KneeDriverLeft={
+    AnyKinMeasureOrg  &Knee = ...BodyModel.Interface.Left.KneeFlexion;
+    DriverPos=pi/180*{.JntPos.Left.KneeFlexion};  
+    DriverVel = pi/180*{.JntVel.Left.KneeFlexion};  
+    Reaction.Type={Off};
+  };
+  
+  //Ankle driver
+  AnyKinEqSimpleDriver AnkleDriverLeft={
+    #if BM_LEG_MODEL == _LEG_MODEL_LEG_
+      AnyKinMeasure& ref2=...BodyModel.Interface.Left.AnkleEversion;
+    #else
+      AnyKinMeasure& ref2=...BodyModel.Interface.Left.SubTalarEversion;
+    #endif
+    
+    DriverPos = pi/180*{      .JntPos.Left.SubTalarEversion    };  
+    DriverVel=pi/180*{      .JntVel.Left.SubTalarEversion    };  
+    Reaction.Type={Off};
+  };
+  
+  
+  
+  // Place the right toe and heel on the ground
+  AnyKinEq RToeGroundConstraint ={
+    AnyKinLinear ToePos = {
+      AnyFixedRefFrame &Ground = Main.Model.EnvironmentModel.GlobalRef;
+      AnyRefNode &Ball = Main.Model.BodyModel.Right.Leg.Seg.Foot.ToeJoint;
+    };
+    MeasureOrganizer = {1};  // Only the y coordinate
+    Reaction.Type={Off};
+  };
+  
+  AnyKinEqSimpleDriver RHeelGroundConstraint ={
+    AnyKinLinear HeelPos = {
+      AnyFixedRefFrame &Ground = Main.Model.EnvironmentModel.GlobalRef;
+      AnyRefNode &Ball = Main.Model.BodyModel.Right.Leg.Seg.Foot.HeelJoint;
+    };
+    MeasureOrganizer = {1};  // Only the y coordinate
+    DriverPos = {0.0};
+    DriverVel = {0.0};
+    Reaction.Type = {Off};   // Provide ground reaction forces
+  };
+  
+  // Place the left toe and heel on the ground
+  AnyKinEq LToeGroundConstraint ={
+    AnyKinLinear ToePos = {
+      AnyFixedRefFrame &Ground = Main.Model.EnvironmentModel.GlobalRef;
+      AnyRefNode &Ball = Main.Model.BodyModel.Left.Leg.Seg.Foot.ToeJoint;
+    };
+    MeasureOrganizer = {1};  // Only the y coordinate
+    Reaction.Type={Off};
+  };
+  
+  AnyKinEqSimpleDriver LHeelGroundConstraint ={
+    AnyKinLinear HeelPos = {
+      AnyFixedRefFrame &Ground = Main.Model.EnvironmentModel.GlobalRef;
+      AnyRefNode &Ball = Main.Model.BodyModel.Left.Leg.Seg.Foot.HeelJoint;
+    };
+    MeasureOrganizer = {1};  // Only the y coordinate
+    DriverPos = {0.0};
+    DriverVel =  {0.0};
+    Reaction.Type = {Off};  // Do not Provide ground reaction
+  };  
+  
+  
+  
+  AnyFolder ConditionalContact={
+    
+    /*
+    ConditionalContactFootPlaneClass (
+    BaseObject = //Object which delivers the forces
+    Foot = //Reference to the foot segment where 3 forces are applied 
+    DisplayTriggerVolume = //Draw the cylinder around the Base node where the contact is active
+    DisplayTargetNode = //Draw the Target node
+    ) = {
+    UserDefinedLimitLow = //low limit for the strength measure function, if the distance measured along Direction[0] is below this val. the strength will be zero (negative)
+    UserDefinedLimitHigh = //high limit for the strength measure function, if the distance measured along Direction[0] is above this val. the strength will be zero
+    UserDefinedRadiusLimit = //high limit for the strength measure function, if the radius measured along the plane with Direction[0] as normal is above this val. the strength will be zero
+    Strength = //strength of muscles
+    StaticFrictionCoefficient = //Friction coefficient
+    NormalDirection = //The axis (X, Y or Z) corresponding to the normal direction
+    FrictionDirection1 = //The axis (X, Y or Z) corresponding to the first friction direction
+    FrictionDirection2 = //The axis (X, Y or Z) corresponding to the second friction direction
+    };
+    */
+    
+    ConditionalContactFootPlaneClass LeftFootSupport (
+    BaseObject = Main.Model.EnvironmentModel.GlobalRef,
+    Foot = ..LegL.Seg.Foot,
+    DisplayTriggerVolume = 1,
+    DisplayTargetNode =1
+    ) = {
+      UserDefinedLimitLow = -0.05;
+      UserDefinedLimitHigh = 0.05;
+      UserDefinedRadiusLimit = 0.4;
+      Strength = 2000;
+      StaticFrictionCoefficient = 0.8;
+      NormalDirection = Y;
+      FrictionDirection1 = X;
+      FrictionDirection2 = Z;
+    };
+    
+    
+    ConditionalContactFootPlaneClass RightFootSupport (
+    BaseObject = Main.Model.EnvironmentModel.GlobalRef,
+    Foot = ..LegR.Seg.Foot,
+    DisplayTriggerVolume = 0,
+    DisplayTargetNode =1
+    ) = {
+      UserDefinedLimitLow = -0.05;
+      UserDefinedLimitHigh = 0.05;
+      UserDefinedRadiusLimit = 0.4;
+      Strength = 2000;
+      StaticFrictionCoefficient = 0.8;
+      NormalDirection = Y;
+      FrictionDirection1 = X;
+      FrictionDirection2 = Z;
+    };
+    
+  };   
+  
+  
+  
+  
+  
+};//Drivers
+