Spring 2014, ECE 4180 project, Georgia Institute of Technolgoy. This is the autonomous driver program for the Robotics Cat and Mouse program.
Dependencies: IMUfilter ADXL345_I2C mbed ITG3200 USBHost mbed-rtos
Revision 3:0a6e4d139b86, committed 2014-04-30
- Comitter:
- Strikewolf
- Date:
- Wed Apr 30 12:25:47 2014 +0000
- Parent:
- 2:188b0fbf3b43
- Commit message:
- Final product before demo
Changed in this revision
GameCode.h | Show annotated file Show diff for this revision Revisions of this file |
HumanPosition.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 188b0fbf3b43 -r 0a6e4d139b86 GameCode.h --- a/GameCode.h Wed Apr 30 05:55:41 2014 +0000 +++ b/GameCode.h Wed Apr 30 12:25:47 2014 +0000 @@ -2,6 +2,8 @@ Serial pc(USBTX, USBRX); +void stop(); + bool gameOver = false; bool isGameOver(short x_hum, short y_hum, short x_cpu, short y_cpu) @@ -16,5 +18,6 @@ void endGame() { pc.printf("GAME OVER\n\r"); + stop(); exit(1); } \ No newline at end of file
diff -r 188b0fbf3b43 -r 0a6e4d139b86 HumanPosition.h --- a/HumanPosition.h Wed Apr 30 05:55:41 2014 +0000 +++ b/HumanPosition.h Wed Apr 30 12:25:47 2014 +0000 @@ -101,6 +101,7 @@ void sendPosition(void const *) { + // temp variables int x = 0; int y = 0; char a = 0; @@ -112,31 +113,37 @@ x = (int) x_position; y = (int) y_position; - // send current xy position to cpu bot pc.printf("Sending: %d %d...\n\r", x, y); + + // break down x coordinate by byte a = x >> 24; b = x >> 16; c = x >> 8; d = x; - // pc.printf("\ta: %x b: %x\n\r", a, b); + + // put each byte on the buffer xbee.putc('x'); - xbee.putc(a); // send upper bits - xbee.putc(b); // send lower bits + xbee.putc(a); + xbee.putc(b); xbee.putc(c); xbee.putc(d); + // break down y coordinate by byte a = y >> 24; b = y >> 16; c = y >> 8; d = y; - //pc.printf("\ta: %x b: %x\n\r", a, b); + + // put each byte on the buffer xbee.putc('y'); - xbee.putc(a); // send upper bits - xbee.putc(b); // send lower bits + xbee.putc(a); + xbee.putc(b); xbee.putc(c); xbee.putc(d); pc.printf("Send complete.\n\r"); + + // wait for a possible game over response wait(0.25); if(xbee.readable() && xbee.getc() == 'd') { gameOver = true;