just a test

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

Revision:
45:a3b984a79d5d
Parent:
44:46e25fa1669b
Child:
46:90516893793a
--- a/rigidLoop.cpp	Mon Mar 31 10:57:35 2014 +0000
+++ b/rigidLoop.cpp	Tue Apr 01 10:08:49 2014 +0000
@@ -25,7 +25,7 @@
     startSpeed=_initSpeed;
 
     // (2) Initialize common variables of all blobs (base class):
-    initCommonVariables();
+    //initCommonVariables();
 
     // (3) initialize common variables for the different modes of this rigid loop (even if some are not used, better not to have more subclasses...)
     // Sending data:
@@ -50,7 +50,8 @@
 
             //setColor(0x07);//0x04+0x02>>i);
             setColor(0x04); // only red?
-
+             blueTouch=true;
+             
             saccadeRadius=250;
 
             // default (initial) shape (the scafold belongs to the base class):
@@ -77,6 +78,7 @@
 
             //setColor(0x07);//0x04+0x02>>i);
             setColor(0x04);
+             blueTouch=false;
 
             saccadeRadius=45;//+rand()%20;
             // default (initial) shape (the scafold belongs to the base class):
@@ -92,8 +94,8 @@
             // per-blob mirror delay (if things were well adjusted - in particular mirror waiting times, then this could be 0.
             // But in case of unique blobs, it may be interesting to accelerate display AND correct the delay by software).
             // Even more interesting: in case of rigid circular blob, this can be coorected using angleCorrectionForceLoop:
-            displaySensingBuffer.setDelayMirrors(3);
-            angleCorrectionForceLoop=-5;// in degrees
+            displaySensingBuffer.setDelayMirrors(2);
+            angleCorrectionForceLoop=-35;// in degrees
 
             break;
 
@@ -103,6 +105,7 @@
 
             //setColor(0x07);//0x04+0x02>>i);
             setColor(0x04);
+            blueTouch=false;
 
             saccadeRadius=45;//+rand()%20;
             // default (initial) shape (the scafold belongs to the base class):
@@ -114,6 +117,8 @@
 
             // Finally, we can create the loop (not much to do in this case, only set the central position, and some other things):
             createLoopFromScafold();
+            
+            justSearched=false;
 
             // per-blob mirror delay (if things were well adjusted - in particular mirror waiting times, then this could be 0.
             // But in case of unique blobs, it may be interesting to accelerate display AND correct the delay by software).
@@ -130,7 +135,8 @@
 
             //setColor(0x07);//0x04+0x02>>i);
             setColor(0x04); //only R
-
+            blueTouch=false;
+            
             // default (initial) shape (the scafold belongs to the base class):
             saccadeRadius=30;//23;
             bluePrint.buildCircularScafold(saccadeRadius, vector2Dd(0,0), 20); //(float _radius, vector2D _pos,vector2D _vel, int _numScafoldPoints);
@@ -162,7 +168,8 @@
             sprintf(spotName,"rigid_bouncing");
 
             setColor(0x05);// R+B
-
+            blueTouch=false;
+            
             saccadeRadius=30;//+rand()%20;
             // default (initial) shape (the scafold belongs to the base class):
             bluePrint.buildCircularScafold(saccadeRadius, vector2Dd(0,0), 18); //(float _radius, vector2D _pos,vector2D _vel, int _numScafoldPoints);
@@ -188,7 +195,8 @@
             sprintf(spotName,"rigid_bouncing");
 
             setColor(0x05);
-
+            blueTouch=false;
+            
             saccadeRadius=30;//+rand()%20;
             // default (initial) shape (the scafold belongs to the base class):
             bluePrint.buildCircularScafold(saccadeRadius, vector2Dd(0,0), 18); //(float _radius, vector2D _pos,vector2D _vel, int _numScafoldPoints);
@@ -221,7 +229,8 @@
 
             //setColor(0x07);//0x04+0x02>>i);
             setColor(0x06); // red+green = yellowish
-
+            blueTouch=false;
+            
             saccadeRadius=35;//+rand()%20;
             // default (initial) shape (the scafold belongs to the base class):
             bluePrint.buildCircularScafold(saccadeRadius, vector2Dd(0,0), 18); //(float _radius, vector2D _pos,vector2D _vel, int _numScafoldPoints);
@@ -257,7 +266,8 @@
             // Make it blueish by default:
             //setColor(0x07);//0x04+0x02>>i);
             setColor(0x05); // red + blue
-
+            blueTouch=false;
+            
             massCenter=1.0;
             dampMotionCenterMass=0; // no motion damp (but there will be no forces: only constant uniform motion)
             factorBouncingForce=0; //actually not used.
@@ -294,7 +304,8 @@
 
             //setColor(0x07);//0x04+0x02>>i);
             setColor(0x04);
-
+            blueTouch=false;
+            
             gravity.set(0,0);
 
             saccadeRadius=50;//+rand()%20;
@@ -323,7 +334,8 @@
 
             //setColor(0x07);//0x04+0x02>>i);
             setColor(0x04);
-
+            blueTouch=false;
+            
             saccadeRadius=20;//+rand()%20;
             // default (initial) shape (the scafold belongs to the base class):
             bluePrint.buildCircularScafold(saccadeRadius, vector2Dd(0,0), 18); //(float _radius, vector2D _pos, int _numScafoldPoints);
@@ -343,6 +355,8 @@
             angleCorrectionForceLoop=-5;// in degrees
 
             break;
+            default:
+            break;
     }
 
     saccadeRadius_initial=saccadeRadius; // this is for search mode for instance.
@@ -510,9 +524,23 @@
             break;
             // ================================================================
         case  SPOT_TRACK:
+        if (displaySensingBuffer.lightTouched) {
             centerMass.pos +=recenteringVectorLoop;
             centerMass.posOld=centerMass.pos; // this is necessary to compute bouceOffWalls using Verlet method... (MAKE A new variable INTEGRATION METHOD?)
             centerMass.bounceOffWalls(); // constrain position (and compute wall "hit")
+            
+                if (justSearched) {
+                    saccadeRadius=saccadeRadius_initial;
+                    bluePrint.buildCircularScafold(saccadeRadius, vector2Dd(0,0), numPoints);
+                    justSearched=false;
+                }
+
+            } else if (displaySensingBuffer.lightState==ALL_DARK) { // not touched nor on something white: SEARCH MODE
+                saccadeRadius+=20;
+                if (saccadeRadius>800) saccadeRadius=saccadeRadius_initial;
+                bluePrint.buildCircularScafold(saccadeRadius, vector2Dd(0,0), numPoints);
+                justSearched=true;
+            }
 
             // Change color with touch? YES
             if (displaySensingBuffer.lightTouched)