Eurobot2012_Primary
Dependencies: mbed Eurobot_2012_Primary
Diff: main.cpp
- Revision:
- 21:15da49f18c63
- Parent:
- 19:06610e1c0895
- Child:
- 22:7ba09c0af0d0
--- a/main.cpp Mon Apr 30 20:22:06 2012 +0000 +++ b/main.cpp Tue May 01 16:54:44 2012 +0000 @@ -23,36 +23,29 @@ Motion motion(motors, ai, kalman); //TODO mutex on kalman state, and on motor commands (i.e. on the i2c bus) -//NOTE! Recieving data with RF12B now DISABLED due to interferance with rtos! void vMotorThread(void const *argument); void vPrintState(void const *argument); void motion_thread(void const *argument); -//bool flag_terminate = false; - -float temp = 0; - //Main loop int main() { pc.baud(115200); - //Init kalman + // no motor motions till we pull the trig + ai.flag_motorStop = true; + //Init kalman, this should be done in the mid of the arena before the game starts kalman.KalmanInit(); //Thread tMotorThread(vMotorThread,NULL,osPriorityNormal,256); //Thread tUpdateState(vPrintState,NULL,osPriorityNormal,1024); - - //Thread thr_motion(motion_thread,NULL,osPriorityNormal,1024); - //Motion_Thread_Ptr = &thr_motion; - - //measure cpu usage. output updated once per second to symbol cpupercent - //Thread mCPUthread(measureCPUidle, NULL, osPriorityIdle, 1024); //check if stack overflow with such a small staack + pc.printf("We got to main! ;D\r\n"); //REMEMBERT TO PUT PULL UP RESISTORS ON I2C!!!!!!!!!!!!!! while (1) { + // we use main loop to estimate the cpu usage osThreadSetPriority (osThreadGetId(), osPriorityIdle); @@ -90,6 +83,15 @@ flag_terminate = true; */ + + // + // Put some code here so it's started by the pull trigger + // start a 90s timer here as well + // + //while (!Tiggered); + + // starts motors + ai.flag_motorStop = false; // strat 1 ================================== // goto middle x settarget(1500, 250, PI/2, true); @@ -111,90 +113,14 @@ Thread::signal_wait(0x01); Thread::wait(2000); - flag_terminate = true; + // terminate thread, stopps motors permanently + ai.flag_terminate = true; while(true){ Thread::wait(osWaitForever); } // end of strat 1 =========================== - - - - - while (1) { - - - // goes to the mid - settarget(500, 1000, 0, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - settarget(2500, 1000, PI, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - } - - - - // goes to the mid - settarget(700, 1500, 0, false); - Thread::signal_wait(0x01); - Thread::wait(2000); -////////////////////////////////////////////////////// - // goes to the mid - settarget(1500, 1000, PI/2, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - // left roll - settarget(500, 1500, PI/2, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - // mid - settarget(1500, 1000, PI/2, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - // map - settarget(1500, 1500, PI/2, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - - // mid - settarget(1500, 1000, -PI/2, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - - // home - settarget(500, 500, 0, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - // oponents base - settarget(2500, 500, 0, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - // oponents ship - settarget(2500, 1500, 0, true); - Thread::signal_wait(0x01); - Thread::wait(2000); - - - //} - - Thread::signal_wait(0x01); - flag_terminate = true; - //OLED3 = true; - - while (true) { - Thread::wait(osWaitForever); - } }