This repository was archived by the owner on Jul 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleModel.any
More file actions
264 lines (235 loc) · 7.29 KB
/
ExampleModel.any
File metadata and controls
264 lines (235 loc) · 7.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// Example Model using the CAMERA template class with a small toy model.
//
// See the CameraClassTemplate for detailed usage of the camera class
#include "CameraClassTemplate.any"
Main = {
// This is a simple example of using the camera class to create videos.
VideoLookAtCamera MyCam (UP_DIRECTION = y, CREATE_GIF= 1) =
{
// The point the camera focus on
CameraLookAtPoint = Main.MyModel.Femur.Knee.r + {0, -0.1, 0};
// The vertical field of view in meters at the LookAtPoint
CameraFieldOfView = 1;
// The direction which the camera is placed
// (In global coordinates with respect to the LookAtPoint)
CameraDirection = {1, 1, -1};
VideoCodec = "libxvid";
// The background color used for the video
BackgroundColor = {1, 1, 1};
// Determines the speed of the video. Setting it to
// nStep/(tEnd-tStart) will make the video run in real time.
VideoInputFrameRate = 10;
// Override the default camera counter with the time step from the study.
// This ensures that we only save the images from the analysis.
// Note: The study must include (have a reference to) this camera template.
// Otherwise the counter will not update.
Counter = Main.MyStudy.iStep;
// The operations which should be included in the video.
Analysis = {
AnyOperation &ref = Main.MyStudy.Kinematics;
};
};
/////////////////////////////////////////////////////////////////////////////////////
///// The code below is a toy example model used to demonstrate Camera class /////
/////////////////////////////////////////////////////////////////////////////////////
AnyFolder MyModel = {
// Global Reference Frame
AnyFixedRefFrame GlobalRef = {
// Todo: Add points for grounding of the model here
}; // Global reference frame
AnySeg Femur = {
Mass = 5;
Jii = {1,0.04,1}*0.05;
AnyRefNode Hip = {
sRel = {0, 0.2, 0};
};
AnyRefNode Knee = {
sRel = {0, -0.3, 0};
ARel = RotMat(pi,y);
};
AnyRefNode QuadOri = {
sRel = {0.05, 0, 0};
};
AnyRefNode CondyleOri = {
sRel = {0, -0.27, 0};
ARel = RotMat(-20*pi/180,z);
AnyDrawRefFrame drw = {
ScaleXYZ = {1,1,1}*0.1;
RGB = {1,0,0};
};
AnyRefNode Focus1 = {
sRel = {0,0.03,0};
};
AnyRefNode Focus2 = {
sRel = {0,-0.03,0};
};
AnyDrawNodes drwn = {
RGB = {1,0,0};
ScaleXYZ = {1,1,1}*0.01;
};
};
AnyDrawSeg drw = {
Opacity = 0.5;
};
Axes0 = RotMat(pi/2,z);
};
AnySeg Tibia = {
r0 = {0.3, -0.25, 0};
Mass = 3;
Jii = {1,0.03,1}*0.03;
AnyRefNode Knee = {
sRel = {0, 0.18, 0};
ARel = RotMat(pi,y);
};
AnyRefNode Ankle = {
sRel = {0, -0.25, 0};
};
// AnyRefNode Patella1 = {
// sRel = .Knee.sRel + {0.07, 0.05, 0};
// };
AnyRefNode Patella2 = {
sRel = .Knee.sRel + {0.02, -0.06, 0};
};
AnyDrawSeg drw = {
Opacity = 0.5;
};
};
AnySeg Patella = {
r0 = {0.33, 0.0, 0};
Mass = 0.02;
Jii = {1,0.5,1}*0.00001;
AnyRefNode Knee = {
sRel = {-0.06, 0, 0};
};
AnyRefNode Lig = {
sRel = {0, -0.03, 0};
};
AnyRefNode Quad = {
sRel = {0, 0.025, 0};
};
AnyRefNode Surf1 = {
sRel = {-0.02, 0.02, 0};
};
AnyRefNode Surf2 = {
sRel = {-0.02, -0.02, 0};
};
AnyDrawSeg drw = {};
};
AnyRevoluteJoint Hip = {
AnyRefFrame &Ground = .GlobalRef;
AnyRefFrame &Femur = .Femur.Hip;
};
// AnyRevoluteJoint FemurPatella = {
// AnyRefFrame &Femur = .Femur.Knee;
// AnyRefFrame &Patella = .Patella.Knee;
// };
AnyKinEqSimpleDriver PatellaLigament = {
AnyKinPLine lin = {
AnyRefFrame &origin = ..Patella.Lig;
AnyRefFrame &insertion = ..Tibia.Patella2;
AnyDrawPLine drw = {
Thickness = 0.01;
RGB = {1,0,0};
};
};
DriverPos = {0.06};
DriverVel = {0};
};
AnyKinPLine EllipsDist1 = {
AnyRefFrame &f1 = Main.MyModel.Femur.CondyleOri.Focus1;
AnyRefFrame &f2 = Main.MyModel.Patella.Surf1;
AnyRefFrame &f3 = Main.MyModel.Femur.CondyleOri.Focus2;
AnyDrawPLine drw = {
Thickness = 0.005;
RGB = {0,0,1};
};
};
AnyKinPLine EllipsDist2 = {
AnyRefFrame &f1 = Main.MyModel.Femur.CondyleOri.Focus1;
AnyRefFrame &f2 = Main.MyModel.Patella.Surf2;
AnyRefFrame &f3 = Main.MyModel.Femur.CondyleOri.Focus2;
AnyDrawPLine drw = {
Thickness = 0.005;
RGB = {0,0,1};
};
};
// Constrain the patella to the xy-plane of the knee node.
AnyKinEq PatellaPlaner = {
AnyKinLinear lin1 = {
AnyRefFrame &knee = Main.MyModel.Femur.Knee;
AnyRefFrame &point = Main.MyModel.Patella.Knee;
Ref = 0;
};
AnyKinLinear lin2 = {
AnyRefFrame &knee = Main.MyModel.Femur.Knee;
AnyRefFrame &point = Main.MyModel.Patella.Lig;
Ref = 0;
};
AnyKinLinear lin3 = {
AnyRefFrame &knee = Main.MyModel.Femur.Knee;
AnyRefFrame &point = Main.MyModel.Patella.Quad;
Ref = 0;
};
MeasureOrganizer = {2,5,8};
};
AnyKinEqSimpleDriver PatellaFemur = {
AnyKinMeasure &L1 = Main.MyModel.EllipsDist1;
AnyKinMeasure &L2 = Main.MyModel.EllipsDist2;
DriverVel = {0,0};
DriverPos = {0.13, 0.13};
};
AnyKinEqSimpleDriver HipAngle = {
AnyKinMeasure &jnt = .Hip;
DriverPos = {pi/2};
DriverVel = {0};
};
AnyRevoluteJoint Knee = {
AnyRefFrame &Femur = .Femur.Knee;
AnyRefFrame &Tibia = .Tibia.Knee;
};
// AnyKinEqFourierDriver KneeAngle = {
// AnyKinMeasure &jnt = .Knee;
// DriverPos = {0};
// DriverVel = {pi/2};
// Reaction.Type ={Off};
// };
// AnyKinEqFourierDriver KneeAngle = {
// AnyKinMeasure &jnt = .Knee;
// Type = Sin;
// Freq = 0.5;
// A = {{0,90}}*pi/180;
// B = {{0,0}}*pi/180;
// Reaction.Type ={Off};
// };
AnyKinEqInterPolDriver KneeAngle = {
Type = Bspline ;
BsplineOrder =5;
T = 2*{0, 0.2, 0.4, 0.6, 0.8, 1.0,1.2};
Data = {{90.1,90, 30, 0, 30, 90,90.1}}*pi/180;
AnyKinMeasure &jnt = .Knee;
Reaction.Type ={Off};
};
AnyViaPointMuscle Quadriceps = {
AnyMuscleModel Model = {
F0 = 1000;
};
AnyRefFrame &origin = .Femur.QuadOri;
AnyRefFrame &insertion = .Patella.Quad;
AnyDrawMuscle drw = {};
};
}; // MyModel
// The study: Operations to be performed on the model
AnyBodyStudy MyStudy = {
AnyFolder &kneeref = .MyModel.Knee;
AnyFolder &Model = .MyModel;
Gravity = {0.0, -9.81, 0.0};
nStep = 50;
tStart = 0;
tEnd = 2.4;
AnyVar MomentArm = Main.MyModel.Quadriceps.LmtDot/(Main.MyModel.Knee.Vel[0]+1.0e-10);
// This reference is important for if the camera class use the iStep variable to set the
// frame counter.
AnyFolder &CameraReferece = Main.MyCam;
};
}; // Main
//#include "_CAMERA_.any"