|
a |
|
b/Tools/GRFPrediction/ContactSurfaceDistanceAndVelocityDepLinPush.any |
|
|
1 |
AnyFolder Push ={ |
|
|
2 |
|
|
|
3 |
AnyKinLinear LinS={ |
|
|
4 |
Ref=0; |
|
|
5 |
AnyRefFrame &BaseObject=..BaseObject; |
|
|
6 |
AnyRefFrame &StrengthObject=..StrengthObject; |
|
|
7 |
}; |
|
|
8 |
|
|
|
9 |
LinS.StrengthObject ={ |
|
|
10 |
AnyDrawSphere DrwSphere ={ |
|
|
11 |
ScaleXYZ =0.01*{1,1,1}; |
|
|
12 |
Opacity =...ContactStrengthSmoothed/....Strength; |
|
|
13 |
}; |
|
|
14 |
}; |
|
|
15 |
|
|
|
16 |
AnyKinMeasureOrg LinMeasureOrg0 ={ |
|
|
17 |
AnyKinLinear &ref=.LinS; |
|
|
18 |
MeasureOrganizer={..Direction[0]}; |
|
|
19 |
}; |
|
|
20 |
|
|
|
21 |
AnyKinMeasureOrg LinMeasureOrg1 ={ |
|
|
22 |
AnyKinLinear &ref=.LinS; |
|
|
23 |
MeasureOrganizer={..Direction[1]}; |
|
|
24 |
}; |
|
|
25 |
|
|
|
26 |
AnyKinMeasureOrg LinMeasureOrg2 ={ |
|
|
27 |
AnyKinLinear &ref=.LinS; |
|
|
28 |
MeasureOrganizer={..Direction[2]}; |
|
|
29 |
}; |
|
|
30 |
|
|
|
31 |
|
|
|
32 |
AnyVar UserDefinedDistMeasure=LinMeasureOrg0.Pos[0]; |
|
|
33 |
AnyVar RadiusMeasure=sqrt(LinMeasureOrg1.Pos[0]^2+LinMeasureOrg2.Pos[0]^2); |
|
|
34 |
AnyVar UserDefinedVelMeasure = vnorm(LinS.Vel-.UserDefinedGroundVel,2); |
|
|
35 |
|
|
|
36 |
AnyFloatVar LowerThanHighDistLimit = ltfun(UserDefinedDistMeasure,.UserDefinedDistLimitHigh); |
|
|
37 |
AnyFloatVar GreaterThanLowDistLimit = gtfun(UserDefinedDistMeasure,.UserDefinedDistLimitLow); |
|
|
38 |
AnyFloatVar LowerThanRadiusLimit = ltfun(RadiusMeasure,.UserDefinedRadiusLimit); |
|
|
39 |
AnyFloatVar LowerThanHighVelLimit = ltfun(UserDefinedVelMeasure,.UserDefinedVelLimitHigh); |
|
|
40 |
AnyVar UserDefinedStrengthFunction= .Strength; |
|
|
41 |
|
|
|
42 |
AnyVar VelSize = UserDefinedVelMeasure;//vnorm(LinS.Vel, 2); |
|
|
43 |
AnyVar VelRatio = VelSize /.UserDefinedVelLimitHigh ; |
|
|
44 |
|
|
|
45 |
AnyFloatVar ContactDisCheck = andfun(andfun(LowerThanHighDistLimit,GreaterThanLowDistLimit),LowerThanRadiusLimit); |
|
|
46 |
AnyFloatVar HeightRatio = iffun(gteqfun(UserDefinedDistMeasure, 0.0), |
|
|
47 |
UserDefinedDistMeasure/.UserDefinedDistLimitHigh, |
|
|
48 |
iffun(lteqfun(abs(UserDefinedDistMeasure/.UserDefinedDistLimitLow), 1.0), 0.0, 1.0)); |
|
|
49 |
AnyFloatVar RadiusRatio = RadiusMeasure/.UserDefinedRadiusLimit; |
|
|
50 |
|
|
|
51 |
AnyFloatVar FirstControlVel = .UserDefinedVelLimitHigh * FirstControlVelRatio ; |
|
|
52 |
AnyFloatVar SecondControlVel = .UserDefinedVelLimitHigh * SecondControlVelRatio ; |
|
|
53 |
|
|
|
54 |
AnyIntVar FirstControlVelCheck = lteqfun(VelRatio, FirstControlVelRatio ); |
|
|
55 |
AnyIntVar SecondControlVelCheck = lteqfun(VelRatio, SecondControlVelRatio ); |
|
|
56 |
|
|
|
57 |
AnyIntVar FirstControlHeightCheck = lteqfun(HeightRatio, FirstControlHeightRatio); |
|
|
58 |
AnyIntVar SecondControlHeightCheck = lteqfun(HeightRatio, SecondControlHeightRatio); |
|
|
59 |
|
|
|
60 |
AnyIntVar FirstControlRadiusCheck = lteqfun(RadiusRatio, FirstControlRadiusRatio); |
|
|
61 |
AnyIntVar SecondControlRadiusCheck = lteqfun(RadiusRatio, SecondControlRadiusRatio); |
|
|
62 |
|
|
|
63 |
AnyFunPolynomial VelFactorFun_Lin = |
|
|
64 |
{ |
|
|
65 |
AnyVar v1 = .FirstControlVelRatio; |
|
|
66 |
AnyVar v2 = .SecondControlVelRatio ; |
|
|
67 |
PolyCoef = (1.0/(v2-v1))*{-v1, 1.0}; |
|
|
68 |
}; |
|
|
69 |
|
|
|
70 |
AnyFunPolynomial HeightFactorFun_Lin = |
|
|
71 |
{ |
|
|
72 |
AnyVar h1 = .FirstControlHeightRatio; |
|
|
73 |
AnyVar h2 = .SecondControlHeightRatio ; |
|
|
74 |
PolyCoef = (1.0/(h2-h1))*{-h1, 1.0}; |
|
|
75 |
}; |
|
|
76 |
|
|
|
77 |
AnyFunPolynomial RadiusFactorFun_Lin = |
|
|
78 |
{ |
|
|
79 |
AnyVar r1 = .FirstControlRadiusRatio; |
|
|
80 |
AnyVar r2 = .SecondControlRadiusRatio ; |
|
|
81 |
PolyCoef = (1.0/(r2-r1))*{-r1, 1.0}; |
|
|
82 |
}; |
|
|
83 |
|
|
|
84 |
AnyFunSquareWave VelFactorFun_SW = |
|
|
85 |
{ |
|
|
86 |
AnyVar v1 = .FirstControlVelRatio; |
|
|
87 |
AnyVar v2 = .SecondControlVelRatio ; |
|
|
88 |
InitialValues = {1.0}; |
|
|
89 |
Ts = {v1}; |
|
|
90 |
Values = {{0.0}}; |
|
|
91 |
dT = {abs(v1-v2)}; |
|
|
92 |
}; |
|
|
93 |
|
|
|
94 |
AnyFunSquareWave HeightFactorFun_SW = |
|
|
95 |
{ |
|
|
96 |
AnyVar h1 = .FirstControlHeightRatio; |
|
|
97 |
AnyVar h2 = .SecondControlHeightRatio ; |
|
|
98 |
InitialValues = {1.0}; |
|
|
99 |
Ts = {h1}; |
|
|
100 |
Values = {{0.0}}; |
|
|
101 |
dT = {abs(h1-h2)}; |
|
|
102 |
}; |
|
|
103 |
|
|
|
104 |
AnyFunSquareWave RadiusFactorFun_SW = |
|
|
105 |
{ |
|
|
106 |
AnyVar r1 = .FirstControlRadiusRatio; |
|
|
107 |
AnyVar r2 = .SecondControlRadiusRatio ; |
|
|
108 |
InitialValues = {1.0}; |
|
|
109 |
Ts = {r1}; |
|
|
110 |
Values = {{0.0}}; |
|
|
111 |
dT = {abs(r1-r2)}; |
|
|
112 |
}; |
|
|
113 |
|
|
|
114 |
AnyFunInterpol VelFactorFun_BSpline4 = |
|
|
115 |
{ |
|
|
116 |
AnyVar v1 = .FirstControlVelRatio; |
|
|
117 |
AnyVar v2 = .SecondControlVelRatio; |
|
|
118 |
AnyVar delta = abs(v1-v2); |
|
|
119 |
|
|
|
120 |
AnyVar SlopeControl = 25/100; |
|
|
121 |
|
|
|
122 |
Type = Bspline; |
|
|
123 |
BsplineOrder = 4; |
|
|
124 |
T = { v2-delta*100/100, v2-delta*50/100, v2-delta*SlopeControl, |
|
|
125 |
v2, |
|
|
126 |
v2+delta*SlopeControl, |
|
|
127 |
(v2+v1)*50/100, |
|
|
128 |
v1-delta*SlopeControl, |
|
|
129 |
v1, |
|
|
130 |
v1+delta*SlopeControl, v1+delta*50/100, v1+delta*100/100}; |
|
|
131 |
Data = {{1.0, 1.0, 1.0, |
|
|
132 |
1.0, //v2 |
|
|
133 |
1.0, |
|
|
134 |
0.5, // average of v2 and v1 |
|
|
135 |
0.0, |
|
|
136 |
0.0, //v1 |
|
|
137 |
0.0, 0.0, 0.0}}; |
|
|
138 |
}; |
|
|
139 |
|
|
|
140 |
AnyFunInterpol HeightFactorFun_BSpline4 = |
|
|
141 |
{ |
|
|
142 |
AnyVar h1 = .FirstControlHeightRatio; |
|
|
143 |
AnyVar h2 = .SecondControlHeightRatio ; |
|
|
144 |
AnyVar delta = abs(h1-h2); |
|
|
145 |
|
|
|
146 |
AnyVar SlopeControl = 25/100; |
|
|
147 |
|
|
|
148 |
Type = Bspline; |
|
|
149 |
BsplineOrder = 4; |
|
|
150 |
T = { h2-delta*100/100, h2-delta*50/100, h2-delta*SlopeControl, |
|
|
151 |
h2, |
|
|
152 |
h2+delta*SlopeControl, |
|
|
153 |
(h2+h1)*50/100, |
|
|
154 |
h1-delta*SlopeControl, |
|
|
155 |
h1, |
|
|
156 |
h1+delta*SlopeControl, h1+delta*50/100, h1+delta*100/100}; |
|
|
157 |
Data = {{1.0, 1.0, 1.0, |
|
|
158 |
1.0, //h2 |
|
|
159 |
1.0, |
|
|
160 |
0.5, // average of h2 and h1 |
|
|
161 |
0.0, |
|
|
162 |
0.0, //h1 |
|
|
163 |
0.0, 0.0, 0.0}}; |
|
|
164 |
}; |
|
|
165 |
|
|
|
166 |
AnyFunInterpol RadiusFactorFun_BSpline4 = |
|
|
167 |
{ |
|
|
168 |
AnyVar r1 = .FirstControlRadiusRatio; |
|
|
169 |
AnyVar r2 = .SecondControlRadiusRatio ; |
|
|
170 |
AnyVar delta = abs(r1-r2); |
|
|
171 |
|
|
|
172 |
AnyVar SlopeControl = 25/100; |
|
|
173 |
|
|
|
174 |
Type = Bspline; |
|
|
175 |
BsplineOrder = 4; |
|
|
176 |
T = { r2-delta*100/100*10, r2-delta*50/100, r2-delta*SlopeControl, |
|
|
177 |
r2, |
|
|
178 |
r2+delta*SlopeControl, |
|
|
179 |
(r2+r1)*50/100, |
|
|
180 |
r1-delta*SlopeControl, |
|
|
181 |
r1, |
|
|
182 |
r1+delta*SlopeControl, r1+delta*50/100, r1+delta*100/100*10}; |
|
|
183 |
Data = {{1.0, 1.0, 1.0, |
|
|
184 |
1.0, //r2 |
|
|
185 |
1.0, |
|
|
186 |
0.5, // average of r2 and r1 |
|
|
187 |
0.0, |
|
|
188 |
0.0, //r1 |
|
|
189 |
0.0, 0.0, 0.0}}; |
|
|
190 |
}; |
|
|
191 |
|
|
|
192 |
|
|
|
193 |
#ifdef _SMOOTHING_FUNCTION_PROFILE_ |
|
|
194 |
#undef _SMOOTHING_FUNCTION_PROFILE_ |
|
|
195 |
#endif |
|
|
196 |
|
|
|
197 |
//#define _SMOOTHING_FUNCTION_PROFILE_ "FUNC_PROFILE_SW" |
|
|
198 |
//#define _SMOOTHING_FUNCTION_PROFILE_ "FUNC_PROFILE_BSPLINE" |
|
|
199 |
//#define _SMOOTHING_FUNCTION_PROFILE_ "FUNC_PROFILE_COSINE" |
|
|
200 |
#define _SMOOTHING_FUNCTION_PROFILE_ "FUNC_PROFILE_LINEAR" |
|
|
201 |
//#define _SMOOTHING_FUNCTION_PROFILE_ "FUNC_PROFILE_TEST" |
|
|
202 |
|
|
|
203 |
#if _SMOOTHING_FUNCTION_PROFILE_ == "FUNC_PROFILE_SW" |
|
|
204 |
AnyVar FirstControlHeightRatio = 1.0; |
|
|
205 |
AnyVar SecondControlHeightRatio = 0.1; |
|
|
206 |
AnyVar FirstControlRadiusRatio = 1.0; |
|
|
207 |
AnyVar SecondControlRadiusRatio = 0.9; |
|
|
208 |
AnyVar FirstControlVelRatio = 1.0; |
|
|
209 |
AnyVar SecondControlVelRatio = 0.1; |
|
|
210 |
|
|
|
211 |
AnyVar HeightFactorFun = iffun(FirstControlHeightCheck, HeightFactorFun_SW(HeightRatio)[0], 0.0); |
|
|
212 |
AnyVar RadiusFactorFun = iffun(FirstControlRadiusCheck, RadiusFactorFun_SW(RadiusRatio)[0], 0.0); |
|
|
213 |
AnyVar VelFactorFun = iffun(FirstControlVelCheck, VelFactorFun_SW(VelRatio)[0], 0.0); |
|
|
214 |
#endif |
|
|
215 |
|
|
|
216 |
#if _SMOOTHING_FUNCTION_PROFILE_ == "FUNC_PROFILE_BSPLINE" |
|
|
217 |
AnyVar FirstControlHeightRatio = 1.0; |
|
|
218 |
AnyVar SecondControlHeightRatio = 0.1; |
|
|
219 |
AnyVar FirstControlRadiusRatio = 1.0; |
|
|
220 |
AnyVar SecondControlRadiusRatio = 0.9; |
|
|
221 |
AnyVar FirstControlVelRatio = 1.0; |
|
|
222 |
AnyVar SecondControlVelRatio = 0.1; |
|
|
223 |
|
|
|
224 |
//Ensure the heightratio is not outside the interpol fun |
|
|
225 |
AnyVar HeightRatioMaxInSplineFun =max(HeightFactorFun_BSpline4.T)-0.0001; //find max "T" in spline function subtract tol |
|
|
226 |
AnyVar HeightRatioMinInSplineFun =min(HeightFactorFun_BSpline4.T)+0.0001;//find min "T" in spline function add tol |
|
|
227 |
AnyVar HeightRatioCapped_max = iffun(gtfun(HeightRatio,HeightRatioMaxInSplineFun),HeightRatioMaxInSplineFun,HeightRatio) ; //cap ratio |
|
|
228 |
AnyVar HeightRatioCapped = iffun(ltfun(HeightRatioCapped_max,HeightRatioMinInSplineFun),HeightRatioMinInSplineFun,HeightRatioCapped_max) ; |
|
|
229 |
|
|
|
230 |
//Ensure the radiusratio is not outside the interpol fun |
|
|
231 |
AnyVar RadiusRatioMaxInSplineFun =max(RadiusFactorFun_BSpline4.T)-0.0001; //find max "T" in spline function subtract tol |
|
|
232 |
AnyVar RadiusRatioMinInSplineFun =min(RadiusFactorFun_BSpline4.T)+0.0001;//find min "T" in spline function add tol |
|
|
233 |
AnyVar RadiusRatioCapped_max = iffun(gtfun(RadiusRatio,RadiusRatioMaxInSplineFun),RadiusRatioMaxInSplineFun,RadiusRatio) ; //cap ratio |
|
|
234 |
AnyVar RadiusRatioCapped = iffun(ltfun(RadiusRatioCapped_max,RadiusRatioMinInSplineFun),RadiusRatioMinInSplineFun,RadiusRatioCapped_max) ; |
|
|
235 |
|
|
|
236 |
//Ensure the Velatio is not outside the interpol fun |
|
|
237 |
AnyVar VelRatioMaxInSplineFun =max(VelFactorFun_BSpline4.T)-0.0001; //find max "T" in spline function subtract tol |
|
|
238 |
AnyVar VelRatioMinInSplineFun =min(VelFactorFun_BSpline4.T)+0.0001;//find min "T" in spline function add tol |
|
|
239 |
AnyVar VelRatioCapped_max = iffun(gtfun(VelRatio,VelRatioMaxInSplineFun),VelRatioMaxInSplineFun,VelRatio) ; //cap ratio |
|
|
240 |
AnyVar VelRatioCapped = iffun(ltfun(VelRatioCapped_max,VelRatioMinInSplineFun),VelRatioMinInSplineFun,VelRatioCapped_max) ; |
|
|
241 |
|
|
|
242 |
|
|
|
243 |
AnyVar HeightFactorFun = iffun(lteqfun(HeightRatio, FirstControlHeightRatio), |
|
|
244 |
// iffun(ltfun(HeightRatio, SecondControlHeightRatio), 1.0, HeightFactorFun_BSpline4(HeightRatio)[0]), |
|
|
245 |
iffun(ltfun(HeightRatio, SecondControlHeightRatio), 1.0, HeightFactorFun_BSpline4(HeightRatioCapped)[0]), |
|
|
246 |
|
|
|
247 |
0.0); |
|
|
248 |
AnyVar RadiusFactorFun = iffun(lteqfun(RadiusRatio, FirstControlRadiusRatio), |
|
|
249 |
//iffun(ltfun(RadiusRatio, SecondControlRadiusRatio), 1.0, RadiusFactorFun_BSpline4(RadiusRatio)[0]), |
|
|
250 |
iffun(ltfun(RadiusRatio, SecondControlRadiusRatio), 1.0, RadiusFactorFun_BSpline4(RadiusRatioCapped)[0]), |
|
|
251 |
|
|
|
252 |
0.0); |
|
|
253 |
AnyVar VelFactorFun = iffun(lteqfun(VelRatio, FirstControlVelRatio), |
|
|
254 |
// iffun(ltfun(VelRatio, SecondControlVelRatio), 1.0, VelFactorFun_BSpline4(VelRatio)[0]), |
|
|
255 |
iffun(ltfun(VelRatio, SecondControlVelRatio), 1.0, VelFactorFun_BSpline4(VelRatioCapped)[0]), |
|
|
256 |
0.0); |
|
|
257 |
#endif |
|
|
258 |
|
|
|
259 |
#if _SMOOTHING_FUNCTION_PROFILE_ == "FUNC_PROFILE_COSINE" |
|
|
260 |
AnyVar FirstControlHeightRatio = 1.0; |
|
|
261 |
AnyVar SecondControlHeightRatio = 0.8; |
|
|
262 |
AnyVar FirstControlRadiusRatio = 1.0; |
|
|
263 |
AnyVar SecondControlRadiusRatio = 0.9; |
|
|
264 |
AnyVar FirstControlVelRatio = 1.0; |
|
|
265 |
AnyVar SecondControlVelRatio = 0.15; |
|
|
266 |
|
|
|
267 |
AnyVar HeightFactorFun = iffun(lteqfun(HeightRatio, FirstControlHeightRatio), |
|
|
268 |
iffun(ltfun(HeightRatio, SecondControlHeightRatio), 1.0, |
|
|
269 |
(cos((HeightRatio-SecondControlHeightRatio)/(FirstControlHeightRatio-SecondControlHeightRatio)*pi)+1)*0.5), |
|
|
270 |
0.0); |
|
|
271 |
AnyVar RadiusFactorFun = iffun(lteqfun(RadiusRatio, FirstControlRadiusRatio), |
|
|
272 |
iffun(ltfun(RadiusRatio, SecondControlRadiusRatio), 1.0, |
|
|
273 |
(cos((RadiusRatio-SecondControlRadiusRatio)/(FirstControlRadiusRatio-SecondControlRadiusRatio)*pi)+1)*0.5), |
|
|
274 |
0.0); |
|
|
275 |
AnyVar VelFactorFun = iffun(lteqfun(VelRatio, FirstControlVelRatio), |
|
|
276 |
iffun(ltfun(VelRatio, SecondControlVelRatio), 1.0, |
|
|
277 |
(cos((VelRatio-SecondControlVelRatio)/(FirstControlVelRatio-SecondControlVelRatio)*pi)+1)*0.5), |
|
|
278 |
0.0); |
|
|
279 |
#endif |
|
|
280 |
|
|
|
281 |
#if _SMOOTHING_FUNCTION_PROFILE_ == "FUNC_PROFILE_LINEAR" |
|
|
282 |
AnyVar FirstControlHeightRatio = 1.0; |
|
|
283 |
AnyVar SecondControlHeightRatio = 0.8; |
|
|
284 |
AnyVar FirstControlRadiusRatio = 1.0; |
|
|
285 |
AnyVar SecondControlRadiusRatio = 0.9; |
|
|
286 |
AnyVar FirstControlVelRatio = 1.0; |
|
|
287 |
AnyVar SecondControlVelRatio = 0.15; |
|
|
288 |
|
|
|
289 |
AnyVar HeightFactorFun = iffun(lteqfun(HeightRatio, FirstControlHeightRatio), |
|
|
290 |
iffun(ltfun(HeightRatio, SecondControlHeightRatio), 1.0, HeightFactorFun_Lin(HeightRatio)), |
|
|
291 |
0.0); |
|
|
292 |
AnyVar RadiusFactorFun = iffun(lteqfun(RadiusRatio, FirstControlRadiusRatio), |
|
|
293 |
iffun(ltfun(RadiusRatio, SecondControlRadiusRatio), 1.0, RadiusFactorFun_Lin(RadiusRatio)), |
|
|
294 |
0.0); |
|
|
295 |
AnyVar VelFactorFun = iffun(lteqfun(VelRatio, FirstControlVelRatio), |
|
|
296 |
iffun(ltfun(VelRatio, SecondControlVelRatio), 1.0, VelFactorFun_Lin(VelRatio)), |
|
|
297 |
0.0); |
|
|
298 |
#endif |
|
|
299 |
|
|
|
300 |
#if _SMOOTHING_FUNCTION_PROFILE_ == "FUNC_PROFILE_TEST" |
|
|
301 |
AnyVar FirstControlHeightRatio = 1.0; |
|
|
302 |
AnyVar SecondControlHeightRatio = 0.8; |
|
|
303 |
AnyVar FirstControlRadiusRatio = 1.0; |
|
|
304 |
AnyVar SecondControlRadiusRatio = 0.9; |
|
|
305 |
AnyVar FirstControlVelRatio = 1.0; |
|
|
306 |
AnyVar SecondControlVelRatio = 0.15; |
|
|
307 |
|
|
|
308 |
AnyVar HeightFactorFun = iffun(FirstControlHeightCheck, |
|
|
309 |
iffun(SecondControlHeightCheck, 1.0, HeightFactorFun_Lin(HeightRatio)), |
|
|
310 |
0.0); |
|
|
311 |
AnyVar RadiusFactorFun = iffun(FirstControlRadiusCheck, |
|
|
312 |
iffun(SecondControlRadiusCheck, 1.0, RadiusFactorFun_Lin(RadiusRatio)), |
|
|
313 |
0.0); |
|
|
314 |
// AnyVar VelFactorFun = iffun(FirstControlVelCheck, |
|
|
315 |
// iffun(SecondControlVelCheck, 1.0, VelFactorFun_BSpline4(VelRatio)[0]), |
|
|
316 |
// 0.0); |
|
|
317 |
// AnyVar VelFactorFun = iffun(FirstControlVelCheck, |
|
|
318 |
// VelFactorFun_SW(VelRatio)[0], |
|
|
319 |
// 0.0); |
|
|
320 |
|
|
|
321 |
AnyVar VelFactorFun = iffun(FirstControlVelCheck, |
|
|
322 |
iffun(SecondControlVelCheck , 1.0, |
|
|
323 |
(cos((VelRatio-SecondControlVelRatio)/(FirstControlVelRatio-SecondControlVelRatio)*pi)+1)*0.5), |
|
|
324 |
0.0); |
|
|
325 |
#endif |
|
|
326 |
|
|
|
327 |
#undef _SMOOTHING_FUNCTION_PROFILE_ |
|
|
328 |
|
|
|
329 |
AnyVar DisFactorFun = HeightFactorFun * RadiusFactorFun; |
|
|
330 |
AnyVar SmoothingFunction = DisFactorFun * VelFactorFun; |
|
|
331 |
|
|
|
332 |
AnyVar ContactStrengthSmoothed = SmoothingFunction * .Strength; |
|
|
333 |
AnyVar ContactStrengthDisAndVel = iffun(andfun(andfun(andfun(LowerThanHighDistLimit,GreaterThanLowDistLimit),LowerThanRadiusLimit),LowerThanHighVelLimit), .Strength, 0.0); |
|
|
334 |
AnyVar ContactStrengthOriginal = iffun( andfun(andfun(LowerThanHighDistLimit,GreaterThanLowDistLimit),LowerThanRadiusLimit),.Strength,0.0); |
|
|
335 |
//<--Test |
|
|
336 |
|
|
|
337 |
AnyVec3 NormalVector={ |
|
|
338 |
iffun(.Direction[0]-0,0,1), |
|
|
339 |
iffun(.Direction[0]-1,0,1), |
|
|
340 |
iffun(.Direction[0]-2,0,1)}; |
|
|
341 |
|
|
|
342 |
AnyVec3 FrictionVector1={ |
|
|
343 |
iffun(.Direction[1]-0,0,1), |
|
|
344 |
iffun(.Direction[1]-1,0,1), |
|
|
345 |
iffun(.Direction[1]-2,0,1)}; |
|
|
346 |
|
|
|
347 |
AnyVec3 FrictionVector2={ |
|
|
348 |
iffun(.Direction[2]-0,0,1), |
|
|
349 |
iffun(.Direction[2]-1,0,1), |
|
|
350 |
iffun(.Direction[2]-2,0,1)}; |
|
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
|
354 |
|
|
|
355 |
AnyKinLinear Lin={ |
|
|
356 |
AnyRefFrame &Box =..BaseObject; |
|
|
357 |
AnyRefFrame &Hand = ..TargetObject; |
|
|
358 |
Ref=0; |
|
|
359 |
}; |
|
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
|
363 |
AnyFolder Direction0Muscle ={ |
|
|
364 |
AnyRecruitedActuator NormalDirectionMuscle={ |
|
|
365 |
AnyKinMeasureOrg NormalDir={ |
|
|
366 |
AnyKinLinear &ref=...Lin; |
|
|
367 |
MeasureOrganizer={....Direction[0]}; //always pick first element |
|
|
368 |
}; |
|
|
369 |
Strength = ..ContactStrengthSmoothed; |
|
|
370 |
Type = NonNegative; |
|
|
371 |
//AnyVar StrengthTestVal = |
|
|
372 |
SET_DEFAULT_ACTUATOR_VOLUME; |
|
|
373 |
|
|
|
374 |
}; |
|
|
375 |
}; |
|
|
376 |
|
|
|
377 |
|
|
|
378 |
|
|
|
379 |
AnyFolder Direction01Muscle={ |
|
|
380 |
AnyFolder Push={ |
|
|
381 |
AnyKinMeasureOrg NormalDir={ |
|
|
382 |
AnyKinLinear &ref=...Lin; |
|
|
383 |
MeasureOrganizer={....Direction[0]}; //always pick first element |
|
|
384 |
}; |
|
|
385 |
AnyKinMeasureOrg FrictionDir={ |
|
|
386 |
AnyKinLinear &ref=...Lin; |
|
|
387 |
MeasureOrganizer={....Direction[1]}; // pick second element |
|
|
388 |
}; |
|
|
389 |
AnyKinMeasureLinComb LinCombinationMeasure ={ |
|
|
390 |
AnyKinMeasure& u1=.NormalDir; |
|
|
391 |
AnyKinMeasure& u2=.FrictionDir; |
|
|
392 |
Coef={ |
|
|
393 |
{1,....StaticFrictionCoefficient} |
|
|
394 |
}; |
|
|
395 |
OutDim = 1; |
|
|
396 |
}; |
|
|
397 |
|
|
|
398 |
AnyRecruitedActuator FrictionMuscle={ |
|
|
399 |
// AnyKinMeasure& ref1=.FrictionDir; |
|
|
400 |
AnyKinMeasureLinComb &ref1=.LinCombinationMeasure; |
|
|
401 |
Strength = ...ContactStrengthSmoothed; |
|
|
402 |
Type = NonNegative; |
|
|
403 |
SET_DEFAULT_ACTUATOR_VOLUME; |
|
|
404 |
}; |
|
|
405 |
|
|
|
406 |
};//Push |
|
|
407 |
|
|
|
408 |
AnyFolder Pull={ |
|
|
409 |
AnyKinMeasureOrg NormalDir={ |
|
|
410 |
AnyKinLinear &ref=...Lin; |
|
|
411 |
MeasureOrganizer={....Direction[0]}; //always pick first element |
|
|
412 |
}; |
|
|
413 |
AnyKinMeasureOrg FrictionDir={ |
|
|
414 |
AnyKinLinear &ref=...Lin; |
|
|
415 |
MeasureOrganizer={....Direction[1]}; // pick second element |
|
|
416 |
}; |
|
|
417 |
AnyKinMeasureLinComb LinCombinationMeasure ={ |
|
|
418 |
AnyKinMeasure& u1=.NormalDir; |
|
|
419 |
AnyKinMeasure& u2=.FrictionDir; |
|
|
420 |
Coef={ |
|
|
421 |
{-1,....StaticFrictionCoefficient} |
|
|
422 |
}; |
|
|
423 |
OutDim = 1; |
|
|
424 |
}; |
|
|
425 |
|
|
|
426 |
AnyRecruitedActuator FrictionMuscle={ |
|
|
427 |
AnyKinMeasureLinComb &ref1=.LinCombinationMeasure; |
|
|
428 |
// AnyKinMeasure& ref1=.FrictionDir; |
|
|
429 |
Strength = ...ContactStrengthSmoothed; |
|
|
430 |
Type = NonPositive; |
|
|
431 |
SET_DEFAULT_ACTUATOR_VOLUME; |
|
|
432 |
}; |
|
|
433 |
|
|
|
434 |
};//Pull |
|
|
435 |
|
|
|
436 |
}; |
|
|
437 |
|
|
|
438 |
|
|
|
439 |
|
|
|
440 |
AnyFolder Direction02Muscle={ |
|
|
441 |
AnyFolder Push={ |
|
|
442 |
AnyKinMeasureOrg NormalDir={ |
|
|
443 |
AnyKinLinear &ref=...Lin; |
|
|
444 |
MeasureOrganizer={....Direction[0]}; //always pick first element |
|
|
445 |
}; |
|
|
446 |
AnyKinMeasureOrg FrictionDir={ |
|
|
447 |
AnyKinLinear &ref=...Lin; |
|
|
448 |
MeasureOrganizer={....Direction[2]}; // pick last element |
|
|
449 |
}; |
|
|
450 |
AnyKinMeasureLinComb LinCombinationMeasure ={ |
|
|
451 |
AnyKinMeasure& u1=.NormalDir; |
|
|
452 |
AnyKinMeasure& u2=.FrictionDir; |
|
|
453 |
Coef={ |
|
|
454 |
{1,....StaticFrictionCoefficient} |
|
|
455 |
}; |
|
|
456 |
OutDim = 1; |
|
|
457 |
}; |
|
|
458 |
|
|
|
459 |
AnyRecruitedActuator FrictionMuscle={ |
|
|
460 |
AnyKinMeasureLinComb &ref1=.LinCombinationMeasure; |
|
|
461 |
// AnyKinMeasure& ref1=.FrictionDir; |
|
|
462 |
|
|
|
463 |
Strength = ...ContactStrengthSmoothed; |
|
|
464 |
Type = NonNegative; |
|
|
465 |
SET_DEFAULT_ACTUATOR_VOLUME; |
|
|
466 |
}; |
|
|
467 |
|
|
|
468 |
};//Push |
|
|
469 |
|
|
|
470 |
AnyFolder Pull={ |
|
|
471 |
AnyKinMeasureOrg NormalDir={ |
|
|
472 |
AnyKinLinear &ref=...Lin; |
|
|
473 |
MeasureOrganizer={....Direction[0]}; //always pick first element |
|
|
474 |
}; |
|
|
475 |
AnyKinMeasureOrg FrictionDir={ |
|
|
476 |
AnyKinLinear &ref=...Lin; |
|
|
477 |
MeasureOrganizer={....Direction[2]}; // pick last element |
|
|
478 |
}; |
|
|
479 |
AnyKinMeasureLinComb LinCombinationMeasure ={ |
|
|
480 |
AnyKinMeasure& u1=.NormalDir; |
|
|
481 |
AnyKinMeasure& u2=.FrictionDir; |
|
|
482 |
Coef={ |
|
|
483 |
{-1,....StaticFrictionCoefficient} |
|
|
484 |
}; |
|
|
485 |
OutDim = 1; |
|
|
486 |
}; |
|
|
487 |
|
|
|
488 |
AnyRecruitedActuator FrictionMuscle={ |
|
|
489 |
AnyKinMeasureLinComb &ref1=.LinCombinationMeasure; |
|
|
490 |
// AnyKinMeasure& ref1=.FrictionDir; |
|
|
491 |
Strength = ...ContactStrengthSmoothed; |
|
|
492 |
Type = NonPositive; |
|
|
493 |
SET_DEFAULT_ACTUATOR_VOLUME; |
|
|
494 |
}; |
|
|
495 |
|
|
|
496 |
};//Pull |
|
|
497 |
|
|
|
498 |
}; |
|
|
499 |
|
|
|
500 |
AnyFolder RefMuscles = |
|
|
501 |
{ |
|
|
502 |
AnyRecruitedForce& ref0 = .Direction0Muscle.NormalDirectionMuscle; |
|
|
503 |
AnyRecruitedForce& ref1 = .Direction01Muscle.Push.FrictionMuscle; |
|
|
504 |
AnyRecruitedForce& ref2 = .Direction01Muscle.Pull.FrictionMuscle; |
|
|
505 |
AnyRecruitedForce& ref3 = .Direction02Muscle.Push.FrictionMuscle; |
|
|
506 |
AnyRecruitedForce& ref4 = .Direction02Muscle.Pull.FrictionMuscle; |
|
|
507 |
}; |
|
|
508 |
|
|
|
509 |
// AnyForceMomentMeasure ForceMomentMeasure = |
|
|
510 |
// { |
|
|
511 |
// AnyForceBase& ref0 = .Direction0Muscle.NormalDirectionMuscle; |
|
|
512 |
// AnyForceBase& ref1 = .Direction01Muscle.Push.FrictionMuscle; |
|
|
513 |
// AnyForceBase& ref2 = .Direction01Muscle.Pull.FrictionMuscle; |
|
|
514 |
// AnyForceBase& ref3 = .Direction02Muscle.Push.FrictionMuscle; |
|
|
515 |
// AnyForceBase& ref4 = .Direction02Muscle.Pull.FrictionMuscle; |
|
|
516 |
// |
|
|
517 |
// AnyRefFrame& base = ..BaseObject; |
|
|
518 |
// |
|
|
519 |
// AnyVec3 Flocal = F * base.Axes; |
|
|
520 |
// AnyVec3 Mlocal = M * base.Axes; |
|
|
521 |
// }; |
|
|
522 |
|
|
|
523 |
AnyDrawVector DrawNormalForce = |
|
|
524 |
{ |
|
|
525 |
AnyRefFrame &ref=..TargetObject; |
|
|
526 |
AnyVar Strength= max({.ContactStrengthSmoothed, 0.00001}); |
|
|
527 |
Vec =..ScaleFactor*..DrawRef.DrawSettingsSupport.Lin.ScaleFactor*( |
|
|
528 |
abs(.NormalVector*.Direction0Muscle.NormalDirectionMuscle.Fout[0])*..BaseObject.Axes' |
|
|
529 |
+ abs(.NormalVector*.Direction01Muscle.Push.FrictionMuscle.Fout[0])*..BaseObject.Axes' |
|
|
530 |
+ abs(.NormalVector*.Direction02Muscle.Push.FrictionMuscle.Fout[0])*..BaseObject.Axes' |
|
|
531 |
+ abs(.NormalVector*.Direction01Muscle.Pull.FrictionMuscle.Fout[0])*..BaseObject.Axes' |
|
|
532 |
+ abs(.NormalVector*.Direction02Muscle.Pull.FrictionMuscle.Fout[0])*..BaseObject.Axes'); |
|
|
533 |
AnyVar length=Strength*(2-(1-Strength/sqrt(Strength^2))); |
|
|
534 |
|
|
|
535 |
PointAway = Off; |
|
|
536 |
DrawCoord = Off; |
|
|
537 |
|
|
|
538 |
Line.RGB = ..DrawRef.DrawSettingsSupport.Lin.RGB; |
|
|
539 |
Line.Thickness = ..DrawRef.DrawSettingsSupport.Lin.Thickness; |
|
|
540 |
Line.End.Thickness = 2*..DrawRef.DrawSettingsSupport.Lin.Thickness; |
|
|
541 |
Line.End.Length = 4*..DrawRef.DrawSettingsSupport.Lin.Thickness; |
|
|
542 |
|
|
|
543 |
}; |
|
|
544 |
|
|
|
545 |
AnyFolder NormalForceValue = |
|
|
546 |
{ |
|
|
547 |
AnyRefFrame &ref=..TargetObject; |
|
|
548 |
AnyVar Strength= max({.ContactStrengthSmoothed,0.00001}); |
|
|
549 |
AnyVec3 NormalForceVector =..ScaleFactor*..DrawRef.DrawSettingsSupport.Lin.ScaleFactor*( |
|
|
550 |
abs(.NormalVector*.Direction0Muscle.NormalDirectionMuscle.Fout[0])*..BaseObject.Axes' |
|
|
551 |
+abs(.NormalVector*.Direction01Muscle.Push.FrictionMuscle.Fout[0])*..BaseObject.Axes' |
|
|
552 |
+abs(.NormalVector*.Direction02Muscle.Push.FrictionMuscle.Fout[0])*..BaseObject.Axes' |
|
|
553 |
+abs(.NormalVector*.Direction01Muscle.Pull.FrictionMuscle.Fout[0])*..BaseObject.Axes' |
|
|
554 |
+abs(.NormalVector*.Direction02Muscle.Pull.FrictionMuscle.Fout[0])*..BaseObject.Axes'); |
|
|
555 |
AnyVar length=Strength*(2-(1-Strength/sqrt(Strength^2))); |
|
|
556 |
}; |
|
|
557 |
|
|
|
558 |
AnyDrawVector DrawFrictionForce = |
|
|
559 |
{ |
|
|
560 |
AnyRefFrame &ref=..TargetObject; |
|
|
561 |
|
|
|
562 |
Vec =..ScaleFactor*..DrawRef.DrawSettingsSupport.Lin.ScaleFactor*..StaticFrictionCoefficient*( |
|
|
563 |
abs(.FrictionVector1*.Direction01Muscle.Push.FrictionMuscle.Fout[0]) |
|
|
564 |
-abs(.FrictionVector1*.Direction01Muscle.Pull.FrictionMuscle.Fout[0]) |
|
|
565 |
+abs(.FrictionVector2*.Direction02Muscle.Push.FrictionMuscle.Fout[0]) |
|
|
566 |
-abs(.FrictionVector2*.Direction02Muscle.Pull.FrictionMuscle.Fout[0]))*..BaseObject.Axes'; |
|
|
567 |
|
|
|
568 |
PointAway = Off; |
|
|
569 |
DrawCoord = Off; |
|
|
570 |
|
|
|
571 |
Line.RGB = ..DrawRef.DrawSettingsSupport.Lin.RGB; |
|
|
572 |
Line.Thickness = ..DrawRef.DrawSettingsSupport.Lin.Thickness; |
|
|
573 |
Line.End.Thickness = 2*..DrawRef.DrawSettingsSupport.Lin.Thickness; |
|
|
574 |
Line.End.Length = 4*..DrawRef.DrawSettingsSupport.Lin.Thickness; |
|
|
575 |
}; |
|
|
576 |
|
|
|
577 |
|
|
|
578 |
//resultann force given in global ref system |
|
|
579 |
AnyVec3 NormalForceVec = NormalForceValue.NormalForceVector/(.ScaleFactor*.DrawRef.DrawSettingsSupport.Lin.ScaleFactor); |
|
|
580 |
AnyVar NormalForceScalar = (NormalForceVec[0]^2+NormalForceVec[1]^2+NormalForceVec[2]^2)^0.5; |
|
|
581 |
|
|
|
582 |
AnyVec3 NormalForceVec2 = NormalForceValue.NormalForceVector/(.ScaleFactor*.DrawRef.DrawSettingsSupport.Lin.ScaleFactor); |
|
|
583 |
AnyVar NormalForceScalar2 = (NormalForceVec2[0]^2+NormalForceVec2[1]^2+NormalForceVec2[2]^2)^0.5; |
|
|
584 |
|
|
|
585 |
AnyVec3 FrictionForceVec = DrawFrictionForce.Vec/(.ScaleFactor*.DrawRef.DrawSettingsSupport.Lin.ScaleFactor); |
|
|
586 |
AnyVar FrictionForceScalar = (FrictionForceVec[0]^2+FrictionForceVec[1]^2+FrictionForceVec[2]^2)^0.5; |
|
|
587 |
|
|
|
588 |
//AnyVar TotalForceScalar = (TotalForceVec[0]^2+TotalForceVec[1]^2+TotalForceVec[2]^2)^0.5; |
|
|
589 |
|
|
|
590 |
/* |
|
|
591 |
AnyDrawVector DrawFrictionForce1 = { |
|
|
592 |
|
|
|
593 |
AnyRefFrame &ref=..TargetObject; |
|
|
594 |
|
|
|
595 |
Vec =0.001*..StaticFrictionCoefficient*( |
|
|
596 |
abs(.FrictionVector1*.Direction01Muscle.Push.FrictionMuscle.Fout[0])*..BaseObject.Axes')+ |
|
|
597 |
-abs(.FrictionVector1*.Direction01Muscle.Pull.FrictionMuscle.Fout[0])*..BaseObject.Axes'); |
|
|
598 |
|
|
|
599 |
PointAway = Off; |
|
|
600 |
DrawCoord = Off; |
|
|
601 |
Line.RGB = {0,1,0}; |
|
|
602 |
Line.Thickness = 0.015; |
|
|
603 |
Line.End.Thickness = 2*0.015; |
|
|
604 |
Line.End.Length = 4*0.015; |
|
|
605 |
}; |
|
|
606 |
|
|
|
607 |
AnyDrawVector DrawFrictionForce2 = { |
|
|
608 |
|
|
|
609 |
AnyRefFrame &ref=..TargetObject; |
|
|
610 |
|
|
|
611 |
Vec =0.001*..StaticFrictionCoefficient*( |
|
|
612 |
abs(.FrictionVector2*.Direction02Muscle.Push.FrictionMuscle.Fout[0])*..BaseObject.Axes')+ |
|
|
613 |
-abs(.FrictionVector2*.Direction02Muscle.Pull.FrictionMuscle.Fout[0])*..BaseObject.Axes'); |
|
|
614 |
|
|
|
615 |
PointAway = Off; |
|
|
616 |
DrawCoord = Off; |
|
|
617 |
Line.RGB = {1,0,0}; |
|
|
618 |
Line.Thickness = 0.015; |
|
|
619 |
Line.End.Thickness = 2*0.015; |
|
|
620 |
Line.End.Length = 4*0.015; |
|
|
621 |
}; |
|
|
622 |
*/ |
|
|
623 |
}; |
|
|
624 |
|