asdf

Dependencies:   L3GD20 LSM303DLHC mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Main.cpp Source File

Main.cpp

00001 //#include "Core.h"
00002 
00003 #include "Sensors.h"
00004 #include "PID.h"
00005 #include "Communication.h"
00006 #include "Flooding.h"
00007 #include "Movement.h"
00008 
00009 #include "BufferAverage.h"
00010 #include "ExponentialAverage.h"
00011 //#include "WeightedAverage.h"
00012 
00013 int main()
00014 {
00015     Motor.baud(115200);
00016     ledF.period_us(26.3); //28.5 //27.9
00017     wait_us(600);
00018     ledF.write(.5);
00019     stop_mov();
00020     
00021     
00022     wait(3);
00023     /*
00024 
00025     STEVE!!!!!!
00026     WHENEVER YOU ARE IN A CELL AND YOU WANT TO KNOW WHAT THE NEXT BEST MOVE IS
00027     USE THE flood_findPath(x, y)  where x and y are your current possition
00028     
00029     the function will return a MOVE type
00030     and you can use something similar to this:
00031 
00032     i've written the code for the following:
00033     
00034     
00035     moveNORTH()
00036     moveSOUTH()
00037     moveEAST()
00038     moveWEST()
00039     
00040     they are at the bottom of the page. take a look and read them.
00041     
00042     
00043     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.
00044     TO THE BOTTOM
00045     
00046     */
00047 
00048     //initMapping();
00049     initSensors();
00050     setRightSpeed(3);
00051     setLeftSpeed(3);
00052     t.start();
00053     
00054     //while (true)
00055     //while(SenseF.read() < 0.99)
00056     //while(true)
00057         //{
00058         t.reset();
00059         while(frontExpAvg.average() < .8 && wallRight() && wallLeft()) 
00060         { 
00061             frontExpAvg.add(SenseF.read());
00062             
00063             pid();
00064                
00065         }
00066         
00067         float time = t.read();
00068         handbrake();
00069         wait_ms(200);
00070         //updateMaze();
00071         //WIRELESS.printf("Time: %f Cells: %i\n\r", time, cells_traveled);
00072         //printMap(WIRELESS);
00073         //if (frontExpAvg.average() < .8 && !wallRight() && wallLeft())
00074             turn_right(3);
00075         //if (frontExpAvg.average() < .8 && wallRight() && !wallLeft())
00076         //    turn_left(3);
00077        // }
00078      
00079      
00080     return 0;
00081 }
00082