Justin Eng / Mbed 2 deprecated RoboticsCatAndMouse_AutonomousDriver

Dependencies:   IMUfilter ADXL345_I2C mbed ITG3200 USBHost mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Humain.cpp Source File

Humain.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 #include "IMU_RPY.h"
00004 #include "GameCode.h"
00005 #include "HumanPosition.h"
00006 #include "HumanControl.h"
00007 
00008 int main()
00009 {
00010     pc.printf("\n\rStartup...\r\n");
00011 
00012     //Reset xbee
00013     pc.printf("Resetting XBee...\r\n");
00014     rst1 = 0;
00015     wait_us(1);
00016     rst1 = 1;
00017     wait_us(1);
00018 
00019     //Initialize IMU and filter
00020     pc.printf("Initializing IMU...\r\n");
00021     imuFilter.reset();
00022     rpy_init();
00023 
00024     // wait for AI car to get away from user
00025     pc.printf("Waiting for AI car...\n\r");
00026     wait(10);
00027 
00028     // start positioning system
00029     pc.printf("Starting Positioning System...\n\r");
00030     Thread position(PositionSystemMain, NULL, osPriorityRealtime, 256 * 4);
00031     wait(3); // wait for the mouse sensor to boot up
00032 
00033     // give control to radio driver while game is running
00034     pc.printf("Running!\n");
00035     Timer sendTimer;
00036     sendTimer.start();
00037     while(!gameOver) {
00038         radioDrive();
00039         if(sendTimer.read_ms() % 250)
00040             sendPosition(NULL);
00041     }
00042 }