Switch to side-by-side view

--- a
+++ b/Application/Examples/ExoskeletonConcept/ExoConcept_BoxLift.main.any
@@ -0,0 +1,178 @@
+#include "../libdef.any"
+/* ----------------------------------------------------------------------------------
+  This is an example of developing an exoskeleton concept. The example is based on
+  the webcast presented by Prof. John Rasmussen from Aalborg University on 28 Mar 2022.
+  <https://www.anybodytech.com/simulation-driven-conceptual-design-of-exoskeletons/>
+  
+  The model is structured to include the BVH_BoxLift model from the AMMR and then apply
+  the code for the exoskeleton concept. This was done to avoid duplicating the box lift
+  model in the AMMR. If you want to apply the exo concept to your own model, you just 
+  need to copy the code in the ExoConcept section to your own model.
+
+---------------------------------------------------------------------------------- */
+
+// ***************************** AnyMoCap ************************************
+// This section points to the BVH_BoxLift Model in the AMMR and allows you to
+// select the subject and trial folders.
+
+// Path to the BVH_BoxLift model in the AMMR. The path to the mocap models in AMMR 
+// generally follows the structure: <MocapModel>/<Subjects>/<S#>/<S#_T#>/Main.any
+// where # is a number. 
+// Please define here the path to the mocap model.
+#path ANYMOCAP_BVH_BOXLIFT "<ANYBODY_PATH_AMMR>/Application/MocapExamples/BVH_BoxLift/Subjects/"
+// Select Subject folder
+#define MOCAP_NAME_SUBJECTDIR "S01"
+// Select Trial folder suffix. 
+#define MOCAP_NAME_TRIALDIR "_T05"
+
+#define MOCAP_NAME_MAINFILEDIR MOCAP_NAME_SUBJECTDIR + MOCAP_NAME_TRIALDIR
+#path BVH_BOXLIFT_MAINFILEDIR "<ANYMOCAP_BVH_BOXLIFT>" + MOCAP_NAME_SUBJECTDIR +"/" +MOCAP_NAME_MAINFILEDIR 
+#include "<BVH_BOXLIFT_MAINFILEDIR>/Main.any"
+
+// ***************************** AnyMoCap ************************************
+// ***************************************************************************
+
+
+// **************************** ExoConcept ***********************************
+/*
+  The code below implements the different steps from the webcast. In case you 
+  want to apply this code to your own model, you can copy and paste the following
+  lines of code to your own model. 
+
+  In this example, two different exoskeleton concepts can be studied: Rotational
+  springs at the knees, and extensible rods crossing the knees, hips and lumbar 
+  spine. Both concepts are investigated by an idealized force and a spring force. 
+  Please see the webcast for a detailed explanation of the steps implemented in 
+  this model. Please note that the outputs from the model may not match exactly 
+  the outputs from the webcast due to possible differences in the box lifting 
+  model.
+  
+  There are four possibilities in this exoskeleton concept model:
+  1  Idealized force at knees.
+  2  Spring force at knees.
+  3  Idealized extensible rods crossing the knees, hips and lumbar spine.
+  4  Spring force-based extensible rods crossing the knees, hips and lumbar spine.
+  
+  The corresponding code can be included in the model by setting the #define 
+  EXO_CONCEPT statement to 1, 2, 3 or 4. Setting the statement to 0 (or any 
+  other value) will run the model without any assitive force.
+*/
+
+#ifndef EXO_CONCEPT
+#define EXO_CONCEPT 4
+#endif
+
+Main = {
+  EnvironmentModel = {
+    
+    #if EXO_CONCEPT == 1
+    // Idealized forces at the knee using AnyReacForces.
+    AnyReacForce Reacs = {
+      AnyKinMeasure &k1 = Main.HumanModel.BodyModel.Right.Leg.Jnt.Knee;
+      AnyKinMeasure &k2 = Main.HumanModel.BodyModel.Left.Leg.Jnt.Knee;
+    };
+    #endif
+
+    #if EXO_CONCEPT == 2
+    // Spring forces at the knee using position of the knee joints.
+    AnyVar k = -89.22;
+    AnyForce rSpring = {
+      AnyKinMeasure &k1 = Main.HumanModel.BodyModel.Right.Leg.Jnt.Knee;
+      F = .k*k1.Pos-24.73;
+    };
+    AnyForce lSpring = {
+      AnyKinMeasure &k1 = Main.HumanModel.BodyModel.Left.Leg.Jnt.Knee;
+      F = .k*k1.Pos-24.73;
+    };
+    #endif
+    
+    #if EXO_CONCEPT == 3
+    // Idealized forces at the extensible rods crossing the knees, hips and lumbar spine.
+    AnyReacForce Reacs = {
+      AnyKinPLine right = {
+        AnyRefFrame &p1 = Main.HumanModel.BodyModel.Trunk.SegmentsThorax.ThoraxSeg.rexo;
+        AnyRefFrame &p2 = Main.HumanModel.BodyModel.Right.Leg.Seg.Shank.exo;
+        AnyDrawPLine drw = {
+          Thickness = 0.01;
+          RGB = {1,0,0};
+        };
+      };
+      AnyKinPLine left = {
+        AnyRefFrame &p1 = Main.HumanModel.BodyModel.Trunk.SegmentsThorax.ThoraxSeg.lexo;
+        AnyRefFrame &p2 = Main.HumanModel.BodyModel.Left.Leg.Seg.Shank.exo;
+        AnyDrawPLine drw = {
+          Thickness = 0.01;
+          RGB = {1,0,0};
+        };
+      };
+    };
+    #endif
+
+    #if EXO_CONCEPT == 4
+    // Spring forces at the extensible rods crossing the knees, hips and lumbar spine.
+    AnyForce Springs = {
+      AnyKinPLine right = {
+        AnyRefFrame &p1 = Main.HumanModel.BodyModel.Trunk.SegmentsThorax.ThoraxSeg.rexo;
+        AnyRefFrame &p2 = Main.HumanModel.BodyModel.Right.Leg.Seg.Shank.exo;
+        AnyDrawPLine drw = {
+          Thickness = 0.01;
+          RGB = {1,0,0};
+        };
+      };
+      AnyKinPLine left = {
+        AnyRefFrame &p1 = Main.HumanModel.BodyModel.Trunk.SegmentsThorax.ThoraxSeg.lexo;
+        AnyRefFrame &p2 = Main.HumanModel.BodyModel.Left.Leg.Seg.Shank.exo;
+        AnyDrawPLine drw = {
+          Thickness = 0.01;
+          RGB = {1,0,0};
+        };
+      };
+      AnyVar k = 1000.0;
+      AnyVar L0 = 1.35;
+      F = k*{L0-right.Pos[0], L0-left.Pos[0]};
+    };
+    #endif
+
+  }; // EnvironmentModel
+  
+  #if (EXO_CONCEPT == 3) | (EXO_CONCEPT == 4)
+  // Create reference nodes for extensible rods if EXO_CONCEPT is 3 or 4
+  Main.HumanModel.BodyModel.Right.Leg.Seg.Shank = {
+    AnyRefNode exo = {
+      sRel = {0.014, 0.057, 0.054};
+      AnyDrawNode drw = {
+        RGB = {1,0,0};
+      };
+    };  
+  };
+  Main.HumanModel.BodyModel.Trunk.SegmentsThorax.ThoraxSeg = {
+    AnyRefNode rexo = {
+      sRel = {0.091, 0.260, 0.214};
+      AnyDrawNode drw = {
+        RGB = {1,0,0};
+      };
+    };
+  };
+  
+  Main.HumanModel.BodyModel.Left.Leg.Seg.Shank = {
+    AnyRefNode exo = {
+      sRel = {0.014, 0.057, -0.054};
+      AnyDrawNode drw = {
+        RGB = {1,0,0};
+      };
+    };  
+  };
+  Main.HumanModel.BodyModel.Trunk.SegmentsThorax.ThoraxSeg = {
+    AnyRefNode lexo = {
+      sRel = {0.091, 0.260, -0.214};
+      AnyDrawNode drw = {
+        RGB = {1,0,0};
+      };
+    };
+  };  
+  #endif
+
+}; // Main
+
+// **************************** ExoConcept ***********************************
+// ***************************************************************************
\ No newline at end of file