der Roboter / Mbed 2 deprecated Roboter

Dependencies:   m3pi_ng mbed

Files at this revision

API Documentation at this revision

Comitter:
akul
Date:
Wed May 28 13:13:49 2014 +0000
Parent:
2:d439dbbc522f
Commit message:
redid code for startpoint 1 -- includes any and all potential intersections (i.e. intersections + corners)

Changed in this revision

Mapping.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Mapping.cpp	Wed May 28 11:29:42 2014 +0000
+++ b/Mapping.cpp	Wed May 28 13:13:49 2014 +0000
@@ -16,60 +16,27 @@
     switch(startpoint){
         case 1:
             if(endpoint == 2){
-                while(count < 2){
+                while(count < 4){
                     if(intersection == true){
                         count++;
                         intersection = false;
                         if(count == 1){
-                            thinggy.left(speed);
+                            thinggy.right(speed);
                         }
                         if(count == 2){
                             thinggy.left(speed);
                         }
+                        if(count == 3){
+                            thinggy.left(speed);
+                        }
+                        if(count == 4){
+                            thinggy.right(speed);
+                        }
                     }
                 }
                 count = 0;
             }
             else if(endpoint == 3){
-                while(count < 3){
-                    if(intersection == true){
-                        count++;
-                        intersection = false;
-                        if(count == 1){
-                            thinggy.left(speed);
-                        }
-                        if(count == 2){
-                            thinggy.forward(speed);
-                        }
-                        if(count == 2){
-                            thinggy.forward(speed);
-                        }
-                    }
-                }
-                count = 0;
-                }
-            else if(endpoint == 4){
-                while(count < 4){
-                    if(intersection == true){
-                        count++;
-                        intersection = false;
-                        if(count == 1){
-                            thinggy.left(speed);
-                        }
-                        if(count == 2){
-                            thinggy.forward(speed);
-                        }
-                        if(count == 3){
-                            thinggy.right(speed);
-                        }
-                        if(count == 4){
-                            thinggy.left(speed);
-                        }
-                    }
-                }
-                count = 0;
-                }
-            else if(endpoint == 5){
                 while(count < 4){
                     if(intersection == true){
                         count++;
@@ -78,28 +45,94 @@
                             thinggy.right(speed);
                         }
                         if(count == 2){
+                            thinggy.left(speed);
+                        }
+                        if(count == 3){
+                            thinggy.forward(speed);
+                        }
+                        if(count == 4){
                             thinggy.forward(speed);
                         }
+                    }
+                }
+                count = 0;
+                }
+            else if(endpoint == 4){
+                while(count < 5){
+                    if(intersection == true){
+                        count++;
+                        intersection = false;
+                        if(count == 1){
+                            thinggy.right(speed);
+                        }
+                        if(count == 2){
+                            thinggy.left(speed);
+                        }
                         if(count == 3){
-                            thinggy.right(speed);
+                            thinggy.forward(speed);
                         }
                         if(count == 4){
                             thinggy.right(speed);
                         }
+                        if(count == 5){
+                            thinggy.left(speed);
+                        }
+                    }
+                }
+                count = 0;
+                }
+            else if(endpoint == 5){
+                while(count < 9){
+                    if(intersection == true){
+                        count++;
+                        intersection = false;
+                        if(count == 1){
+                            thinggy.right(speed);
+                        }
+                        if(count == 2){
+                            thinggy.right(speed);
+                        }
+                        if(count == 3){
+                            thinggy.left(speed);
+                        }
+                        if(count == 4){
+                            thinggy.forward(speed);
+                        }
+                        if(count == 5){
+                            thinggy.left(speed);
+                        }
+                        if(count == 6){
+                            thinggy.right(speed);
+                        }
+                        if(count == 7){
+                            thinggy.right(speed);
+                        }
+                        if(count == 8){
+                            thinggy.right(speed);
+                        }
+                        if(count == 9){
+                            thinggy.left(speed);
+                        }
                     }
                 }
                 count = 0;
                 }
             else if(endpoint == 6){
-                while(count < 2){
+                while(count < 4){
                     if(intersection == true){
                         count++;
                         intersection = false;
                         if(count == 1){
+                            thinggy.right(speed);
+                        }
+                        if(count == 2){
+                            thinggy.right(speed);
+                        }
+                        if(count == 3){
                             thinggy.left(speed);
                         }
-                        if(count == 2){
-                            thinggy.forward(speed);
+                        if(count == 4){
+                            thinggy.right(speed);
                         }
                     }
                 }