asdf

Dependencies:   L3GD20 LSM303DLHC mbed

Committer:
goy5022
Date:
Thu Apr 03 23:58:04 2014 +0000
Revision:
8:ce5b1bf38077
Parent:
7:95ebadc83fc7
asdf

Who changed what in which revision?

UserRevisionLine numberNew contents of line
goy5022 2:997f57aee3b7 1 //#include "Core.h"
goy5022 0:c2ec30f28676 2
goy5022 2:997f57aee3b7 3 #include "Sensors.h"
goy5022 7:95ebadc83fc7 4 #include "PID.h"
goy5022 2:997f57aee3b7 5 #include "Communication.h"
goy5022 2:997f57aee3b7 6 #include "Flooding.h"
goy5022 7:95ebadc83fc7 7 #include "Movement.h"
goy5022 0:c2ec30f28676 8
goy5022 2:997f57aee3b7 9 #include "BufferAverage.h"
goy5022 2:997f57aee3b7 10 #include "ExponentialAverage.h"
goy5022 2:997f57aee3b7 11 //#include "WeightedAverage.h"
goy5022 0:c2ec30f28676 12
goy5022 0:c2ec30f28676 13 int main()
goy5022 0:c2ec30f28676 14 {
goy5022 0:c2ec30f28676 15 Motor.baud(115200);
goy5022 3:1a8a7cc709cc 16 ledF.period_us(26.3); //28.5 //27.9
goy5022 2:997f57aee3b7 17 wait_us(600);
goy5022 3:1a8a7cc709cc 18 ledF.write(.5);
goy5022 2:997f57aee3b7 19 stop_mov();
goy5022 2:997f57aee3b7 20
goy5022 2:997f57aee3b7 21
goy5022 3:1a8a7cc709cc 22 wait(3);
goy5022 2:997f57aee3b7 23 /*
goy5022 7:95ebadc83fc7 24
goy5022 2:997f57aee3b7 25 STEVE!!!!!!
goy5022 2:997f57aee3b7 26 WHENEVER YOU ARE IN A CELL AND YOU WANT TO KNOW WHAT THE NEXT BEST MOVE IS
goy5022 2:997f57aee3b7 27 USE THE flood_findPath(x, y) where x and y are your current possition
goy5022 2:997f57aee3b7 28
goy5022 2:997f57aee3b7 29 the function will return a MOVE type
goy5022 2:997f57aee3b7 30 and you can use something similar to this:
goy5022 7:95ebadc83fc7 31
goy5022 2:997f57aee3b7 32 i've written the code for the following:
goy5022 2:997f57aee3b7 33
goy5022 2:997f57aee3b7 34
goy5022 2:997f57aee3b7 35 moveNORTH()
goy5022 2:997f57aee3b7 36 moveSOUTH()
goy5022 2:997f57aee3b7 37 moveEAST()
goy5022 2:997f57aee3b7 38 moveWEST()
goy5022 2:997f57aee3b7 39
goy5022 2:997f57aee3b7 40 they are at the bottom of the page. take a look and read them.
goy5022 2:997f57aee3b7 41
goy5022 2:997f57aee3b7 42
goy5022 2:997f57aee3b7 43 REMEMBER TO MOVE THEM TO THE TOP OF THE PAGE IF YOU PLAN TO USE THEM IN THE MAIN FUNCTION, OR VICEVERSA MOVE THE MAIN FUNC.
goy5022 2:997f57aee3b7 44 TO THE BOTTOM
goy5022 2:997f57aee3b7 45
goy5022 2:997f57aee3b7 46 */
goy5022 2:997f57aee3b7 47
goy5022 7:95ebadc83fc7 48 //initMapping();
goy5022 6:6e96e93689df 49 initSensors();
goy5022 2:997f57aee3b7 50 setRightSpeed(3);
goy5022 2:997f57aee3b7 51 setLeftSpeed(3);
goy5022 6:6e96e93689df 52 t.start();
goy5022 2:997f57aee3b7 53
goy5022 3:1a8a7cc709cc 54 //while (true)
goy5022 5:9e504a5a1f48 55 //while(SenseF.read() < 0.99)
goy5022 7:95ebadc83fc7 56 //while(true)
goy5022 7:95ebadc83fc7 57 //{
goy5022 7:95ebadc83fc7 58 t.reset();
goy5022 7:95ebadc83fc7 59 while(frontExpAvg.average() < .8 && wallRight() && wallLeft())
goy5022 7:95ebadc83fc7 60 {
goy5022 7:95ebadc83fc7 61 frontExpAvg.add(SenseF.read());
goy5022 7:95ebadc83fc7 62
goy5022 7:95ebadc83fc7 63 pid();
goy5022 7:95ebadc83fc7 64
goy5022 2:997f57aee3b7 65 }
goy5022 7:95ebadc83fc7 66
goy5022 7:95ebadc83fc7 67 float time = t.read();
goy5022 7:95ebadc83fc7 68 handbrake();
goy5022 7:95ebadc83fc7 69 wait_ms(200);
goy5022 7:95ebadc83fc7 70 //updateMaze();
goy5022 7:95ebadc83fc7 71 //WIRELESS.printf("Time: %f Cells: %i\n\r", time, cells_traveled);
goy5022 7:95ebadc83fc7 72 //printMap(WIRELESS);
goy5022 7:95ebadc83fc7 73 //if (frontExpAvg.average() < .8 && !wallRight() && wallLeft())
goy5022 7:95ebadc83fc7 74 turn_right(3);
goy5022 7:95ebadc83fc7 75 //if (frontExpAvg.average() < .8 && wallRight() && !wallLeft())
goy5022 7:95ebadc83fc7 76 // turn_left(3);
goy5022 7:95ebadc83fc7 77 // }
goy5022 7:95ebadc83fc7 78
goy5022 7:95ebadc83fc7 79
goy5022 0:c2ec30f28676 80 return 0;
goy5022 2:997f57aee3b7 81 }
goy5022 7:95ebadc83fc7 82