|
| 1 | +// This model is for the FDK tutorial. It is the starting point for the |
| 2 | +//definition of a simple knee with force-dependent kinematics features. |
| 3 | + |
| 4 | +Main = { |
| 5 | + |
| 6 | + /// The actual body model goes in this folder |
| 7 | + AnyFolder MyModel = { |
| 8 | + |
| 9 | + // Global Reference Frame |
| 10 | + AnyFixedRefFrame GlobalRef = { |
| 11 | + }; // Global reference frame |
| 12 | + |
| 13 | + // Definition of the thigh segment |
| 14 | + AnySeg Thigh = { |
| 15 | + r0 = {0.4, 0, 0}; |
| 16 | + Axes0 = RotMat(pi/2,z); |
| 17 | + Mass = 5; |
| 18 | + Jii = {0.3, 0.01, 0.3}*0.7; |
| 19 | + |
| 20 | + // This is the center of the nominal knee joint. Notice that |
| 21 | + // the actual knee center will vary when we use FDK. |
| 22 | + AnyRefNode KneeCenter = { |
| 23 | + sRel = {-0.03, -0.4, 0.0}; |
| 24 | + |
| 25 | + // Define a cylinder representing the femoral condyle. The quadriceps |
| 26 | + // will wrap about this cylinder. |
| 27 | + AnyRefNode SurfCenter = { |
| 28 | + sRel = {0,0,-0.05}; |
| 29 | + AnySurfCylinder Condyle = { |
| 30 | + Radius = 0.06; |
| 31 | + Length = 0.1; |
| 32 | + AnyDrawParamSurf drw = { |
| 33 | + RGB = {0, 0, 1}; |
| 34 | + }; |
| 35 | + }; |
| 36 | + }; |
| 37 | + }; |
| 38 | + AnyRefNode HipCenter = { |
| 39 | + sRel = {0.0, 0.4, 0.0}; |
| 40 | + }; |
| 41 | + |
| 42 | + // Origin of the quadriceps muscle. |
| 43 | + AnyRefNode Quadriceps = { |
| 44 | + sRel = {0.06, 0.0, 0.0}; |
| 45 | + }; |
| 46 | + AnyDrawSeg drw ={ |
| 47 | + Opacity = 0.5; |
| 48 | + }; |
| 49 | + }; |
| 50 | + |
| 51 | + AnySeg Shank = { |
| 52 | + r0 = {0.8, -0.4, 0.0}; |
| 53 | + Mass = 4; |
| 54 | + Jii = {0.4, 0.01, 0.4}*0.4; |
| 55 | + AnyDrawSeg drw ={ |
| 56 | + Opacity = 0.5; |
| 57 | + RGB = {1,0,0}; |
| 58 | + }; |
| 59 | + |
| 60 | + AnyRefNode KneeCenter = { |
| 61 | + sRel = {0.0, 0.4, 0.0}; |
| 62 | + }; |
| 63 | + AnyRefNode Quadriceps = { |
| 64 | + sRel={0.05, 0.3, 0.0}; |
| 65 | + }; |
| 66 | + }; |
| 67 | + |
| 68 | + // Hip joint between the thigh and ground |
| 69 | + AnyRevoluteJoint Hip = { |
| 70 | + AnyRefFrame &ref1 = .GlobalRef; |
| 71 | + AnyRefFrame &ref2 = .Thigh.HipCenter; |
| 72 | + }; |
| 73 | + |
| 74 | + // Fix the hip joint at a constant angle |
| 75 | + AnyKinEqSimpleDriver HipAngle = { |
| 76 | + AnyRevoluteJoint &Hip = .Hip; |
| 77 | + DriverPos = {pi/2}; |
| 78 | + DriverVel = {0}; |
| 79 | + }; |
| 80 | + |
| 81 | + // Knee joint. Notice that this is only going to be the nominal joint. |
| 82 | + // The actual position of the knee joint center will depend on the forces |
| 83 | + // acting upon it. Notice that we list the shank before the thigh. This |
| 84 | + // defines the knee joint in the shank coordinate system and we can |
| 85 | + // relate the reaction forces to the directon of the tibial plateau. |
| 86 | +//# BEGIN SNIPPET 1 |
| 87 | +AnyRevoluteJoint KneeJoint = { |
| 88 | + AnyRefFrame &Shank = .Shank.KneeCenter; |
| 89 | + AnyRefFrame &Thigh = .Thigh.KneeCenter; |
| 90 | + |
| 91 | + // Prepare the joint for FDK: Define the reaction types in x and y |
| 92 | + // directions to be FDK-dependent. These reaction forces must then |
| 93 | + // be switched off and provided by some elastic element that we |
| 94 | + // define explicitly below. |
| 95 | + Constraints = { |
| 96 | + CType = {ForceDep, ForceDep, Hard, Hard, Hard}; |
| 97 | + Reaction.Type={Off,Off,On,On,On}; |
| 98 | + }; |
| 99 | +}; |
| 100 | +§// Define springs in the knee, simulating the effect of cartilage |
| 101 | +// and ligaments. |
| 102 | +AnyForce KneeStiffness = { |
| 103 | + AnyKinLinear &lin = Main.MyModel.KneeJoint.Linear; |
| 104 | + F = {-1000*lin.Pos[0], -5000*lin.Pos[1], 0}; |
| 105 | +};§ |
| 106 | + |
| 107 | +//# END SNIPPET 1 |
| 108 | + |
| 109 | + // Knee driver- just a simple knee extension. |
| 110 | + AnyKinEqSimpleDriver KneeDriver = { |
| 111 | + DriverPos = {pi/2}; |
| 112 | + DriverVel = {-pi/30}; |
| 113 | + AnyRevoluteJoint &KneeJoint = .KneeJoint; |
| 114 | + Reaction.Type={Off}; // The muscles must carry this movement |
| 115 | + }; |
| 116 | + |
| 117 | + // Muscle |
| 118 | + AnyMuscleShortestPath Quadriceps = { |
| 119 | + AnyMuscleModel MusMdl = { |
| 120 | + F0 = 6000; |
| 121 | + }; |
| 122 | + AnyRefFrame &org = .Thigh.Quadriceps; |
| 123 | + AnyParamSurf &wrap = .Thigh.KneeCenter.SurfCenter.Condyle; |
| 124 | + AnyRefFrame &ins = .Shank.Quadriceps; |
| 125 | + SPLine = { |
| 126 | + StringMesh = 50; |
| 127 | + InitWrapPosVectors = {{0.1, 0.1, 0},{0.1, 0.2, 0}}; |
| 128 | + }; |
| 129 | + AnyDrawMuscle drw = { |
| 130 | + Bulging = 1; |
| 131 | + MaxStress = 2500; |
| 132 | + }; |
| 133 | + }; |
| 134 | + }; // MyModel |
| 135 | + |
| 136 | +//# BEGIN SNIPPET 2 |
| 137 | +AnyBodyStudy Study = { |
| 138 | + AnyFolder &Model = .MyModel; |
| 139 | + Gravity = {0.0, -9.81, 0.0}; |
| 140 | + tStart = 1; |
| 141 | + tEnd = 10; |
| 142 | + nStep = 100; |
| 143 | + §InverseDynamics.ForceDepKinOnOff=On;§ |
| 144 | +}; |
| 145 | +//# END SNIPPET 2 |
| 146 | + |
| 147 | +}; // Main |
| 148 | + |
| 149 | + |
0 commit comments