00001
00002
00003
00004
00005
00006
00007 #include "GT2004CollisionDetector.h"
00008 #include "Tools/Debugging/Debugging.h"
00009
00010 double maxfl1 = 0;
00011 double maxfl2 = 0;
00012 double maxfr1 = 0;
00013 double maxfr2 = 0;
00014 double maxhl1 = 0;
00015 double maxhl2 = 0;
00016 double maxhr1 = 0;
00017 double maxhr2 = 0;
00018
00019
00020
00021 GT2004CollisionDetector::GT2004CollisionDetector
00022 (const CollisionDetectorInterfaces& interfaces)
00023 : CollisionDetector(interfaces)
00024 {
00025 infin = 1000000000;
00026 index = 0;
00027 min = 5;
00028 max = 12;
00029 oldVal = 0;
00030 newVal = 0;
00031
00032 frontMin = 0;
00033 frontMax = infin;
00034 backMin = -0;
00035 backMax = -infin;
00036 sideMin = 0;
00037 sideMax = infin;
00038 rotMin = 0.00;
00039 rotMax = infin;
00040
00041
00042
00043 currentMotionX = 0;
00044 currentMotionY = 0;
00045 currentRotation = 0;
00046 lastMotionX = 0;
00047 lastMotionY = 0;
00048 lastRotation = 0;
00049 motionChangeThresholdX = 50;
00050 motionChangeThresholdY = 50;
00051 motionChangeThresholdR = 0.2;
00052 calmDown = 32;
00053 lastMotionChange = calmDown + 1;
00054 lastTooBigMotionChange = 0;
00055 motionChangeThresholdFactor = 1;
00056 xRatio = 0;
00057 yRatio = 0;
00058 rRatio = 0;
00059 q = 12;
00060
00061
00062
00063
00064 scaleThresholdFore = scaleThresholdBack = scaleThresholdSide = 1;
00065 scaleThresholdRot = 2;
00066
00067 walkingMode = 0;
00068
00069
00070
00071
00072
00073
00074
00075 for (int i = 0; i < SensorData::numOfSensor_ERS210; i++)
00076 {
00077 for (int l = 0; l < SensorDataBuffer::maxNumOfFrames; l++)
00078 {
00079 for (int d = 0; d < 16; d++)
00080 {
00081 floatingAvg[i][l][d] = 0;
00082 }
00083 minAvg[i][l] = 0;
00084 }
00085
00086
00087
00088
00089
00090 for (int j = 0; j < 128; j++)
00091 {
00092 for (int k = 0; k < 2; k++)
00093 {
00094 ringBuffer[i][j][k] = 0;
00095 }
00096 }
00097 for (int t = 0; t < 3; t++)
00098 {
00099 threshold[i][t] = 0;
00100 }
00101 }
00102
00103
00104 threshold[SensorData::legFL3][2] = infin;
00105 threshold[SensorData::legFR3][2] = infin;
00106 threshold[SensorData::legHL3][2] = infin;
00107 threshold[SensorData::legHR3][2] = infin;
00108
00109 }
00110
00111
00112 void GT2004CollisionDetector::calculateThresholds()
00113 {
00114
00115 walkingMode = 0;
00116
00117 threshold[SensorData::legFL1][2] = 1;
00118 threshold[SensorData::legHL1][2] = 1;
00119 threshold[SensorData::legFL2][2] = 1;
00120 threshold[SensorData::legHL2][2] = 1;
00121
00122
00123 if ((currentMotionX > frontMin) && (currentMotionX <= frontMax))
00124 {
00125 walkingMode = 1;
00126
00127 if (currentMotionX <= 5)
00128 {
00129 threshold[SensorData::legFL1][1] = 1200; threshold[SensorData::legFL2][1] = 1000;
00130 threshold[SensorData::legHL1][1] = 3300; threshold[SensorData::legHL2][1] = 2500;
00131 }
00132 else if (currentMotionX <= 40)
00133 {
00134 threshold[SensorData::legFL1][1] = 1500; threshold[SensorData::legFL2][1] = 3600;
00135 threshold[SensorData::legHL1][1] = 3500; threshold[SensorData::legHL2][1] = 3300;
00136 }
00137 else if (currentMotionX <= 80)
00138 {
00139 threshold[SensorData::legFL1][1] = 2100; threshold[SensorData::legFL2][1] = 1800;
00140 threshold[SensorData::legHL1][1] = 3500; threshold[SensorData::legHL2][1] = 1800;
00141 }
00142 else if (currentMotionX <= 120)
00143 {
00144 threshold[SensorData::legFL1][1] = 2300; threshold[SensorData::legFL2][1] = 2700;
00145 threshold[SensorData::legHL1][1] = 3300; threshold[SensorData::legHL2][1] = 3300;
00146 }
00147 else if (currentMotionX <= 160)
00148 {
00149 threshold[SensorData::legFL1][1] = 2500; threshold[SensorData::legFL2][1] = 2700;
00150 threshold[SensorData::legHL1][1] = 3300; threshold[SensorData::legHL2][1] = 3300;
00151 }
00152 else if (currentMotionX <= 200)
00153 {
00154 threshold[SensorData::legFL1][1] = 4500; threshold[SensorData::legFL2][1] = 2000;
00155 threshold[SensorData::legHL1][1] = 3300; threshold[SensorData::legHL2][1] = 2000;
00156 }
00157 else if (currentMotionX <= 240)
00158 {
00159 threshold[SensorData::legFL1][1] = 4500; threshold[SensorData::legFL2][1] = 2000;
00160 threshold[SensorData::legHL1][1] = 4500; threshold[SensorData::legHL2][1] = 2000;
00161 }
00162 else if (currentMotionX <= 280)
00163 {
00164 threshold[SensorData::legFL1][1] = 9000; threshold[SensorData::legFL2][1] = 2000;
00165 threshold[SensorData::legHL1][1] = 8000; threshold[SensorData::legHL2][1] = 2000;
00166 }
00167 else if (currentMotionX <= 320)
00168 {
00169 threshold[SensorData::legFL1][1] =11000; threshold[SensorData::legFL2][1] = 2000;
00170 threshold[SensorData::legHL1][1] = 6600; threshold[SensorData::legHL2][1] = 2000;
00171 }
00172 else if (currentMotionX <= 360)
00173 {
00174 threshold[SensorData::legFL1][1] =11000; threshold[SensorData::legFL2][1] = 2000;
00175 threshold[SensorData::legHL1][1] =10000; threshold[SensorData::legHL2][1] = 2000;
00176 }
00177 else {
00178 threshold[SensorData::legFL1][1] =11000; threshold[SensorData::legFL2][1] = 3000;
00179 threshold[SensorData::legHL1][1] =12000; threshold[SensorData::legHL2][1] = 3300;
00180 }
00181
00182 threshold[SensorData::legFL1][2] += int(threshold[SensorData::legFL1][1] * scaleThresholdFore);
00183 threshold[SensorData::legFL2][2] += int(threshold[SensorData::legFL2][1] * scaleThresholdFore);
00184 threshold[SensorData::legHL1][2] += int(threshold[SensorData::legHL1][1] * scaleThresholdFore);
00185 threshold[SensorData::legHL2][2] += int(threshold[SensorData::legHL2][1] * scaleThresholdFore);
00186 }
00187
00188
00189
00190 else if ((currentMotionX < backMin) && (currentMotionX >= backMax))
00191 {
00192 walkingMode = 2;
00193
00194 if (currentMotionX >= -5)
00195 {
00196 threshold[SensorData::legFL1][1] = 1200; threshold[SensorData::legFL2][1] = 2500;
00197 threshold[SensorData::legHL1][1] = 3600; threshold[SensorData::legHL2][1] = 2100;
00198 }
00199 else if (currentMotionX >= -40)
00200 {
00201 threshold[SensorData::legFL1][1] = 1500; threshold[SensorData::legFL2][1] = 1500;
00202 threshold[SensorData::legHL1][1] = 4200; threshold[SensorData::legHL2][1] = 2700;
00203 }
00204 else if (currentMotionX >= -80)
00205 {
00206 threshold[SensorData::legFL1][1] = 1300; threshold[SensorData::legFL2][1] = 1000;
00207 threshold[SensorData::legHL1][1] = 7000; threshold[SensorData::legHL2][1] = 1500;
00208 }
00209 else if (currentMotionX >= -120)
00210 {
00211 threshold[SensorData::legFL1][1] = 1200; threshold[SensorData::legFL2][1] = 1200;
00212 threshold[SensorData::legHL1][1] = 8000; threshold[SensorData::legHL2][1] = 1200;
00213 }
00214 else if (currentMotionX >= -160)
00215 {
00216 threshold[SensorData::legFL1][1] = 1200; threshold[SensorData::legFL2][1] = 2000;
00217 threshold[SensorData::legHL1][1] = 6000; threshold[SensorData::legHL2][1] = 1500;
00218 }
00219 else if (currentMotionX >= -200)
00220 {
00221 threshold[SensorData::legFL1][1] = 2100; threshold[SensorData::legFL2][1] = 1300;
00222 threshold[SensorData::legHL1][1] = 9000; threshold[SensorData::legHL2][1] = 2200;
00223 }
00224 else if (currentMotionX >= -240)
00225 {
00226 threshold[SensorData::legFL1][1] = 5000; threshold[SensorData::legFL2][1] = 1300;
00227 threshold[SensorData::legHL1][1] = 8000; threshold[SensorData::legHL2][1] = 2000;
00228 }
00229 else
00230 {
00231 threshold[SensorData::legFL1][1] = 8000; threshold[SensorData::legHL1][1] = 2500;
00232 threshold[SensorData::legFL2][1] =12000; threshold[SensorData::legHL2][1] = 3000;
00233 }
00234 threshold[SensorData::legFL1][2] += int(threshold[SensorData::legFL1][1] * scaleThresholdBack);
00235 threshold[SensorData::legFL2][2] += int(threshold[SensorData::legFL2][1] * scaleThresholdBack);
00236 threshold[SensorData::legHL1][2] += int(threshold[SensorData::legHL1][1] * scaleThresholdBack);
00237 threshold[SensorData::legHL2][2] += int(threshold[SensorData::legHL2][1] * scaleThresholdBack);
00238 }
00239
00240
00241
00242 if (
00243 (fabs(currentMotionY) > sideMin) &&
00244 (fabs(currentMotionY) <= sideMax)
00245 )
00246 {
00247 walkingMode = walkingMode * 10 + 3;
00248
00249 if (fabs(currentMotionY) <= 5)
00250 {
00251 threshold[SensorData::legFL1][1] = 1500; threshold[SensorData::legFL2][1] = 12000;
00252 threshold[SensorData::legHL1][1] =13000; threshold[SensorData::legHL2][1] = 4500;
00253 }
00254 else if
00255 (fabs(currentMotionY) <= 40)
00256 {
00257 threshold[SensorData::legFL1][1] = 1500; threshold[SensorData::legFL2][1] = 14000;
00258 threshold[SensorData::legHL1][1] = 7500; threshold[SensorData::legHL2][1] = 4000;
00259 }
00260 else if
00261 (fabs(currentMotionY) <= 80)
00262 {
00263 threshold[SensorData::legFL1][1] = 2000; threshold[SensorData::legFL2][1] = 35000;
00264 threshold[SensorData::legHL1][1] = 8000; threshold[SensorData::legHL2][1] = 4000;
00265 }
00266 else if
00267 (fabs(currentMotionY) <= 120)
00268 {
00269 threshold[SensorData::legFL1][1] = 2000; threshold[SensorData::legFL2][1] = 160000;
00270 threshold[SensorData::legHL1][1] = 7000; threshold[SensorData::legHL2][1] = 5000;
00271 }
00272 else if
00273 (fabs(currentMotionY) <= 160)
00274 {
00275 threshold[SensorData::legFL1][1] = 2000; threshold[SensorData::legFL2][1] = 350000;
00276 threshold[SensorData::legHL1][1] = 6000; threshold[SensorData::legHL2][1] = 15000;
00277 }
00278 else if
00279 (fabs(currentMotionY) <= 200)
00280 {
00281 threshold[SensorData::legFL1][1] = 1800; threshold[SensorData::legFL2][1] = 900000;
00282 threshold[SensorData::legHL1][1] = 6500; threshold[SensorData::legHL2][1] = 30000;
00283 }
00284 else if
00285 (fabs(currentMotionY) <= 240)
00286 {
00287 threshold[SensorData::legFL1][1] = 1500; threshold[SensorData::legFL2][1] = 1050000;
00288 threshold[SensorData::legHL1][1] = 6000; threshold[SensorData::legHL2][1] = 35000;
00289 }
00290 else
00291 {
00292 threshold[SensorData::legFL1][1] = 3000; threshold[SensorData::legFL2][1] =1200000;
00293 threshold[SensorData::legHL1][1] =20000; threshold[SensorData::legHL2][1] = 40000;
00294 }
00295 }
00296
00297 threshold[SensorData::legFL1][2] += int(threshold[SensorData::legFL1][1] * scaleThresholdSide);
00298 threshold[SensorData::legFL2][2] += int(threshold[SensorData::legFL2][1] * scaleThresholdSide);
00299 threshold[SensorData::legHL1][2] += int(threshold[SensorData::legHL1][1] * scaleThresholdSide);
00300 threshold[SensorData::legHL2][2] += int(threshold[SensorData::legHL2][1] * scaleThresholdSide);
00301
00302
00303
00304 if ((fabs(currentRotation) > rotMin) && (fabs(currentRotation) <= rotMax))
00305 {
00306 walkingMode = walkingMode * 10 + 5;
00307
00308 if (fabs(currentRotation) <= 0.05)
00309 {
00310 threshold[SensorData::legFL1][1] = 600; threshold[SensorData::legFL2][1] = 1200;
00311 threshold[SensorData::legHL1][1] = 1800; threshold[SensorData::legHL2][1] = 2000;
00312 }
00313 else if (fabs(currentRotation) <= 0.5)
00314 {
00315 threshold[SensorData::legFL1][1] = 600; threshold[SensorData::legFL2][1] = 1200;
00316 threshold[SensorData::legHL1][1] = 1800; threshold[SensorData::legHL2][1] = 2000;
00317 }
00318 else if (fabs(currentRotation) <= 1.0)
00319 {
00320 threshold[SensorData::legFL1][1] = 1200; threshold[SensorData::legFL2][1] = 1500;
00321 threshold[SensorData::legHL1][1] = 4500; threshold[SensorData::legHL2][1] = 2000;
00322 }
00323 else if (fabs(currentRotation) <= 1.5)
00324 {
00325 threshold[SensorData::legFL1][1] = 1500; threshold[SensorData::legFL2][1] = 3000;
00326 threshold[SensorData::legHL1][1] = 3000; threshold[SensorData::legHL2][1] = 2700;
00327 }
00328 else if (fabs(currentRotation) <= 2.0)
00329 {
00330 threshold[SensorData::legFL1][1] = 2400; threshold[SensorData::legFL2][1] = 6000;
00331 threshold[SensorData::legHL1][1] = 3300; threshold[SensorData::legHL2][1] = 3600;
00332 }
00333 else if (fabs(currentRotation) <= 2.5)
00334 {
00335 threshold[SensorData::legFL1][1] = 3600; threshold[SensorData::legFL2][1] =20000;
00336 threshold[SensorData::legHL1][1] = 4500; threshold[SensorData::legHL2][1] = 4500;
00337 }
00338 else if (fabs(currentRotation) <= 3.0)
00339 {
00340 threshold[SensorData::legFL1][1] = 4500; threshold[SensorData::legFL2][1] =60000;
00341 threshold[SensorData::legHL1][1] = 6000; threshold[SensorData::legHL2][1] = 5000;
00342 }
00343 else if (fabs(currentRotation) <= 3.5)
00344 {
00345 threshold[SensorData::legFL1][1] = 4500; threshold[SensorData::legFL2][1] =60000;
00346 threshold[SensorData::legHL1][1] = 7500; threshold[SensorData::legHL2][1] = 6000;
00347 }
00348 else if (fabs(currentRotation) <= 4.0)
00349 {
00350 threshold[SensorData::legFL1][1] = 5500; threshold[SensorData::legFL2][1] =70000;
00351 threshold[SensorData::legHL1][1] = 9000; threshold[SensorData::legHL2][1] = 7000;
00352 }
00353
00354 else
00355 {
00356 threshold[SensorData::legFL1][1] = 6000; threshold[SensorData::legFL2][1] =75000;
00357 threshold[SensorData::legHL1][1] = 10000; threshold[SensorData::legHL2][1] = 7500;
00358 }
00359
00360 threshold[SensorData::legFL1][2] += int(threshold[SensorData::legFL1][1] * scaleThresholdRot);
00361 threshold[SensorData::legFL2][2] += int(threshold[SensorData::legFL2][1] * scaleThresholdRot);
00362 threshold[SensorData::legHL1][2] += int(threshold[SensorData::legHL1][1] * scaleThresholdRot);
00363 threshold[SensorData::legHL2][2] += int(threshold[SensorData::legHL2][1] * scaleThresholdRot);
00364 }
00365
00366
00367
00368 if (
00369 (
00370 (fabs(currentRotation) >= 0.75) &&
00371 (
00372 (fabs(currentMotionX) >= 100) ||
00373 (fabs(currentMotionY) >= 100 )
00374 )
00375 )
00376 ||
00377 (
00378 (fabs(currentMotionX) >= 100) &&
00379 (fabs(currentMotionY) >= 100)
00380 )
00381 )
00382 {
00383 threshold[SensorData::legFL1][2] *= 2;
00384 threshold[SensorData::legFL2][2] *= 2;
00385 threshold[SensorData::legHL1][2] *= 2;
00386 threshold[SensorData::legHL2][2] *= 2;
00387 }
00388
00389
00390
00391
00392 if (walkingMode == 0)
00393 {
00394 threshold[SensorData::legFL1][2] = infin;
00395 threshold[SensorData::legFL2][2] = infin;
00396 threshold[SensorData::legHL1][2] = infin;
00397 threshold[SensorData::legHL2][2] = infin;
00398 }
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 threshold[SensorData::neckTilt][2] = 20000;
00410 threshold[SensorData::headPan][2] = 300000;
00411 threshold[SensorData::headTilt][2] = 20000;
00412
00413
00414
00415
00416 threshold[SensorData::legFR1][2] = threshold[SensorData::legFL1][2];
00417 threshold[SensorData::legFR2][2] = threshold[SensorData::legFL2][2];
00418 threshold[SensorData::legHR1][2] = threshold[SensorData::legHL1][2];
00419 threshold[SensorData::legHR2][2] = threshold[SensorData::legHL2][2];
00420
00421 }
00422
00423
00424
00425 void GT2004CollisionDetector::execute()
00426 {
00427 collisionPercept.setFrameNumber(sensorDataBuffer.frame[0].frameNumber);
00428 currentMotionX = motionInfo.executedMotionRequest.walkRequest.walkParams.translation.x;
00429 currentMotionY = motionInfo.executedMotionRequest.walkRequest.walkParams.translation.y;
00430 currentRotation = motionInfo.executedMotionRequest.walkRequest.walkParams.rotation;
00431 walkingMode = 0;
00432
00433 collisionPercept.state[JointData::legFL3] = 0;
00434 collisionPercept.state[JointData::legHL3] = 0;
00435 collisionPercept.state[JointData::legFR3] = 0;
00436 collisionPercept.state[JointData::legHR3] = 0;
00437
00438
00439 for (int i = 0; i < SensorData::numOfSensor_ERS210; i++)
00440 {
00441
00442 if ((i == SensorData::neckTilt) || (i == SensorData::headPan) ||
00443 (i == SensorData::headTilt) ||
00444 (i == SensorData::legFL1) || (i == SensorData::legFL2) ||
00445 (i == SensorData::legHL1) || (i == SensorData::legHL2) ||
00446 (i == SensorData::legFR1) || (i == SensorData::legFR2) ||
00447 (i == SensorData::legHR1) || (i == SensorData::legHR2))
00448 {
00449 for (int quarter = 0; quarter < sensorDataBuffer.numOfFrames; quarter++)
00450 {
00451 int current = index + quarter;
00452
00453 min = 5;
00454 max = 12;
00455 minAvg[i][current%SensorDataBuffer::maxNumOfFrames] = min;
00456
00457
00458 for (int d = min; d <= max; d++)
00459 {
00460
00461 oldVal = (int)(((ringBuffer[i][(current + 128 - q)%128][0] -
00462 ringBuffer[i][(current + 128 - q - d)%128][1])*
00463 (ringBuffer[i][(current + 128 - q)%128][0] -
00464 ringBuffer[i][(current + 128 - q - d)%128][1]))/12);
00465
00466
00467
00468 ringBuffer[i][current%128][0] = (int)(sensorDataBuffer.frame[quarter].data[i]/32);
00469 ringBuffer[i][current%128][1] = (int)(sensorDataBuffer.frame[quarter].refValue[i]/32);
00470
00471 if (current < 16)
00472 {
00473 ringBuffer[i][current%128][0] = 0;
00474 }
00475
00476
00477
00478 newVal = (int)(((ringBuffer[i][current%128][0] -
00479 ringBuffer[i][(current + 128 - d)%128][1])*
00480 (ringBuffer[i][current%128][0] -
00481 ringBuffer[i][(current + 128 - d)%128][1]))/12);
00482
00483
00484 floatingAvg[i][current%SensorDataBuffer::maxNumOfFrames][d] = newVal - oldVal +
00485 floatingAvg[i][(current+SensorDataBuffer::maxNumOfFrames-1)%SensorDataBuffer::maxNumOfFrames][d];
00486
00487
00488 if (floatingAvg[i][current%SensorDataBuffer::maxNumOfFrames][d] < floatingAvg[i][current%SensorDataBuffer::maxNumOfFrames][minAvg[i][current%SensorDataBuffer::maxNumOfFrames]])
00489 {
00490 minAvg[i][current%SensorDataBuffer::maxNumOfFrames] = d;
00491 }
00492 }
00493 }
00494 }
00495 }
00496
00497
00498 xRatio = fabs(currentMotionX-lastMotionX);
00499 yRatio = fabs(currentMotionY-lastMotionY);
00500 rRatio = fabs(currentRotation-lastRotation);
00501
00502 collisionPercept.reset();
00503
00504
00505 if
00506 (
00507 (motionChangeThresholdX < xRatio) ||
00508 (motionChangeThresholdY < yRatio) ||
00509 (motionChangeThresholdR < rRatio)
00510 )
00511 {
00512 lastMotionChange = 0;
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527 }
00528
00529
00530 if (lastMotionChange <= calmDown)
00531 {
00532
00533
00534
00535
00536
00537
00538 motionChangeThresholdFactor = 1000000;
00539 if (lastMotionChange == calmDown)
00540 {
00541 motionChangeThresholdFactor = 1;
00542 }
00543
00544 }
00545
00546 if ((motionInfo.executedMotionRequest.motionType==MotionRequest::walk) &&
00547 (motionInfo.executedMotionRequest.walkRequest.walkType==WalkRequest::normal))
00548
00549 {
00550 calculateThresholds();
00551
00552 collisionPercept.state[JointData::neckTilt] = floatingAvg[SensorData::neckTilt][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::neckTilt][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::neckTilt][2];
00553 collisionPercept.state[JointData::headPan] = floatingAvg[SensorData::headPan][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::headPan][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::headPan][2];
00554 collisionPercept.state[JointData::headTilt] = floatingAvg[SensorData::headTilt][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::headTilt][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::headTilt][2];
00555
00556 collisionPercept.state[JointData::legFL1] = floatingAvg[SensorData::legFL1][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFL1][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFL1][2] / motionChangeThresholdFactor;
00557 collisionPercept.state[JointData::legFR1] = floatingAvg[SensorData::legFR1][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFR1][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFR1][2] / motionChangeThresholdFactor;
00558 collisionPercept.state[JointData::legHL1] = floatingAvg[SensorData::legHL1][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHL1][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHL1][2] / motionChangeThresholdFactor;
00559 collisionPercept.state[JointData::legHR1] = floatingAvg[SensorData::legHR1][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHR1][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHR1][2] / motionChangeThresholdFactor;
00560
00561 collisionPercept.state[JointData::legFL2] = floatingAvg[SensorData::legFL2][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFL2][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFL2][2] / motionChangeThresholdFactor;
00562 collisionPercept.state[JointData::legFR2] = floatingAvg[SensorData::legFR2][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFR2][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFR2][2] / motionChangeThresholdFactor;
00563 collisionPercept.state[JointData::legHL2] = floatingAvg[SensorData::legHL2][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHL2][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHL2][2] / motionChangeThresholdFactor;
00564 collisionPercept.state[JointData::legHR2] = floatingAvg[SensorData::legHR2][index%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHR2][index%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHR2][2] / motionChangeThresholdFactor;
00565
00566
00567
00568 for (int current = index + 1; current < (index + sensorDataBuffer.numOfFrames); current++)
00569 {
00570 if (collisionPercept.state[JointData::neckTilt] < floatingAvg[SensorData::neckTilt][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::neckTilt][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::neckTilt][2])
00571 {collisionPercept.state[JointData::neckTilt] = floatingAvg[SensorData::neckTilt][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::neckTilt][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::neckTilt][2];}
00572
00573 if (collisionPercept.state[JointData::headPan] < floatingAvg[SensorData::headPan][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::headPan][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::headPan][2])
00574 {collisionPercept.state[JointData::headPan] = floatingAvg[SensorData::headPan][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::headPan][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::headPan][2];}
00575
00576 if (collisionPercept.state[JointData::headTilt] < floatingAvg[SensorData::headTilt][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::headTilt][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::headTilt][2])
00577 {collisionPercept.state[JointData::headTilt] = floatingAvg[SensorData::headTilt][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::headTilt][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::headTilt][2];}
00578
00579
00580
00581 if (collisionPercept.state[JointData::legFL1] < floatingAvg[SensorData::legFL1][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFL1][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFL1][2] / motionChangeThresholdFactor)
00582 {collisionPercept.state[JointData::legFL1] = floatingAvg[SensorData::legFL1][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFL1][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFL1][2] / motionChangeThresholdFactor;}
00583
00584 if (collisionPercept.state[JointData::legFR1] < floatingAvg[SensorData::legFR1][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFR1][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFR1][2] / motionChangeThresholdFactor)
00585 {collisionPercept.state[JointData::legFR1] = floatingAvg[SensorData::legFR1][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFR1][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFR1][2] / motionChangeThresholdFactor;}
00586
00587 if (collisionPercept.state[JointData::legHL1] < floatingAvg[SensorData::legHL1][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHL1][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHL1][2] / motionChangeThresholdFactor)
00588 {collisionPercept.state[JointData::legHL1] = floatingAvg[SensorData::legHL1][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHL1][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHL1][2] / motionChangeThresholdFactor;}
00589
00590 if (collisionPercept.state[JointData::legHR1] < floatingAvg[SensorData::legHR1][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHR1][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHR1][2] / motionChangeThresholdFactor)
00591 {collisionPercept.state[JointData::legHR1] = floatingAvg[SensorData::legHR1][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHR1][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHR1][2] / motionChangeThresholdFactor;}
00592
00593
00594
00595 if (collisionPercept.state[JointData::legFL2] < floatingAvg[SensorData::legFL2][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFL2][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFL2][2] / motionChangeThresholdFactor)
00596 {collisionPercept.state[JointData::legFL2] = floatingAvg[SensorData::legFL2][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFL2][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFL2][2] / motionChangeThresholdFactor;}
00597
00598 if (collisionPercept.state[JointData::legFR2] < floatingAvg[SensorData::legFR2][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFR2][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFR2][2] / motionChangeThresholdFactor)
00599 {collisionPercept.state[JointData::legFR2] = floatingAvg[SensorData::legFR2][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legFR2][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legFR2][2] / motionChangeThresholdFactor;}
00600
00601 if (collisionPercept.state[JointData::legHL2] < floatingAvg[SensorData::legHL2][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHL2][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHL2][2] / motionChangeThresholdFactor)
00602 {collisionPercept.state[JointData::legHL2] = floatingAvg[SensorData::legHL2][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHL2][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHL2][2] / motionChangeThresholdFactor;}
00603
00604 if (collisionPercept.state[JointData::legHR2] < floatingAvg[SensorData::legHR2][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHR2][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHR2][2] / motionChangeThresholdFactor)
00605 {collisionPercept.state[JointData::legHR2] = floatingAvg[SensorData::legHR2][current%SensorDataBuffer::maxNumOfFrames][minAvg[SensorData::legHR2][current%SensorDataBuffer::maxNumOfFrames]] / threshold[SensorData::legHR2][2] / motionChangeThresholdFactor;}
00606 }
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721 }
00722 index += sensorDataBuffer.numOfFrames;
00723 lastMotionChange += sensorDataBuffer.numOfFrames;
00724 lastMotionX = currentMotionX;
00725 lastMotionY = currentMotionY;
00726 lastRotation= currentRotation;
00727 }
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860