Code to run the microcontrollers on the R5 competition bot

Dependencies:   LineSensors mbed

Revision:
18:2bd595af51d2
Parent:
17:5046b27f5441
Child:
19:9f4510646c9e
--- a/r5map.h	Sat Apr 18 03:02:28 2015 +0000
+++ b/r5map.h	Sat Apr 18 03:13:27 2015 +0000
@@ -1,27 +1,61 @@
-#include "DriveController.h"
- 
-int main()
+#ifndef R5_MAP
+#define R5_MAP
+
+#include <vector>
+
+using namespace std;
+
+struct position
+{
+    position(int xx = 0, int yy = 0) : x(xx), y(yy) {}
+    inline bool operator==(const typename ::position& rhs){return ((x==rhs.x) && (y==rhs.y)); }
+    inline bool operator!=(const typename ::position& rhs){return !operator==(rhs);}
+    int x,y;
+};
+
+enum wallState { OPEN, CLOSED, UNKNOWN };
+enum direction { NORTH, EAST, SOUTH, WEST };
+
+struct Cell
+{
+    Cell() : north(UNKNOWN), south(UNKNOWN), east(UNKNOWN), west(UNKNOWN), visited(false) {}
+    wallState north;
+    wallState south;
+    wallState east;
+    wallState west;
+    bool visited ;
+    int number;
+};
+
+class R5Map
 {
-    DriveController myWheels;
-    
-    myWheels.sensors.setThreshold();
-    
-    wait(10);
-    
-    myWheels.treadSpeed1.period_us(50);  //setting pwm period for all wheels to 20khz
-    myWheels.treadSpeed2.period_us(50);
-    
-    //spinTest();
-    
-    while(true) //test loop
-    {
-        myWheels.move(FORWARD);
-        wait(0.5);
-        myWheels.move(FORWARD);
-        wait(0.5);
-        myWheels.rotate((myWheels.orient+2)%4);
-        wait(0.5);
-    }
-    
-    return 0;
-}
\ No newline at end of file
+    public:
+    R5Map(int conSize = DEFAULT_SIZE);
+    void setPosition(position cell);
+    void setStart(position newStart);
+    void setFinish(position newFin);
+    void setWall(position cell, direction dir, wallState state);
+    void setCurWall(direction dir, wallState state);
+    void setVisited(position cell);
+    void setCurVisited();
+    position getPosition() const;
+    position getStart() const;
+    position getFinish() const;
+    wallState getWall(position cell, direction dir) const;
+    wallState getCurWall(direction dir) const;
+    bool getVisited(position cell) const;
+    bool getCurVisited() const;
+    int getSize() const;
+    void printMap() const;
+    ~R5Map();
+
+    private:
+    static const int DEFAULT_SIZE = 5;
+    Cell map[7][7];
+    int size;
+    position pos; //X,Y
+    position start;
+    position fin;
+};
+
+#endif