Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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