![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Code to run the microcontrollers on the R5 competition bot
Dependencies: LineSensors mbed
Diff: navcontroller.h
- Revision:
- 17:5046b27f5441
- Child:
- 19:9f4510646c9e
diff -r b49db5c8e16c -r 5046b27f5441 navcontroller.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/navcontroller.h Sat Apr 18 03:02:28 2015 +0000 @@ -0,0 +1,42 @@ +#ifndef NAVCONTROLLER_H +#define NAVCONTROLLER_H + +#include "r5map.h" +#include <stack> +#include <vector> + +#define SENS_FORWARD 7 +#define SENS_RIGHT 0 +#define SENS_BACK 2 +#define SENS_LEFT 3 +#define PIN_INT_1 4 +#define PIN_INT_2 5 +#define FRDM_ADD 0x0A + +class NavController +{ + public: + NavController(int mapSize = 5); + void explore(); //moves bot through the unknown maze + void goBack(); //returns bot to the origin + void saveMap(); //saves map information to file + void pinWrite(int, int); + void waitingForInterrupt(int, int); + void testWithDelay(); + void testWithoutDelay(); + + private: + typename ::position end; + typename ::direction nextExploreMove(); //calculates the next move in maze exploration + void sendMove(typename ::direction next); //sends a move command to the freedom board via i2c + void updateMap(); //records all the sensor information into the map object + bool readSensor(typename ::direction wall); //returns true if there is a wall in direction "wall" + char readWall(typename ::direction wall); //returns the character written on the wall in the direction of 'wall' + + typename ::R5Map map; + typename ::direction orient; //current orientation of the bot + stack<typename ::direction> path; //a record of the bots path + void initIO(); +}; + +#endif