Code for RFID Robot

Dependencies:   DebounceIn HTTPClient ID12RFID SDFileSystem TextLCD WiflyInterface iniparser mbed

Files at this revision

API Documentation at this revision

Comitter:
4180skrw
Date:
Tue Dec 10 02:17:48 2013 +0000
Commit message:
initial commit

Changed in this revision

DebounceIn.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
ID12RFID.lib Show annotated file Show diff for this revision Revisions of this file
LCDText.cpp Show annotated file Show diff for this revision Revisions of this file
LCDText.h Show annotated file Show diff for this revision Revisions of this file
RFID.cpp Show annotated file Show diff for this revision Revisions of this file
RFID.h Show annotated file Show diff for this revision Revisions of this file
SD.cpp Show annotated file Show diff for this revision Revisions of this file
SD.h Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
WiflyInterface.lib Show annotated file Show diff for this revision Revisions of this file
driver.cpp Show annotated file Show diff for this revision Revisions of this file
driver.h Show annotated file Show diff for this revision Revisions of this file
iniparser.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
robot.cpp Show annotated file Show diff for this revision Revisions of this file
robot.h Show annotated file Show diff for this revision Revisions of this file
wifiunit.cpp Show annotated file Show diff for this revision Revisions of this file
wifiunit.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DebounceIn.lib	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AjK/code/DebounceIn/#31ae5cfb44a4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/donatien/code/HTTPClient/#1f743885e7de
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ID12RFID.lib	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/ID12RFID/#f04afa911cf5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCDText.cpp	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,56 @@
+#include "LCDText.h"
+
+void clearLCD() {
+    char buff[33];
+    memset(buff, ' ', 32);
+    buff[32] = '\0';
+    mylcd.printf(buff);
+}
+
+//clears LCD and prints the two strings centered on each line
+//max length of each string is 16
+void printLCD(const char* string1, const char* string2) {
+    char buff[33];
+    memset(buff, ' ', 32);
+    buff[32] = '\0';
+    //clear LCD
+    clearLCD();
+    
+    //print to LCD
+    if(string1) {
+        memcpy(buff+(16-strlen(string1))/2, string1, strlen(string1));
+    }
+    if(string2) {
+        memcpy(buff+16+(16-strlen(string2))/2, string2, strlen(string2));
+    }
+    mylcd.printf(buff);
+}
+
+//creates a menu with with a title, controlled by the up/down/select buttons
+//returns index of option selected
+int displayMenu(const char* menuTitle, const char** menuOptions, int numOptions) {
+    int curSelection = 0;
+    
+    printLCD(menuTitle, menuOptions[curSelection]);
+    if(!up || !down || !select || !back) wait(.3);
+    while(1) {
+        if(!up) {
+            curSelection = (curSelection == numOptions-1) ? 0 : (curSelection + 1);
+            printLCD(menuTitle, menuOptions[curSelection]);
+            if(!up) wait(.2);
+        }
+        if(!down) {
+            curSelection = (curSelection == 0) ? (numOptions - 1) : (curSelection - 1);
+            printLCD(menuTitle, menuOptions[curSelection]);
+            if(!down) wait(.2);
+        }
+        if(!select) {
+            clearLCD();
+            return curSelection;
+        }
+        if(!back) {
+            clearLCD();
+            return -1;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCDText.h	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,17 @@
+#ifndef _LCDTEST_H
+#define _LCDTEST_H
+
+#include "mbed.h"
+#include "TextLCD.h"
+#include "DebounceIn.h"
+
+extern DigitalOut myled1, myled2, myled3, myled4;
+extern TextLCD mylcd;
+extern DebounceIn down, up, select, back;
+extern Serial device;
+
+void clearLCD();
+void printLCD(const char* string1, const char* string2);
+int displayMenu(const char* menuTitle, const char** menuOptions, int numOptions);
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RFID.cpp	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,46 @@
+#include "RFID.h"
+
+//Takes in vector by reference and populates it with unique RFID values
+//until pb21 is pressed.
+int readTagSequence(std::vector<int>& v)
+{
+   int currTag;
+   int size = 0;
+   printLCD("Scan tag", NULL);
+   while (select) {
+       if(rfid.readable()) {
+           currTag = rfid.read();
+           size++;
+           v.resize(size);
+           v[size-1] = currTag;
+           char line1[16];
+           sprintf(line1, "%d", v[size-1]);
+           printLCD(line1, "added to list");
+           wait(1.5);
+           printLCD("Scan tag", NULL);
+       }
+       else if(!back) return 0;
+   }
+   return 1;
+}
+
+//Reads a single RFID tag, and returns value
+int readTag()
+{
+   printLCD("Scan tag", NULL);
+   int currTag = 0;
+   while (!currTag) {
+       if (rfid.readable()) {
+           currTag = rfid.read();
+           char line1[16];
+           sprintf(line1, "%d", currTag);
+           printLCD(line1, "read");
+           wait(1.5);
+           return currTag;
+       }
+       else if (!back) {
+           return 0;
+       }
+   }
+   return currTag;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RFID.h	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,16 @@
+#ifndef  _RFID_H
+#define _RFID_H
+
+#include "mbed.h"
+#include "ID12RFID.h"
+#include <vector>
+#include <algorithm>
+#include "LCDText.h"
+
+extern DebounceIn down, up, select, back;
+extern ID12RFID rfid;
+
+int readTagSequence(std::vector<int>& v);
+int readTag();
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SD.cpp	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,172 @@
+#include "SD.h"
+
+dictionary* translationFile;
+dictionary* programmedFile;
+
+void setupSDCard()
+{
+    translationFile = iniparser_load("/sd/translationFile.ini");
+    programmedFile = iniparser_load("/sd/programmedFile.ini");
+    
+    if(translationFile && programmedFile) {
+        printLCD("Files opened", "succesfully!");
+    }
+    else if(!translationFile && !programmedFile) {
+        printLCD("Error opening", "both files");
+    }
+    else if(!translationFile) {
+        printLCD("Error opening", "translation");
+    }
+    else {
+        printLCD("Error opening", "programmed");
+    }
+    wait(1.5);
+}
+
+vector<robotCommand>* translateTags(vector<int>& tagValues)
+{
+
+    vector<robotCommand>* commandVector = new vector<robotCommand>();
+    printLCD("Translating", NULL);
+    wait(.5);
+    
+    for (int i = 0; i < tagValues.size(); i += 2) // Tags alternate between command type and magnitude
+    {
+        printf("trying to find tag # %d\n", tagValues[i]);
+        char tagName[40];
+        sprintf(tagName, "translations:%d", tagValues[i]%1000);
+        
+        // get the command string from the ini file
+        
+        char commandName[30];
+        sprintf(commandName,"%s", iniparser_getstring(translationFile,tagName, "NONE"));
+
+        //printf("commandName is: %s\n", commandName);
+        CommandType commandID = None;
+        
+        if (strcmp(commandName, "FORWARD") == 0)
+            commandID = Forward;
+        else if (strcmp(commandName, "REVERSE") == 0)
+            commandID = Reverse; 
+        else if (strcmp(commandName, "LEFT") == 0)
+            commandID = Left; 
+        else if (strcmp(commandName, "RIGHT") == 0)
+            commandID = Right; 
+        else if (strcmp(commandName, "PLAYSOUND") == 0)
+            commandID = PlaySound; 
+        
+        sprintf(tagName, "Translations:%d", tagValues[i+1]%1000);
+        double magnitude = iniparser_getdouble(translationFile,tagName, 0.0);
+        printf("Adding %d %f", commandID, magnitude);
+        commandVector->push_back(robotCommand(commandID, magnitude));
+    }
+    printf("done searching\n");
+    printLCD("Translation", "Complete");
+    wait(.5);
+    return commandVector;
+}
+
+vector<robotCommand>* getProgrammedPath(int pathNumber)
+{
+    vector<robotCommand>* commandVector = new vector<robotCommand>();
+    printLCD("Translating", NULL);
+    wait(.5);
+    
+    char sectionName[30];
+    sprintf(sectionName, "path%d", pathNumber);
+    printf("section name: %s\n", sectionName);
+    int num_keys = iniparser_getsecnkeys(programmedFile, sectionName);
+    
+    printf("number of keys: %d\n", num_keys);
+    char keyName[5];
+    for (int i = 0; i < num_keys; i+= 2)
+    {
+        sprintf(keyName,"path%d:%d",pathNumber, i);
+        char commandName[30];
+        sprintf(commandName,"%s", iniparser_getstring(programmedFile,keyName, "NONE"));
+ 
+        CommandType commandID = None;
+        if (strcmp(commandName, "FORWARD") == 0)
+            commandID = Forward;
+        else if (strcmp(commandName, "REVERSE") == 0)
+            commandID = Reverse; 
+        else if (strcmp(commandName, "LEFT") == 0)
+            commandID = Left; 
+        else if (strcmp(commandName, "RIGHT") == 0)
+            commandID = Right; 
+        else if (strcmp(commandName, "PLAYSOUND") == 0)
+            commandID = PlaySound; 
+            
+        sprintf(keyName,"path%d:%d",pathNumber, i+1);
+        double magnitude = iniparser_getdouble(programmedFile,keyName, 0.0);
+        printf("Adding %d %f", commandID, magnitude);
+        commandVector->push_back(robotCommand(commandID, magnitude));
+    }
+    printf("done searching pre-programmed path\n");
+    printLCD("Translation", "Complete");
+    wait(.5);
+    return commandVector;
+}
+
+void writeTagCommand(int tagID, CommandType value)
+{
+    printf("first key: %s\n", translationFile->key[1]);
+    printf("Entering Write Command, tagID: %d, value: %d\n", tagID, value);
+    char stringValue[15];
+    tagID = tagID % 1000;
+    
+    if (value == 0)
+    {
+        sprintf(stringValue, "FORWARD");
+    }
+    else if (value == 1)
+    {
+        sprintf(stringValue, "REVERSE");
+    }
+    else if (value == 2)
+    {
+        sprintf(stringValue, "LEFT");
+    }
+    else if (value == 3)
+    {
+        sprintf(stringValue, "RIGHT");
+    }
+    else if (value == 4)
+    {
+        sprintf(stringValue, "PLAYSOUND");
+    }
+
+    char keyName[30];
+    sprintf(keyName, "translations:%d", tagID);
+    printf("trying to set\n");
+    int val = dictionary_set(translationFile, keyName, stringValue);
+    
+    
+    FILE* translationFilePointer = fopen("/sd/translationFile.ini", "w"); // need to make sure this is right
+    if (translationFilePointer != NULL) printf("file opened succesfully\n");
+    iniparser_dump(translationFile, translationFilePointer);
+    printf("done dumping\n");
+    printf("value is now %s\n", iniparser_getstring(translationFile,keyName, "NONE"));
+    fclose(translationFilePointer);
+    printLCD("Tag Updated", NULL);
+    wait(1.5);
+}
+
+void writeTagCommand(int tagID, double magValue)
+{
+    char keyName[30];
+    tagID = tagID % 1000;
+    sprintf(keyName, "translations:%d", tagID); // need to make sure this is right
+    
+    char stringValue[20];
+    sprintf(stringValue, "%f", magValue);
+    
+    dictionary_set(translationFile, keyName, stringValue); // add the key to the dictionary
+    FILE* translationFilePointer = fopen("/sd/translationFile.ini", "w");
+    iniparser_dump_ini(translationFile, translationFilePointer);
+    fclose(translationFilePointer);
+    printLCD("Tag Updated", NULL);
+    wait(1.5);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SD.h	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,35 @@
+#ifndef _SD_H
+#define _SD_H
+
+#include "mbed.h"
+#include "SDFileSystem.h"
+#include "iniparser.h"
+#include "dictionary.h"
+#include <vector>
+#include "LCDText.h"
+
+typedef enum {
+    Forward,
+    Reverse,
+    Left,
+    Right,
+    PlaySound,
+    None
+} CommandType; 
+
+class robotCommand {
+public:
+    robotCommand(CommandType type, double mag) : commandType(type), magnitude(mag) {}
+    CommandType commandType;
+    double magnitude;
+};
+
+extern SDFileSystem sd;
+
+void setupSDCard();
+vector<robotCommand>* translateTags(vector<int>& tagValues);
+vector<robotCommand>* getProgrammedPath(int pathNumber);
+void writeTagCommand(int tagID, CommandType value);
+void writeTagCommand(int tagID, double magValue);
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WiflyInterface.lib	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/WiflyInterface/#fb4494783863
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/driver.cpp	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,129 @@
+#include "driver.h"
+#include "wifiunit.h"
+
+void processCommands(vector<robotCommand> &commands) {
+    printLCD("Processing", NULL);
+    forward();
+    stop();
+    for(int i=0; i<commands.size(); i++) {
+        double mag = commands[i].magnitude;
+        int angle;
+        switch(commands[i].commandType) {
+            case(Forward):
+                printLCD("Forward", NULL);
+                forward();
+                wait(mag*4);
+                break;
+            case(Reverse):
+                printLCD("Reverse", NULL);
+                reverse();
+                printf("%f\n", mag*4);
+                wait(mag*4);
+                break;
+            case(Left):
+                printLCD("Left", NULL);
+                angle = (int) (mag*90);
+                //create script
+                device.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", NewScript, 13, Drive, char((speed>>8)&0xFF),  char(speed&0xFF), char(((1)>>8)&0xFF),  char((1)&0xFF), WaitAngle, char((angle>>8)&0xFF), char(angle&0xFF), Drive, 0, 0, 0, 0);
+                device.printf("%c", DoScript);
+                break;
+            case(Right):
+                printLCD("Right", NULL);
+                angle = (int) (mag*90);
+                //create script
+                device.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", NewScript, 13, Drive, char((speed>>8)&0xFF),  char(speed&0xFF), char(((-1)>>8)&0xFF),  char((-1)&0xFF), WaitAngle, char(((-angle)>>8)&0xFF), char((-angle)&0xFF), Drive, 0, 0, 0, 0);
+                device.printf("%c", DoScript);
+                break;
+            case(PlaySound):
+                printLCD("Sound", NULL);
+                playsong((int) mag);
+                break;
+        }
+        stop();
+    }
+}
+
+void initialize() {
+    initializeRobot();
+    forward();
+    wait(.5);
+    stop();
+    reverse();
+    wait(.5);
+    stop();
+    setupSDCard();
+    setupWiFi();
+    down.mode(PullUp);
+    up.mode(PullUp);
+    back.mode(PullUp);
+    select.mode(PullUp);
+}
+
+void cancel() {
+    printLCD("Cancelled", NULL);
+    wait(1.5);
+}
+
+// Demo to move around using basic commands
+int main() {
+    initialize();
+    const char* mainMenu[4] = {"Read From RFID", "Read From SD", "Reprogram", "WiFi Mode"};
+    const char* reprogramType[2] = {"Command", "Magnitude"};
+    const char* allCommands[5] = {"Forward", "Reverse", "Left", "Right", "Play Sound"};
+    const char* allMagnitudes[6] = {".5", "1", "1.5", "2", "2.5", "3"};
+    vector<int> tagValues;
+    vector<robotCommand>* commands;
+    
+    while(1) {
+        wait(.2);
+        int option = displayMenu("Main Menu", mainMenu, 4);
+        wait(.2);
+        switch(option) {
+            case(0):  { //read from RFID
+                tagValues.clear();
+                int rt = readTagSequence(tagValues);
+                if(!rt) {
+                    cancel();
+                    break;
+                }
+                commands = translateTags(tagValues);
+                processCommands(*commands);
+                delete commands;
+            }
+            break;
+            case(1): //read from SD
+                commands = getProgrammedPath(1);
+                processCommands(*commands);
+                delete commands;
+                break;
+            case(2): //reprogram
+                int type = displayMenu("Reprogram Type", reprogramType, 2);
+                if(type == 0) { //reprogram command
+                    CommandType repCommand = (CommandType) displayMenu("Command Type", allCommands, 5);
+                    int tagID = readTag();
+                    if(!tagID) {
+                        cancel();
+                        break;
+                    }
+                    writeTagCommand(tagID, repCommand);
+                }
+                else { //reprogram magnitude
+                    double repMag = displayMenu("Mag Type", allMagnitudes, 6)*.5+.5;
+                    int tagID = readTag();
+                    if(!tagID) {
+                        cancel();
+                        break;
+                    }
+                    writeTagCommand(tagID, repMag);
+                }
+                break;
+                
+           case(3):
+                int ret = readTag();
+                commands = getTagCommands(ret%1000);
+                processCommands(*commands);
+                delete commands;
+                break;
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/driver.h	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,22 @@
+#ifndef _DRIVER_H
+#define _DRIVER_H
+
+#include "mbed.h"
+#include "LCDText.h"
+#include "DebounceIn.h"
+#include "robot.h"
+#include "ID12RFID.h"
+#include "RFID.h"
+#include "SD.h"
+
+DigitalOut myled1(LED1), myled2(LED2), myled3(LED3), myled4(LED4);
+Serial device(p28, p27);
+TextLCD mylcd(p15, p16, p17, p18, p19, p20);
+DebounceIn down(p22), up(p23), select(p24), back(p21);
+ID12RFID rfid(p10); // uart rx
+SDFileSystem sd(p5, p6, p7, p8, "sd");
+
+void processCommands(vector<robotCommand> &commands);
+void initialize();
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/iniparser.lib	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/4180skrw/code/iniparser/#452fd0d30ac6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/robot.cpp	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,78 @@
+#include "robot.h"
+
+void initializeRobot() {
+    printLCD("Initializing", NULL);
+    // wait for Roomba to power up to accept serial commands
+    wait(2);
+    // set baud rate for Roomba factory default
+    device.baud(57600);
+    // Start command mode and select sensor data to send back
+    start();
+    
+    //define songs
+    //one beep
+    device.printf("%c%c%c%c%c", Song, char(1), char(1), char(69), char(16));
+    wait(1);
+    //georgia tech fight song, split into 3 songs because max song length is 16
+    device.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", Song, char(2), char(16), char(67), char(18), char(0), char(2), char(65), char(9), char(0), char(2), char(63), char(18), char(0), char(2), char(63), char(9), char(0), char(2), char(63), char(18), char(0), char(2), char(65), char(9), char(0), char(2), char(67), char(18), char(0), char(2), char(67), char(9), char(0), char(2));
+    device.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", Song, char(14), char(16), char(67), char(9), char(0), char(2), char(65), char(9), char(0), char(2), char(63), char(9), char(0), char(2), char(65), char(9), char(0), char(2), char(65), char(9), char(0), char(2), char(65), char(9), char(0), char(2), char(63), char(18), char(0), char(2), char(62), char(9), char(63), char(54));
+    //a major arpeggio
+    device.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", Song, char(3), char(7), char(69), char(32), char(73), char(32), char(76), char(32), char(81), char(32), char(76), char(32), char(73), char(32), char(69), char(32));
+    clearLCD();
+}
+
+// Start  - send start and safe mode, start streaming sensor data
+void start() {
+   // device.printf("%c%c", Start, SafeMode);
+    device.putc(Start);
+    wait(.1);
+    device.putc(Control);
+    wait(.5);
+  //  device.printf("%c%c", SensorStream, char(1));
+    device.putc(Sensors);
+    device.putc(BumpsandDrops);
+    wait(.5);
+}
+// Stop  - turn off drive motors
+void stop() {
+    device.printf("%c%c%c%c%c", Drive, char(0),  char(0),  char(0),  char(0));
+}
+// Forward  - turn on drive motors
+void forward() {
+    device.printf("%c%c%c%c%c", Drive, char((speed>>8)&0xFF),  char(speed&0xFF),  
+    char((radius>>8)&0xFF),  char(radius&0xFF));
+ 
+}
+// Reverse - reverse drive motors
+void reverse() {
+    device.printf("%c%c%c%c%c", Drive, char(((-speed)>>8)&0xFF),  char((-speed)&0xFF),  
+    char(((radius)>>8)&0xFF),  char((radius)&0xFF));
+ 
+}
+// Left - drive motors set to rotate to left
+void left() {
+    device.printf("%c%c%c%c%c", Drive, char((speed>>8)&0xFF),  char(speed&0xFF),  
+    char(((1)>>8)&0xFF),  char((1)&0xFF));
+}
+// Right - drive motors set to rotate to right
+void right() {
+    device.printf("%c%c%c%c%c", Drive, char(((speed)>>8)&0xFF),  char((speed)&0xFF),  
+    char((-1>>8)&0xFF),  char(-1&0xFF));
+ 
+}
+// Charger - search and return to charger using IR beacons (if found)
+void charger() {
+    device.printf("%c", Clean );
+    wait(.2);
+    device.printf("%c", CoverandDock );
+}
+// Play Song  - play a song
+void playsong(int mag) { //Play song
+    if(mag == 2) { //play rest of georgia tech fight song
+        device.printf("%c%c%c%c%c%c%c%c", NewScript, char(6), PlaySong, char(2), WaitTime, char(20), PlaySong, char(14));
+        device.printf("%c", DoScript);
+    }
+    else {
+        device.printf("%c%c", PlaySong, char(mag));
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/robot.h	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,43 @@
+#ifndef _ROBOT_H
+#define _ROBOT_H
+
+#include "mbed.h"
+#include <vector>
+#include "LCDText.h"
+
+extern Serial device;
+ 
+// Definitions of iRobot Roomba SCI Command Numbers
+// See the Roomba SCI manual for a complete list
+ 
+ 
+//                 Create Command              // Arguments
+const char         Start = 128;
+const char         Control = 130;
+const char         FullMode = 132;
+const char         Drive = 137;                // 4:   [Vel. Hi] [Vel Low] [Rad. Hi] [Rad. Low]
+const char         Sensors = 142;              // 1:    Sensor Packet ID
+const char         CoverandDock = 143;         // 0:    Return to Charger
+const char         Clean = 135;                 // 0:    Start Cleaning
+const char         PlaySong = 141;
+const char         Song = 140;
+const char         NewScript = 152;
+const char         DoScript = 153;
+const char         WaitTime = 155;
+const char         WaitAngle = 157;
+                /* iRobot Roomba Sensor IDs */
+const char         BumpsandDrops = 1;
+ 
+const int speed =  250;
+const int radius = 0x8000;
+void start();
+void forward();
+void reverse();
+void left();
+void right();
+void stop();
+void playsong(int mag);
+void charger();
+void initializeRobot();
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wifiunit.cpp	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,82 @@
+#include "mbed.h"
+#include "WiflyInterface.h"
+#include "HTTPClient.h"
+#include <vector>
+#include "SD.h"
+
+WiflyInterface wifly(p13, p14, p29, p30, "GTother", "GeorgeP@1927", WPA);
+
+HTTPClient http;
+char str[512];
+
+void setupWiFi()
+{
+    printf("trying to connect");
+    wifly.init();
+    while (!wifly.connect()) wait (0.1);
+    printf("IP Address is %s\n\r", wifly.getIPAddress());
+}
+
+vector<robotCommand>* getTagCommands(int tagID)
+{    
+    vector<robotCommand>* commandVector = new vector<robotCommand>();
+    printLCD("Translating", "Web Server");
+    char url[512];
+    char str[512];
+    sprintf(url, "http://sabacai.com/index.php?tag=%d", tagID);
+    printf("url is %s", url);
+    int ret = http.get(url, str, 512);
+    if (!ret) {
+        printf("Tag String Received - read %d characters\n", strlen(str));
+        str[strlen(str)-1] = '\0'; // remove the last column
+        printf("Result: %s\n", str);
+    }
+    
+    char * pch;
+    printf ("Splitting string \"%s\" into tokens:\n",str);
+    pch = strtok (str,",");
+    
+    int i = 0;
+    CommandType commandID = None;
+    
+    while (pch != NULL)
+    {
+        printf ("%s\n",pch);
+        double magnitude = 0.0;
+        
+        if ((i&0x1) == 0)
+        {
+            // this is the command type
+            if (strcmp(pch, "FORWARD") == 0)
+                commandID = Forward;
+            else if (strcmp(pch, "REVERSE") == 0)
+                commandID = Reverse; 
+            else if (strcmp(pch, "LEFT") == 0)
+                commandID = Left; 
+            else if (strcmp(pch, "RIGHT") == 0)
+                commandID = Right; 
+            else if (strcmp(pch, "PLAYSOUND") == 0)
+                commandID = PlaySound; 
+                
+            printf("command name is %s, id is %d", pch, commandID);
+        }
+        else 
+        {
+            // this is the magnitude
+            magnitude = atof(pch);
+            printf("magnitude is %f", magnitude);
+        }
+        
+        // do some stuff here
+        if (i != 0 && ((i&0x1) == 1))
+        {
+            // add the command to the vector
+            printf(" now adding %d, %f", commandID, magnitude);
+            commandVector->push_back(robotCommand(commandID, magnitude));
+        }
+        i+=1;
+        pch = strtok (NULL, ",");
+    }
+    
+    return commandVector;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wifiunit.h	Tue Dec 10 02:17:48 2013 +0000
@@ -0,0 +1,2 @@
+void setupWiFi();
+vector<robotCommand>* getTagCommands(int tagID);