Alpha Tango / Mbed 2 deprecated R5_Robotics

Dependencies:   mbed

Revision:
9:a5a6d3a48145
Parent:
8:a6080c27f8c5
Child:
10:ed6ecbb420b8
diff -r a6080c27f8c5 -r a5a6d3a48145 main.cpp
--- a/main.cpp	Sat Mar 31 21:43:07 2018 +0000
+++ b/main.cpp	Sat Mar 31 23:16:56 2018 +0000
@@ -31,7 +31,7 @@
 void turnLeft(float, bool);
 void rot180(); //Turns the robot around
 int findColor(); //Figures out what color the disk is and makes a decision on where to take the disk
-void findPath(int color, int i); //Determines where to take the token based on the color and its relative location
+void findPath(int color, int i, float scale, float); //Determines where to take the token based on the color and its relative location
  
 
 //    GLOBAL VARIABLES
@@ -128,9 +128,10 @@
     
     while(true)
      { 
-        for(int i = 0; i <=8; i++) //begin motion around Nth perimeter
+        for(int i = 0; i <=7; i++) //begin motion around Nth perimeter   ::No token on one length of the track so we may want to revise this
         {   
             leg = 0.762; //2.5 feet in meters 
+            scale = 1; 
             if(i % 2 == 0)
             {
                 turnRight(); 
@@ -143,21 +144,14 @@
             }
             else 
             {
-                findPath(color, i);
+                findPath(color, i, leg);
                 dropToken(); 
                 //returnPrevious(); 
             }
             move(leg, FORWARD); 
                
         }
-       /* grabToken(); 
-        move(1,FORWARD);
-        turnLeft();
-        wait(0.5);
-        turnLeft();
-        wait(2); 
-        dropToken(); 
-        wait(2);*/
+       
      }
 }
 
@@ -326,9 +320,269 @@
         //pc.printf("Clear (%d), Red (%d), Green (%d), Blue (%d)\n", clear_value, red_value, green_value, blue_value);
         //wait(0.5);
     }
-void findPath(int color, int i)
+void findPath(int color, int i, float scale) //This function decides where to go based on its reletive position and the color written in from the findColor function. Indexes/Positions 3 & 7 not used
+                                             //          3          
+                                             //2*--------*--------*4
+                                             // |                 |
+                                             // |                 |
+                                             // |                 |
+                                             // |                 |
+                                             //1*                 *5
+                                             // |                 |
+                                             // |                 |
+                                             // |                 |
+                                             // |                 |
+                                             // *--------*--------*6
+                                             // 0        7   
+                                             
 {
+    /*******************************************************************///Red
+    if( i == 0 && color == 1 )
+    {
+        //condition for return red at index 0
+        
+    }
+     if( i == 1 && color == 1 )
+    {
+        //condition for return red at index 1
+        
+    }
+     if( i == 2 && color == 1 )
+    {
+        //condition for return red at index 2
+        
+    }
+     if( i == 4 && color == 1 )
+    {
+        //condition for return red at index 4
+        
+    }
+     if( i == 5 && color == 1 )
+    {
+        //condition for return red at index 5
+        
+    }
+     if( i == 6 && color == 1 )
+    {
+        //condition for return red at index 5
+        
+    }
+     
+    /*******************************************************************///Green 
+    if( i == 0 && color == 2 )
+    {
+        //condition for return Green at index 0
+        
+    }
+     if( i == 1 && color == 2 )
+    {
+        //condition for return green at index 1
+        
+    }
+     if( i == 2 && color == 2 )
+    {
+        //condition for return green at index 2
+        
+    }
     
+     if( i == 4 && color == 2 )
+    {
+        //condition for return green at index 4
+        
+    }
+     if( i == 5 && color == 2 )
+    {
+        //condition for return green at index 5
+        
+    }
+     if( i == 6 && color == 2 )
+    {
+        //condition for return green at index 6
+        
+    }
+    /*******************************************************************///Blue
+    if( i == 0 && color == 3 )//condition for return Blue at index 0 ::
+    {
+        rot180(); 
+        move(0.3048*scale, FORWARD); 
+        turnRight(); 
+        move(0.3048*scale, FORWARD); 
+        break; 
+        
+    }
+     if( i == 1 && color == 3 ) //condition for return blue at index 1
+    {
+        rot180(); 
+        move((leg + 0.3048*scale, FORWARD); 
+        turnRight(); 
+        move(0.3048*scale, FORWARD); 
+        break;      
+        
+    }
+     if( i == 2 && color == 3 ) //condition for return blue at index 2
+    {
+        rot180(); 
+        move((2*leg + 0.3048*scale, FORWARD); 
+        turnRight();  
+        move(0.3048*scale, FORWARD); 
+        break;
+        
+    }
+     if( i == 4 && color == 3 ) //condition for return blue at index 4
+    { 
+        move((2*leg + 0.3048*scale, FORWARD); 
+        turnRight();  
+        move(2*leg + 0.3048*scale, FORWARD); 
+        break;
+        
+    }
+     if( i == 5 && color == 3 ) //condition for return blue at index 5
+    {
+        move(leg + 0.3048*scale, FORWARD); 
+        turnRight();  
+        move(2*leg + 0.3048*scale, FORWARD); 
+        break;
+        
+    }
+     if( i == 6 && color == 3 ) //condition for return blue at index 5
+    {
+       move(2*leg + 0.3048*scale);
+       turnLeft(); 
+       move(0.3048*scale, FORWARD);  
+       break;
+        
+    }
+    else break; 
+     
+    /*******************************************************************///Cyan
+    if( i == 0 && color == 4 )
+    {
+        //condition for return Cyan at index 0
+        
+    }
+     if( i == 1 && color == 4 )
+    {
+        //condition for return Cyan at index 1
+        
+    }
+     if( i == 2 && color == 4 )
+    {
+        //condition for return Cyan at index 2
+        
+    }
+     if( i == 4 && color == 4 )
+    {
+        //condition for return Cyan at index 4
+        
+    }
+     if( i == 5 && color == 4 )
+    {
+        //condition for return Cyan at index 5
+        
+    }
+     if( i == 6 && color == 4 )
+    {
+        //condition for return Cyan at index 6
+        
+    }
+    else break; 
+    /*******************************************************************///Magenta
+    if( i == 0 && color == 5 )
+    {
+        //condition for return Magenta at index 0
+        
+    }
+     if( i == 1 && color == 5 )
+    {
+        //condition for return Magenta at index 1
+        
+    }
+     if( i == 2 && color == 5 )
+    {
+        //condition for return Magenta at index 2
+        
+    }
+     if( i == 4 && color == 5 )
+    {
+        //condition for return Magenta at index 4
+        
+    }
+     if( i == 5 && color == 5 )
+    {
+        //condition for return Magenta at index 5
+        
+    }
+     if( i == 6 && color == 5 )
+    {
+        //condition for return Magenta at index 6
+        
+    }
+    else break; 
+    /*******************************************************************///Yellow
+    if( i == 0 && color == 6 )
+    {
+        //condition for return Yellow at index 0
+        
+    }
+     if( i == 1 && color == 6 )
+    {
+        //condition for return Yellow at index 1
+        
+    }
+     if( i == 2 && color == 6 )
+    {
+        //condition for return Yellow at index 2
+        
+    }
+     if( i == 4 && color == 6 )
+    {
+        //condition for return Yellow at index 4
+        
+    }
+     if( i == 5 && color == 6 )
+    {
+        //condition for return Yellow at index 5
+        
+    }
+     if( i == 6 && color == 6 )
+    {
+        //condition for return Yellow at index 6
+        
+    }
+    else break; 
+    /*******************************************************************///Gray
+    if( i == 0 && color == 7 )
+    {
+        //condition for return Gray at index 0
+        
+    }
+     if( i == 1 && color == 7 )
+    {
+        //condition for return Gray at index 1
+        
+    }
+     if( i == 2 && color == 7 )
+    {
+        //condition for return Gray at index 2
+        
+    }
+     if( i == 4 && color == 7 )
+    {
+        //condition for return Gray at index 4
+        
+    }
+     if( i == 5 && color == 7 )
+    {
+        //condition for return Gray at index 5
+        
+    }
+     if( i == 6 && color == 7 )
+    {
+        //condition for return Gray at index 6
+        
+    }
+    else break; 
+    /*******************************************************************/
     
 }
 }
\ No newline at end of file