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

Committer:
Strikewolf
Date:
Wed Apr 30 12:25:47 2014 +0000
Revision:
3:0a6e4d139b86
Parent:
1:dacf7db790f6
Final product before demo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Strikewolf 1:dacf7db790f6 1 #include "mbed.h"
Strikewolf 1:dacf7db790f6 2 #include "rtos.h"
Strikewolf 1:dacf7db790f6 3 #include "IMU_RPY.h"
Strikewolf 1:dacf7db790f6 4 #include "GameCode.h"
Strikewolf 1:dacf7db790f6 5 #include "HumanPosition.h"
Strikewolf 1:dacf7db790f6 6 #include "HumanControl.h"
Strikewolf 1:dacf7db790f6 7
Strikewolf 1:dacf7db790f6 8 int main()
Strikewolf 1:dacf7db790f6 9 {
Strikewolf 1:dacf7db790f6 10 pc.printf("\n\rStartup...\r\n");
Strikewolf 1:dacf7db790f6 11
Strikewolf 1:dacf7db790f6 12 //Reset xbee
Strikewolf 1:dacf7db790f6 13 pc.printf("Resetting XBee...\r\n");
Strikewolf 1:dacf7db790f6 14 rst1 = 0;
Strikewolf 1:dacf7db790f6 15 wait_us(1);
Strikewolf 1:dacf7db790f6 16 rst1 = 1;
Strikewolf 1:dacf7db790f6 17 wait_us(1);
Strikewolf 1:dacf7db790f6 18
Strikewolf 1:dacf7db790f6 19 //Initialize IMU and filter
Strikewolf 1:dacf7db790f6 20 pc.printf("Initializing IMU...\r\n");
Strikewolf 1:dacf7db790f6 21 imuFilter.reset();
Strikewolf 1:dacf7db790f6 22 rpy_init();
Strikewolf 1:dacf7db790f6 23
Strikewolf 1:dacf7db790f6 24 // wait for AI car to get away from user
Strikewolf 1:dacf7db790f6 25 pc.printf("Waiting for AI car...\n\r");
Strikewolf 1:dacf7db790f6 26 wait(10);
Strikewolf 1:dacf7db790f6 27
Strikewolf 1:dacf7db790f6 28 // start positioning system
Strikewolf 1:dacf7db790f6 29 pc.printf("Starting Positioning System...\n\r");
Strikewolf 1:dacf7db790f6 30 Thread position(PositionSystemMain, NULL, osPriorityRealtime, 256 * 4);
Strikewolf 1:dacf7db790f6 31 wait(3); // wait for the mouse sensor to boot up
Strikewolf 1:dacf7db790f6 32
Strikewolf 1:dacf7db790f6 33 // give control to radio driver while game is running
Strikewolf 1:dacf7db790f6 34 pc.printf("Running!\n");
Strikewolf 1:dacf7db790f6 35 Timer sendTimer;
Strikewolf 1:dacf7db790f6 36 sendTimer.start();
Strikewolf 1:dacf7db790f6 37 while(!gameOver) {
Strikewolf 1:dacf7db790f6 38 radioDrive();
Strikewolf 1:dacf7db790f6 39 if(sendTimer.read_ms() % 250)
Strikewolf 1:dacf7db790f6 40 sendPosition(NULL);
Strikewolf 1:dacf7db790f6 41 }
Strikewolf 1:dacf7db790f6 42 }