Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Files at this revision

API Documentation at this revision

Comitter:
narshu
Date:
Tue May 01 16:54:44 2012 +0000
Parent:
20:0c3f320e477a
Child:
22:7ba09c0af0d0
Commit message:
Added support for both starting locs (except AI target mirroring)

Changed in this revision

Eurobot_shared.lib Show annotated file Show diff for this revision Revisions of this file
front_arms.h Show annotated file Show diff for this revision Revisions of this file
globals.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Eurobot_shared.lib	Mon Apr 30 20:22:06 2012 +0000
+++ b/Eurobot_shared.lib	Tue May 01 16:54:44 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/narshu/libraries/Eurobot_shared/m9b1ne
\ No newline at end of file
+http://mbed.org/users/narshu/libraries/Eurobot_shared/m9cjn5
\ No newline at end of file
--- a/front_arms.h	Mon Apr 30 20:22:06 2012 +0000
+++ b/front_arms.h	Tue May 01 16:54:44 2012 +0000
@@ -1,22 +1,22 @@
-#ifndef _FRONT_ARMS_H
-#define _FRONT_ARMS_H
-
-#include "mbed.h"
-
-#define LEFT_ARM_PIN p21
-#define RIGHT_ARM_PIN p24
-
-Servo leftServo(LEFT_ARM_PIN);
-Servo rightServo(RIGHT_ARM_PIN);
-
-void setLeftArmPosition(float degrees) {
-    if(degrees < 90) degrees = 90; // If arm moves past this angle, robot will not fit in the perimeter constraint
-    leftServo.position(degrees);
-}
-
-void setRightArmPosition(float degrees) {
-    if(degrees > 90) degrees = 90; // If arm moves past this angle, robot will not fit in the perimeter constraint
-    rightServo.position(degrees);
-}
-
+#ifndef _FRONT_ARMS_H
+#define _FRONT_ARMS_H
+
+#include "mbed.h"
+
+#define LEFT_ARM_PIN p21
+#define RIGHT_ARM_PIN p24
+
+Servo leftServo(LEFT_ARM_PIN);
+Servo rightServo(RIGHT_ARM_PIN);
+
+void setLeftArmPosition(float degrees) {
+    if(degrees < 90) degrees = 90; // If arm moves past this angle, robot will not fit in the perimeter constraint
+    leftServo.position(degrees);
+}
+
+void setRightArmPosition(float degrees) {
+    if(degrees > 90) degrees = 90; // If arm moves past this angle, robot will not fit in the perimeter constraint
+    rightServo.position(degrees);
+}
+
 #endif // _FRONT_ARMS_H
\ No newline at end of file
--- a/globals.h	Mon Apr 30 20:22:06 2012 +0000
+++ b/globals.h	Tue May 01 16:54:44 2012 +0000
@@ -4,11 +4,14 @@
 #include "mbed.h"
 #define PI 3.14159265
 
+
+//#define ROBOT_SECONDARY
+#define STARTLOC_RED
+//#define STARTLOC_BLUE
+
 //enables ui
 #define UION
 
-//#define ROBOT_SECONDARY
-
 #ifdef ROBOT_SECONDARY
 //Secondary Robot constants in mm
 const int robot_width = 260;
@@ -47,7 +50,11 @@
     int x;
     int y;
 };
+#ifdef STARTLOC_RED
 const pos beaconpos[] = {{3000, 1000},{0,0}, {0,2000}};
+#elif STARTLOC_BLUE
+const pos beaconpos[] = {{0, 1000},{3000,2000}, {3000,0}};
+#endif
 
 //System constants
 const int PREDICTPERIOD = 20; //ms
--- 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);
-    }
 }