This is some awesome robot code

Dependencies:   mbed-rtos mbed QEI

Fork of ICRSEurobot13 by Thomas Branch

Revision:
72:7996aa8286ae
Parent:
49:665bdca0f2cd
Child:
79:0d3140048526
--- a/Processes/Kalman/Kalman.cpp	Mon Apr 15 10:52:36 2013 +0000
+++ b/Processes/Kalman/Kalman.cpp	Mon Apr 15 13:37:32 2013 +0000
@@ -55,6 +55,7 @@
     printf("waiting for all sonar, and at least 1 IR\r\n");
     while( ((sensorseenflags & 0x7)^0x7) || !(sensorseenflags & 0x7<<3) );
 
+#ifdef TEAM_RED
     //solve for our position (assume perfect bias)
     const float d = beaconpos[2].y - beaconpos[1].y;
     const float i = beaconpos[2].y - beaconpos[0].y;
@@ -62,15 +63,30 @@
     float r1 = RawReadings[SONAR2];
     float r2 = RawReadings[SONAR1];
     float r3 = RawReadings[SONAR0];
+#endif
+#ifdef  TEAM_BLUE
+    const float d = beaconpos[1].y - beaconpos[2].y;
+    const float i = beaconpos[0].y - beaconpos[2].y;
+    const float j = beaconpos[0].x - beaconpos[2].x;
+    float r1 = RawReadings[SONAR2];
+    float r2 = RawReadings[SONAR1];
+    float r3 = RawReadings[SONAR0];
+#endif
 
     printf("ranges: 0: %0.4f, 1: %0.4f, 2: %0.4f \r\n", r1, r2, r3);
 
     float y_coor = (r1*r1-r2*r2+d*d)/(2*d);
     float x_coor = (r1*r1-r3*r3+i*i+j*j)/(2*j) - (i*y_coor)/j;
 
+#ifdef TEAM_RED
     //coordinate system hack (for now)
     x_coor = beaconpos[2].x - x_coor;
     y_coor = beaconpos[2].y - y_coor;
+#endif
+#ifdef  TEAM_BLUE
+    x_coor = x_coor - beaconpos[2].x;
+    y_coor = y_coor - beaconpos[2].y;
+#endif
 
     printf("solved pos from sonar: %f, %f \r\n", x_coor, y_coor);