Skip to content

Commit 2515d12

Browse files
JacobAdamsenJacob Hilmar Adamsen
andauthored
Update of Force-Dependent Kinematics tutorial (#48)
Co-authored-by: Jacob Hilmar Adamsen <[email protected]>
1 parent 7d42d8c commit 2515d12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+219789
-395
lines changed

A_Getting_started_anyscript/lesson3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
::: {rst-class} break
22
:::
33

4+
(How_to_write_AnyScript_L3)=
45
# Lesson 3: Connecting Segments by Joints
56

67
:::{note}

ForceDependentKinematics/Downloads/DemoSimpleKnee2.any

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Main = {
6161
sRel = {0.0, 0.4, 0.0};
6262
};
6363
AnyRefNode Quadriceps = {
64-
sRel={0.00, 0.3, 0.0};
64+
sRel={0.05, 0.3, 0.0};
6565
};
6666
};
6767

ForceDependentKinematics/Downloads/DemoSimpleKnee3.any

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Main = {
4141

4242
// Origin of the quadriceps muscle.
4343
AnyRefNode Quadriceps = {
44-
sRel = {0.00, 0.3, 0.0};
44+
sRel = {0.06, 0.0, 0.0};
4545
};
4646
AnyDrawSeg drw ={
4747
Opacity = 0.5;

ForceDependentKinematics/Downloads/DemoSimpleKnee4.any

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Main = {
5353

5454
// Origin of the quadriceps muscle.
5555
AnyRefNode Quadriceps = {
56-
sRel = {0.00, 0.3, 0.0};
56+
sRel = {0.06, 0.0, 0.0};
5757
};
5858
AnyDrawSeg drw ={
5959
Opacity = 0.5;
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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+
//# END SNIPPET 1
101+
102+
// Knee driver- just a simple knee extension.
103+
AnyKinEqSimpleDriver KneeDriver = {
104+
DriverPos = {pi/2};
105+
DriverVel = {-pi/30};
106+
AnyRevoluteJoint &KneeJoint = .KneeJoint;
107+
Reaction.Type={Off}; // The muscles must carry this movement
108+
};
109+
110+
// Muscle
111+
AnyMuscleShortestPath Quadriceps = {
112+
AnyMuscleModel MusMdl = {
113+
F0 = 6000;
114+
};
115+
AnyRefFrame &org = .Thigh.Quadriceps;
116+
AnyParamSurf &wrap = .Thigh.KneeCenter.SurfCenter.Condyle;
117+
AnyRefFrame &ins = .Shank.Quadriceps;
118+
SPLine = {
119+
StringMesh = 50;
120+
InitWrapPosVectors = {{0.1, 0.1, 0},{0.1, 0.2, 0}};
121+
};
122+
AnyDrawMuscle drw = {
123+
Bulging = 1;
124+
MaxStress = 2500;
125+
};
126+
};
127+
}; // MyModel
128+
129+
AnyBodyStudy Study = {
130+
AnyFolder &Model = .MyModel;
131+
Gravity = {0.0, -9.81, 0.0};
132+
tStart = 1;
133+
tEnd = 10;
134+
nStep = 100;
135+
};
136+
137+
}; // Main
138+
139+
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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

Comments
 (0)