Index: branches/slam/code/projects/slam/smart_run_around_fsm.h
===================================================================
--- branches/slam/code/projects/slam/smart_run_around_fsm.h	(revision 120)
+++ branches/slam/code/projects/slam/smart_run_around_fsm.h	(nonexistent)
@@ -1,33 +0,0 @@
-//Obstacle Avoid Numbers
-
-
-#ifndef _RUN_AROUND_FSM_H_
-#define _RUN_AROUND_FSM_H_
-
-//The States: 
-#define MOVING 12           //Move strait.
-#define BACKWARDS 15        //Move backwards. (Front close to wall.)
-#define STOP 16             //Stop.  The default state, (Something broke).
-#define CRAZY 40            //Erratic behavior that occurs more often when the robot is frequently trying to turn. (i.e. may be stuck.)
-
-#define LEFT 37             //Left
-#define RIGHT 39            //Right
-
-#define BACKUP_MAX 15
-#define CRAZY_MAX 200       //The number of counts between "crazy moments"
-#define STRAIT_SPEED 200    //The speed when going strait or backing up.
-#define TURN_CONSTANT 2
-#define PCONTROL_CRAZY_LIMIT 80
-
-int avoid_state;    /*State machine variable.*/
-int crazy_count;    /*Counter for a 'get unstuck' behavior.*/
-
-int backup_count;	/*Counter for backup duration.*/
-int pControl;		/*Proportional control variable, determines turn direction.*/
-int d1,d2,d3,d4,d5;	/*The five distances taken in by IR.*/
-
-void run_around_init(void);
-void run_around_FSM(void);
-void evaluate_state(void);
-
-#endif
Index: branches/slam/code/projects/slam/slam_analyzer.c
===================================================================
--- branches/slam/code/projects/slam/slam_analyzer.c	(revision 120)
+++ branches/slam/code/projects/slam/slam_analyzer.c	(nonexistent)
@@ -1,35 +0,0 @@
-#include "slam_analyzer.h"
-#include "slam_defs.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-
-
-void slam_analyze(RobotData* head){
-  //The good stuff.
-
-}
-
-
-
-void slam_print_data(RobotData* head){
-  if(head==NULL) printf("No data to display.\n");
-  RobotData* iter = head;
-  BomNode* bomIter;
-  char i;
-  while(iter!= NULL){
-    bomIter = iter->bom_head;
-    printf("Robot %x:\n",iter->id);
-    for(i=0;i<5;i++)
-      printf("\tSharp IR %i : %i\n\n",i,iter->IR[i]);
-    if(BomIter == NULL){
-        printf("No Bom Data to Display\n\n\n");
-    }
-    else{
-      while(bomIter!=NULL){
-        printf("\tBom reading for robot %x : %i",BomIter->id, BomIter->value);
-        bomIter = bomIter->next;
-      }
-    }
-  }
-}
Index: branches/slam/code/projects/slam/slam_analyzer.h
===================================================================
--- branches/slam/code/projects/slam/slam_analyzer.h	(revision 120)
+++ branches/slam/code/projects/slam/slam_analyzer.h	(nonexistent)
@@ -1,6 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <slam_defs.h>
-
-void slam_analyze(RobotData* head);
-void slam_print_data(RobotData* head);
Index: branches/slam/code/projects/slam/robot_main.c
===================================================================
--- branches/slam/code/projects/slam/robot_main.c	(revision 120)
+++ branches/slam/code/projects/slam/robot_main.c	(nonexistent)
@@ -1,132 +0,0 @@
-#include "dragonfly_lib.h"
-#include "wireless.h"
-#include "wl_token_ring.h"
-#include "smart_run_around_fsm.h"
-#include "slam_defs.h"
-
-#define BOM_POST_DELAY 50
-#define PACKET_BUFFER_SIZE 101 
-
-void bom_pre(void);
-void bom_post(void);
-
-//Packet Handler Functions
-void timeout_handle(void);
-void response_handle(int frame, int received);
-void receive_handle(char type, int source, unsigned char* packet, int length);
-void unregister(void);
-
-int make_request_packet(char** packet);
-
-int IR[5];
-
-int main(void)
-{
-
-  dragonfly_init(ALL_ON);
-  
-  wl_init();
- 
-  wl_token_ring_register();
-  wl_token_ring_join();
-  wl_token_ring_set_bom_functions(bom_pre, bom_post, get_max_bom);
-
-  PacketGroupHandler packet_group_handler;
-  packet_group_handler.groupCode=SLAM_PACKET_GROUP;
-  packet_group_handler.timeout_handler=timeout_handle;
-  packet_group_handler.handle_response=response_handle;
-  packet_group_handler.handle_receive=receive_handle;
-  packet_group_handler.unregister=unregister;
-
-  wl_register_packet_group(&packet_group_handler);
-  
-  int i;
-  while(1){
-    wl_do();
-    run_around_FSM(); 
-    for(i=0;i<5;i++){
-      IR[i]=range_read_distance(i);
-    }
-  }
-
-  wl_unregister_packet_group(&packet_group_handler); 
-}
-
-void bom_pre(void){
-    bom_on();
-}
-
-void bom_post(void){
-    delay_ms(BOM_POST_DELAY);
-    bom_off();
-}
-
-//These can probably be NULL..
-
-void timeout_handle(void){
-
-}
-
-void response_handle(int frame, int received){
-  
-}
-
-void receive_handle(char type, int source, unsigned char* packet, int length){
-  int i; 
-  if(type==REQUEST_PACKET_TYPE){
-    
-    /*Send a message back to our computer overlord.*/
-    char buf[PACKET_BUFFER_SIZE]; 
-    int len = make_request_packet((char**)&buf);
-    char packet[len];
-    for(i=0; i< len ; i++){
-      packet[i]=buf[i];
-    } 
-    
-    wl_send_robot_to_robot_packet(SLAM_PACKET_GROUP, ROBOT_RESPONSE, packet, len, source , 0);
-  }
-  else if(type == CONTROL_PACKET_TYPE){
-    for(i=0;i<length;i++){
-      
-    }
-  }
-}
-
-
-/**
-
-Packets are structured {IR1, IR2, IR3, IR4, IR5,
-BomID1, ... , BomValue1, BomID2, ... , BomValue2, etc.} 
-Total size is 5 + 3*numRobots. So Xbee should support
-up to 31 robots before we need to restructure the 
-communication between the computer and the robot.
-
-*/
-int make_request_packet(char** packet){
-  int i;
-  for(i=0;i<5;i++){
-      (*packet)[i] = IR[i];
-  } 
-  i=5; 
-  wl_token_iterator_begin();
-  int id = wl_get_xbee_id();  
-  
-  while(wl_token_iterator_has_next()){
-    int robot_in_view = wl_token_iterator_next(); 
-    
-    //Robot int's are two bytes. 
-    (*packet)[i] = robot_in_view; 
-    i+=2;
-    
-    int bom_number = wl_token_get_sensor_reading(id,robot_in_view);
-    //Bom reading of 255 denotes an unseen node. 
-    if(bom_number<0) bom_number = 255; 
-    bom_number %= 256;
-    char bom_value = (char) bom_number;
-    (*packet)[i] = bom_value;
-    i++;
-  }
-  //Size is one bom byte towards every robot, and 5 IR bytes. 
-  return wl_token_get_num_robots()+5;
-}
-
Index: branches/slam/code/projects/slam/smart_run_around_fsm.c
===================================================================
--- branches/slam/code/projects/slam/smart_run_around_fsm.c	(revision 120)
+++ branches/slam/code/projects/slam/smart_run_around_fsm.c	(nonexistent)
@@ -1,135 +0,0 @@
-#include "dragonfly_lib.h"
-#include "smart_run_around_fsm.h"
-
-/*A simple behavior for navigating in an environment, i.e. avoiding walls and getting stuck.
-Could be better at not getting stuck.
-
-Latest revision only has two accessible states: move and reverse.
-*/
-
-
-void run_around_init(void)
-{
-  range_init();
-  analog_init();
-  motors_init();
-  orb_init();
-  orb_enable();
-  usb_init();
- 
-  /*Start in the default state, MOVING*/ 
-  avoid_state=MOVING;
-  /*Set timers to their maximum values.*/
-  crazy_count=CRAZY_MAX;
-  backup_count=0; 
-  pControl=0;
-  
-  /*Initialize distances to zero.*/ 
-  d1=0; d2=0; d3=0; d4=0; d5=0;
-  
-  orb_set_color(GREEN);
-
-}
-
-/*The main function, call this to update states as frequently as possible.*/
-void run_around_FSM(void) {
-  /*Default to moving.*/ 
-  avoid_state=MOVING;
-  
-  /*The following lines ensure that undefined (-1) values
-  will not update the distances.*/ 
-  int temp;
-  
-  temp=range_read_distance(IR1);
-  d1=(temp == -1) ? d1 : temp;
-  
-  temp=range_read_distance(IR2);
-  d2=(temp == -1) ? d2 : temp;
-  
-  temp=range_read_distance(IR3);
-  d3=(temp == -1) ? d3 : temp;
-  
-  temp=range_read_distance(IR4);
-  d4=(temp == -1) ? d4 : temp;
-  
-  temp=range_read_distance(IR5);
-  d5=(temp == -1) ? d5 : temp;
-  
-  /*If the crazy count is in it's >>3 range, it acts crazy.*/
-  if(crazy_count<=(CRAZY_MAX>>3))
-  {
-    avoid_state=CRAZY;
-    crazy_count--;
-    
-    if(crazy_count<0) crazy_count=CRAZY_MAX;
-    
-    evaluate_state();
-    return;
-  }
-  
-  //Checks the forward distance to see if it should back up, if so...state backwards.
-  if((d2!=-1)&&(d2 >150)){
-      backup_count=BACKUP_MAX;
-      avoid_state=BACKWARDS;
-      evaluate_state();
-      return;
-  }
- 
-  if(backup_count<BACKUP_MAX){
-    avoid_state=BACKWARDS; 
-    if(backup_count<0)
-      backup_count=BACKUP_MAX;
-    evaluate_state();
-    return;
-  }
-  
-  /*Should evaluate an expression from -255 to 255 to pass to move.*/
-  pControl= ((d3-d1) + (d4-d5)) >> TURN_CONSTANT;
-  
-  if(pControl>PCONTROL_CRAZY_LIMIT || pControl<-PCONTROL_CRAZY_LIMIT) crazy_count--;
-  /*i.e. if you really want to turn for an extended period of time...you're probably stuck.*/
-
-  /*Debug stuff:*/
-  /*usb_puts("pControl evaluating: ");
-  usb_puti(pControl);
-  usb_puts("\n\r");
-  usb_puts("IR1: ");
-  usb_puti(d1);
-  usb_puts(" IR2: ");
-  usb_puti(d2);
-  usb_puts(" IR3: ");
-  usb_puti(d3);
-  usb_puts(" IR4: ");
-  usb_puti(d4);
-  usb_puts(" IR5: ");
-  usb_puti(d5);
-  usb_puts("\n\r");*/
-  
-  evaluate_state();
-}
-
-
-//Acts on state change.
-void evaluate_state(){
-    switch(avoid_state){
-    case(MOVING): orb_set_color(GREEN);
-      move(STRAIT_SPEED,pControl);
-      break;
-    
-    case(BACKWARDS): orb_set_color(ORANGE);
-      move(-STRAIT_SPEED,0);
-      break;
-      
-    case(CRAZY): orb_set_color(RED);
-      /*TODO: Implement a crazy state.*/
-      move(STRAIT_SPEED,pControl);
-      break;
-      
-    default:
-      /*Should never get here, go strait.*/
-      move(100,0); orb_set_color(BLUE);
-      break;
-  }
-}
-
-
Index: branches/slam/code/projects/slam/computer_main.c
===================================================================
--- branches/slam/code/projects/slam/computer_main.c	(revision 120)
+++ branches/slam/code/projects/slam/computer_main.c	(nonexistent)
@@ -1,108 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "wireless.h"
-#include "wl_token_ring.h"
-#include "slam_analyzer.h"
-
-void handle_timeout(void);
-void handle_response(int frame, int received);
-void handle_receive(char type, int source, unsigned char* packet, int length);
-void unregister(void);
-RobotData* getRobot(int id);
-
-RobotData* head_bot;
-RobotData* current_bot;
-
-int main(void)
-{
-  PacketGroupHandler* pgh = malloc(sizeof(PacketGroupHandler)); 
-  pgh->groupCode = SLAM_PACKET_GROUP;
-  pgh->timeout_handler = handle_timeout;
-  pgh->handle_response = handle_response;
-  pgh->handle_receive = handle_receive;
-  pgh->unregister = unregister;
-
-  
-  wl_init();
-  wl_register_packet_group(pgh);
-  wl_token_ring_register();
-  //wl_token_ring_join();
-  //wl_token_ring_set_bom_functions(NULL,NULL,NULL);
-
-  while(1){
-    wl_do();
-    wl_token_iterator_begin();
-    
-    //Iterate through the robots in the token ring. 
-    while(wl_token_iterator_has_next()){
-      wl_send_robot_to_robot_packet(SLAM_PACKET_GROUP,REQUEST_PACKET_TYPE,
-        NULL,0,wl_token_iterator_next(),0);   
-      //head_bot will not be modified by the analyzer. 
-      usleep(50000); 
-    }
-    slam_analyze(head_bot);
-  } 
-	return 0;
-}
-
-void handle_timeout(void){}
-void handle_response(int frame, int received){}
-
-void handle_receive(char type, int source, unsigned char* packet, int length){
-  if(type == ROBOT_RESPONSE){
-    int i; 
-    current_bot = getRobot(source);
-    if(current_bot == NULL){
-      //Add the new robot to the front of the list.
-      current_bot = malloc(sizeof(RobotData));
-      current_bot->next = head_bot; //Works even if head_bot is null.
-      head_bot = current_bot;
-    }
-    for(i=0;i<5;i++)
-      current_bot->IR[i] = packet[i];
-    i++; //i=5 
-   
-    //Bom Handling.
-    //Clear the current information.
-    BomNode* head = current_bot->bom_head;
-    if(head!=NULL){
-      BomNode* next = head->next;
-      while(next!=NULL){
-        free(head);
-        head = next;
-        next = head->next;
-      }
-      free(head);
-    }
-    //All of the memory allocated for the BomList is free.
-
-    //The remainder of the packet is bom data. 
-    BomNode* bom_node;
-    current_bot->bom_head = bom_node;
-    //i still points to the first bom information spot at 5. 
-    while(i<length){
-      bom_node = malloc(sizeof BomNode);
-      bom_node->id = ((short int)((short)packet[i++]<<8) + packet[i++]);
-      if(i>=length){
-        printf("Packet not constructed correctly. Terminate. \n");
-        exit(EXIT_FAILURE);
-      }
-      bom_node->value = packet[i++];
-      if(i>=length){
-        printf("Packet not constructed correctly. Terminate. \n");
-        exit(EXIT_FAILURE);
-      }
-      bom_node = bom_node->next;
-    }
-  }
-}
-
-RobotData* getRobot(int id){
-  RobotData* next = head_bot; 
-  while(next->id != id && next->next!=NULL);
-  
-  if(next->id != id) return NULL;
-  else return next;
-}
-
Index: branches/slam/code/projects/slam/test/monitor_test.c
===================================================================
--- branches/slam/code/projects/slam/test/monitor_test.c	(nonexistent)
+++ branches/slam/code/projects/slam/test/monitor_test.c	(revision 121)
@@ -0,0 +1,7 @@
+#include <dragonfly_lib.h>
+void main(void){
+  usb_init(); 
+  while(1){
+    usb_puts("hey bro\n");
+  }
+}
Index: branches/slam/code/projects/slam/test/Makefile
===================================================================
--- branches/slam/code/projects/slam/test/Makefile	(nonexistent)
+++ branches/slam/code/projects/slam/test/Makefile	(revision 121)
@@ -0,0 +1,520 @@
+########Update This Section########
+#
+#
+
+# Relative path to the root directory (containing lib directory)
+ifndef COLONYROOT
+COLONYROOT = ../../..
+endif
+
+# Target file name (without extension).
+TARGET = template
+
+# Uncomment this to use the wireless library
+USE_WIRELESS = 1
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = /dev/cu.usbserial-A4001hAA
+#
+#
+###################################
+
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+#if you want your code to work on the Firefly++ and not Firefly+
+#then add the -DFFPP line to CDEFS
+CDEFS = 
+#-DFFPP
+
+# MCU name
+MCU = atmega128
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the 
+#     processor frequency. You can then use this symbol in your source code to 
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+F_CPU = 8000000
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(wildcard *.c)
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC = 
+
+# Optimization level, can be [0, 1, 2, 3, s]. 
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG =
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+# Place -D or -U options here
+CDEFS += -DF_CPU=$(F_CPU)UL 
+CDEFS += -DFFP
+# for wireless library
+ifdef USE_WIRELESS
+	CDEFS += -DROBOT
+endif
+
+# Place -I, -L options here
+CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly 
+CINCS += -L$(COLONYROOT)/code/lib/bin
+ifdef USE_WIRELESS
+	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
+endif
+
+#---------------- Compiler Options ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS =
+# CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(CSTANDARD)
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+PRINTF_LIB = 
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB = 
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+MATH_LIB = -lm
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+ifdef USE_WIRELESS
+	LDFLAGS += -lwireless
+endif
+LDFLAGS += -ldragonfly
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd 
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = avrisp
+
+# programmer connected to serial device
+
+AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+#don't check for device signature
+AVRDUDE_FLAGS += -F
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+# DEBUG_UI = gdb
+DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+DEBUG_BACKEND = avarice
+#DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when 
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before: 
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
+
+# Define all listing files.
+LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) 
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss 
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+	@echo
+	@echo $(MSG_BEGIN)
+
+end:
+	@echo $(MSG_END)
+	@echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion : 
+	@$(CC) --version
+
+
+
+# Program the device.  
+program: $(TARGET).hex $(TARGET).eep
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set 
+#     a breakpoint at main().
+gdb-config: 
+	@$(REMOVE) $(GDBINIT_FILE)
+	@echo define reset >> $(GDBINIT_FILE)
+	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+	@echo end >> $(GDBINIT_FILE)
+	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
+	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+ifeq ($(DEBUG_BACKEND),simulavr)
+	@echo load  >> $(GDBINIT_FILE)
+endif	
+	@echo break main >> $(GDBINIT_FILE)
+	
+debug: gdb-config $(TARGET).elf
+ifeq ($(DEBUG_BACKEND), avarice)
+	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+	@$(WINSHELL) /c pause
+	
+else
+	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
+endif
+	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+	
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000 
+
+
+coff: $(TARGET).elf
+	@echo
+	@echo $(MSG_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+	@echo
+	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+	@echo
+	@echo $(MSG_FLASH) $@
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+	@echo
+	@echo $(MSG_EEPROM) $@
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+	@echo
+	@echo $(MSG_EXTENDED_LISTING) $@
+	$(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+	@echo
+	@echo $(MSG_SYMBOL_TABLE) $@
+	$(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+	@echo
+	@echo $(MSG_LINKING) $@
+	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+	@echo
+	@echo $(MSG_COMPILING) $<
+	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+	@echo
+	@echo $(MSG_ASSEMBLING) $<
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ 
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+	@echo
+	@echo $(MSG_CLEANING)
+	$(REMOVE) $(TARGET).hex
+	$(REMOVE) $(TARGET).eep
+	$(REMOVE) $(TARGET).cof
+	$(REMOVE) $(TARGET).elf
+	$(REMOVE) $(TARGET).map
+	$(REMOVE) $(TARGET).sym
+	$(REMOVE) $(TARGET).lss
+	$(REMOVE) $(OBJ)
+	$(REMOVE) $(LST)
+	$(REMOVE) $(SRC:.c=.s)
+	$(REMOVE) $(SRC:.c=.d)
+	$(REMOVEDIR) .dep
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
Index: branches/slam/code/projects/slam/robot/monitor_test.lst
===================================================================
--- branches/slam/code/projects/slam/robot/monitor_test.lst	(nonexistent)
+++ branches/slam/code/projects/slam/robot/monitor_test.lst	(revision 121)
@@ -0,0 +1,37 @@
+   1               		.file	"monitor_test.c"
+   2               		.arch atmega128
+   3               	__SREG__ = 0x3f
+   4               	__SP_H__ = 0x3e
+   5               	__SP_L__ = 0x3d
+   6               	__tmp_reg__ = 0
+   7               	__zero_reg__ = 1
+   8               		.global __do_copy_data
+   9               		.global __do_clear_bss
+  10               		.text
+  11               	.global	main
+  13               	main:
+  14               	/* prologue: frame size=0 */
+  15 0000 C0E0      		ldi r28,lo8(__stack - 0)
+  16 0002 D0E0      		ldi r29,hi8(__stack - 0)
+  17 0004 DEBF      		out __SP_H__,r29
+  18 0006 CDBF      		out __SP_L__,r28
+  19               	/* prologue end (size=4) */
+  20               	/* epilogue: frame size=0 */
+  21 0008 0C94 0000 		jmp exit
+  22               	/* epilogue end (size=2) */
+  23               	/* function main size 6 (0) */
+  25               	/* File "monitor_test.c": code    6 = 0x0006 (   0), prologues   4, epilogues   2 */
+DEFINED SYMBOLS
+                            *ABS*:00000000 monitor_test.c
+/var/tmp//cc3WAcUk.s:3      *ABS*:0000003f __SREG__
+/var/tmp//cc3WAcUk.s:4      *ABS*:0000003e __SP_H__
+/var/tmp//cc3WAcUk.s:5      *ABS*:0000003d __SP_L__
+/var/tmp//cc3WAcUk.s:6      *ABS*:00000000 __tmp_reg__
+/var/tmp//cc3WAcUk.s:7      *ABS*:00000001 __zero_reg__
+/var/tmp//cc3WAcUk.s:13     .text:00000000 main
+
+UNDEFINED SYMBOLS
+__do_copy_data
+__do_clear_bss
+__stack
+exit
Index: branches/slam/code/projects/slam/robot/smart_run_around_fsm.c
===================================================================
--- branches/slam/code/projects/slam/robot/smart_run_around_fsm.c	(nonexistent)
+++ branches/slam/code/projects/slam/robot/smart_run_around_fsm.c	(revision 121)
@@ -0,0 +1,135 @@
+#include "dragonfly_lib.h"
+#include "smart_run_around_fsm.h"
+
+/*A simple behavior for navigating in an environment, i.e. avoiding walls and getting stuck.
+Could be better at not getting stuck.
+
+Latest revision only has two accessible states: move and reverse.
+*/
+
+
+void run_around_init(void)
+{
+  range_init();
+  analog_init();
+  motors_init();
+  orb_init();
+  orb_enable();
+  usb_init();
+ 
+  /*Start in the default state, MOVING*/ 
+  avoid_state=MOVING;
+  /*Set timers to their maximum values.*/
+  crazy_count=CRAZY_MAX;
+  backup_count=0; 
+  pControl=0;
+  
+  /*Initialize distances to zero.*/ 
+  d1=0; d2=0; d3=0; d4=0; d5=0;
+  
+  orb_set_color(GREEN);
+
+}
+
+/*The main function, call this to update states as frequently as possible.*/
+void run_around_FSM(void) {
+  /*Default to moving.*/ 
+  avoid_state=MOVING;
+  
+  /*The following lines ensure that undefined (-1) values
+  will not update the distances.*/ 
+  int temp;
+  
+  temp=range_read_distance(IR1);
+  d1=(temp == -1) ? d1 : temp;
+  
+  temp=range_read_distance(IR2);
+  d2=(temp == -1) ? d2 : temp;
+  
+  temp=range_read_distance(IR3);
+  d3=(temp == -1) ? d3 : temp;
+  
+  temp=range_read_distance(IR4);
+  d4=(temp == -1) ? d4 : temp;
+  
+  temp=range_read_distance(IR5);
+  d5=(temp == -1) ? d5 : temp;
+  
+  /*If the crazy count is in it's >>3 range, it acts crazy.*/
+  if(crazy_count<=(CRAZY_MAX>>3))
+  {
+    avoid_state=CRAZY;
+    crazy_count--;
+    
+    if(crazy_count<0) crazy_count=CRAZY_MAX;
+    
+    evaluate_state();
+    return;
+  }
+  
+  //Checks the forward distance to see if it should back up, if so...state backwards.
+  if((d2!=-1)&&(d2 >150)){
+      backup_count=BACKUP_MAX;
+      avoid_state=BACKWARDS;
+      evaluate_state();
+      return;
+  }
+ 
+  if(backup_count<BACKUP_MAX){
+    avoid_state=BACKWARDS; 
+    if(backup_count<0)
+      backup_count=BACKUP_MAX;
+    evaluate_state();
+    return;
+  }
+  
+  /*Should evaluate an expression from -255 to 255 to pass to move.*/
+  pControl= ((d3-d1) + (d4-d5)) >> TURN_CONSTANT;
+  
+  if(pControl>PCONTROL_CRAZY_LIMIT || pControl<-PCONTROL_CRAZY_LIMIT) crazy_count--;
+  /*i.e. if you really want to turn for an extended period of time...you're probably stuck.*/
+
+  /*Debug stuff:*/
+  /*usb_puts("pControl evaluating: ");
+  usb_puti(pControl);
+  usb_puts("\n\r");
+  usb_puts("IR1: ");
+  usb_puti(d1);
+  usb_puts(" IR2: ");
+  usb_puti(d2);
+  usb_puts(" IR3: ");
+  usb_puti(d3);
+  usb_puts(" IR4: ");
+  usb_puti(d4);
+  usb_puts(" IR5: ");
+  usb_puti(d5);
+  usb_puts("\n\r");*/
+  
+  evaluate_state();
+}
+
+
+//Acts on state change.
+void evaluate_state(){
+    switch(avoid_state){
+    case(MOVING): orb_set_color(GREEN);
+      move(STRAIT_SPEED,pControl);
+      break;
+    
+    case(BACKWARDS): orb_set_color(ORANGE);
+      move(-STRAIT_SPEED,0);
+      break;
+      
+    case(CRAZY): orb_set_color(RED);
+      /*TODO: Implement a crazy state.*/
+      move(STRAIT_SPEED,pControl);
+      break;
+      
+    default:
+      /*Should never get here, go strait.*/
+      move(100,0); orb_set_color(BLUE);
+      break;
+  }
+}
+
+
Index: branches/slam/code/projects/slam/robot/robot_main.c
===================================================================
--- branches/slam/code/projects/slam/robot/robot_main.c	(nonexistent)
+++ branches/slam/code/projects/slam/robot/robot_main.c	(revision 121)
@@ -0,0 +1,133 @@
+#include "dragonfly_lib.h"
+#include "../../libwireless/lib/wireless.h"
+#include "../../libwireless/lib/wl_token_ring.h"
+#include "smart_run_around_fsm.h"
+#include "../slam_defs.h"
+
+#define BOM_POST_DELAY 0
+#define PACKET_BUFFER_SIZE 101 
+
+//Packet Handler Functions
+void receive_handle(char type, int source, unsigned char* packet, int length);
+void unregister(void);
+
+int make_request_packet(char** packet);
+void send_response_packet(int dest);
+
+unsigned int response_flag = 0; //Will represent the robot to respond to or 0 for no robot.
+char control_flag=0;             //Non zero when the robot is to be controlled.
+int IR[5];
+
+int main(void)
+{
+
+  dragonfly_init(ALL_ON);
+  
+  usb_init();
+  usb_puts("USB initialized\n\n\r");
+  
+  wl_init();
+ 
+  wl_token_ring_register();
+  wl_token_ring_join();
+
+  PacketGroupHandler packet_group_handler;
+  packet_group_handler.groupCode=SLAM_PACKET_GROUP;
+  packet_group_handler.timeout_handler=NULL;
+  packet_group_handler.handle_response=NULL;
+  packet_group_handler.handle_receive=receive_handle;
+  packet_group_handler.unregister=unregister;
+
+  wl_register_packet_group(&packet_group_handler);
+  
+  int i;
+  while(1){
+    wl_do();
+    //Uncomment this if you want the robot to do something. 
+    //run_around_FSM(); 
+    
+    for(i=0;i<5;i++){
+      IR[i]=range_read_distance(i);
+    }
+    if(response_flag){
+      send_response_packet(response_flag);
+      response_flag=0;
+    }
+    if(control_flag){
+      //FILL IN HERE
+    }
+
+  }
+
+  wl_unregister_packet_group(&packet_group_handler); 
+}
+
+void send_response_packet(int dest){
+    
+    usb_puts("Sending a response packet to ");
+    usb_puti(dest);
+    usb_puts(".\n\r");
+    
+    char buf[PACKET_BUFFER_SIZE]; 
+    int len = make_request_packet((char**)&buf), i;
+    char packet[len];
+    for(i=0; i< len ; i++){
+      packet[i]=buf[i];
+    } 
+    
+    wl_send_robot_to_robot_packet(SLAM_PACKET_GROUP, ROBOT_RESPONSE, packet, len, dest, 0);
+}
+
+void receive_handle(char type, int source, unsigned char* packet, int length){
+  if(type==REQUEST_PACKET_TYPE){
+    usb_puts("Received a request packet\n\r");
+    response_flag = source;
+  }
+  //Not yet implemented:
+  else if(type == CONTROL_PACKET_TYPE){
+    control_flag = 1;
+    //Put packet data into some global.
+  }
+}
+
+
+/**
+
+Packets are structured {IR1, IR2, IR3, IR4, IR5,
+BomID1, ... , BomValue1, BomID2, ... , BomValue2, etc.} 
+Total size is 5 + 3*numRobots. So Xbee should support
+up to 31 robots before we need to restructure the 
+communication between the computer and the robot.
+
+*/
+int make_request_packet(char** packet){
+  int i;
+  for(i=0;i<5;i++){
+      (*packet)[i] = IR[i];
+  } 
+  i=5; 
+  wl_token_iterator_begin();
+  int id = wl_get_xbee_id();  
+  
+  while(wl_token_iterator_has_next()){
+    int robot_in_view = wl_token_iterator_next(); 
+    
+    //Robot int's are two bytes. 
+    (*packet)[i] = robot_in_view; 
+    i+=2;
+    
+    int bom_number = wl_token_get_sensor_reading(id,robot_in_view);
+    //Bom reading of 255 denotes an unseen node. 
+    if(bom_number<0) bom_number = 255; 
+    bom_number %= 256;
+    char bom_value = (char) bom_number;
+    (*packet)[i] = bom_value;
+    i++;
+  }
+  //Size is one bom byte towards every robot, and 5 IR bytes. 
+  return wl_token_get_num_robots()+5;
+}
+
+void unregister(void){
+  return;
+}
Index: branches/slam/code/projects/slam/robot/robotize_lib.sh
===================================================================
--- branches/slam/code/projects/slam/robot/robotize_lib.sh	(nonexistent)
+++ branches/slam/code/projects/slam/robot/robotize_lib.sh	(revision 121)
@@ -0,0 +1,5 @@
+cd ../../libwireless/lib;
+make clean;
+make all;
+make publish;
+cd ../../slam/computer;

Property changes on: branches/slam/code/projects/slam/robot/robotize_lib.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/slam/code/projects/slam/robot/Makefile
===================================================================
--- branches/slam/code/projects/slam/robot/Makefile	(nonexistent)
+++ branches/slam/code/projects/slam/robot/Makefile	(revision 121)
@@ -0,0 +1,520 @@
+########Update This Section########
+#
+#
+
+# Relative path to the root directory (containing lib directory)
+ifndef COLONYROOT
+COLONYROOT = ../../..
+endif
+
+# Target file name (without extension).
+TARGET = robot_main
+
+# Uncomment this to use the wireless library
+USE_WIRELESS = 1
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = /dev/cu.usbserial-A4001hAK
+#
+#
+###################################
+
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+#if you want your code to work on the Firefly++ and not Firefly+
+#then add the -DFFPP line to CDEFS
+CDEFS = 
+#-DFFPP
+
+# MCU name
+MCU = atmega128
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the 
+#     processor frequency. You can then use this symbol in your source code to 
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+F_CPU = 8000000
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(wildcard *.c)
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC = 
+
+# Optimization level, can be [0, 1, 2, 3, s]. 
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG =
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+# Place -D or -U options here
+CDEFS += -DF_CPU=$(F_CPU)UL 
+CDEFS += -DFFP
+# for wireless library
+ifdef USE_WIRELESS
+	CDEFS += -DROBOT
+endif
+
+# Place -I, -L options here
+CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly 
+CINCS += -L$(COLONYROOT)/code/lib/bin
+ifdef USE_WIRELESS
+	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
+endif
+
+#---------------- Compiler Options ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS =
+# CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(CSTANDARD)
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+PRINTF_LIB = 
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB = 
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+MATH_LIB = -lm
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+ifdef USE_WIRELESS
+	LDFLAGS += -lwireless
+endif
+LDFLAGS += -ldragonfly
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd 
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = avrisp
+
+# programmer connected to serial device
+
+AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+#don't check for device signature
+AVRDUDE_FLAGS += -F
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+# DEBUG_UI = gdb
+DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+DEBUG_BACKEND = avarice
+#DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when 
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before: 
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
+
+# Define all listing files.
+LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) 
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss 
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+	@echo
+	@echo $(MSG_BEGIN)
+
+end:
+	@echo $(MSG_END)
+	@echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion : 
+	@$(CC) --version
+
+
+
+# Program the device.  
+program: $(TARGET).hex $(TARGET).eep
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set 
+#     a breakpoint at main().
+gdb-config: 
+	@$(REMOVE) $(GDBINIT_FILE)
+	@echo define reset >> $(GDBINIT_FILE)
+	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+	@echo end >> $(GDBINIT_FILE)
+	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
+	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+ifeq ($(DEBUG_BACKEND),simulavr)
+	@echo load  >> $(GDBINIT_FILE)
+endif	
+	@echo break main >> $(GDBINIT_FILE)
+	
+debug: gdb-config $(TARGET).elf
+ifeq ($(DEBUG_BACKEND), avarice)
+	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+	@$(WINSHELL) /c pause
+	
+else
+	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
+endif
+	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+	
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000 
+
+
+coff: $(TARGET).elf
+	@echo
+	@echo $(MSG_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+	@echo
+	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+	@echo
+	@echo $(MSG_FLASH) $@
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+	@echo
+	@echo $(MSG_EEPROM) $@
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+	@echo
+	@echo $(MSG_EXTENDED_LISTING) $@
+	$(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+	@echo
+	@echo $(MSG_SYMBOL_TABLE) $@
+	$(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+	@echo
+	@echo $(MSG_LINKING) $@
+	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+	@echo
+	@echo $(MSG_COMPILING) $<
+	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+	@echo
+	@echo $(MSG_ASSEMBLING) $<
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ 
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+	@echo
+	@echo $(MSG_CLEANING)
+	$(REMOVE) $(TARGET).hex
+	$(REMOVE) $(TARGET).eep
+	$(REMOVE) $(TARGET).cof
+	$(REMOVE) $(TARGET).elf
+	$(REMOVE) $(TARGET).map
+	$(REMOVE) $(TARGET).sym
+	$(REMOVE) $(TARGET).lss
+	$(REMOVE) $(OBJ)
+	$(REMOVE) $(LST)
+	$(REMOVE) $(SRC:.c=.s)
+	$(REMOVE) $(SRC:.c=.d)
+	$(REMOVEDIR) .dep
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
Index: branches/slam/code/projects/slam/robot/smart_run_around_fsm.h
===================================================================
--- branches/slam/code/projects/slam/robot/smart_run_around_fsm.h	(nonexistent)
+++ branches/slam/code/projects/slam/robot/smart_run_around_fsm.h	(revision 121)
@@ -0,0 +1,33 @@
+//Obstacle Avoid Numbers
+
+
+#ifndef _RUN_AROUND_FSM_H_
+#define _RUN_AROUND_FSM_H_
+
+//The States: 
+#define MOVING 12           //Move strait.
+#define BACKWARDS 15        //Move backwards. (Front close to wall.)
+#define STOP 16             //Stop.  The default state, (Something broke).
+#define CRAZY 40            //Erratic behavior that occurs more often when the robot is frequently trying to turn. (i.e. may be stuck.)
+
+#define LEFT 37             //Left
+#define RIGHT 39            //Right
+
+#define BACKUP_MAX 15
+#define CRAZY_MAX 200       //The number of counts between "crazy moments"
+#define STRAIT_SPEED 200    //The speed when going strait or backing up.
+#define TURN_CONSTANT 2
+#define PCONTROL_CRAZY_LIMIT 80
+
+int avoid_state;    /*State machine variable.*/
+int crazy_count;    /*Counter for a 'get unstuck' behavior.*/
+
+int backup_count;	/*Counter for backup duration.*/
+int pControl;		/*Proportional control variable, determines turn direction.*/
+int d1,d2,d3,d4,d5;	/*The five distances taken in by IR.*/
+
+void run_around_init(void);
+void run_around_FSM(void);
+void evaluate_state(void);
+
+#endif
Index: branches/slam/code/projects/slam/computer/slam_analyzer.c
===================================================================
--- branches/slam/code/projects/slam/computer/slam_analyzer.c	(nonexistent)
+++ branches/slam/code/projects/slam/computer/slam_analyzer.c	(revision 121)
@@ -0,0 +1,29 @@
+#include "slam_analyzer.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+void slam_analyze(RobotData* head){
+  printf("Analyzing..\n");
+}
+
+void slam_print_data(RobotData* head){
+  if(head==NULL) printf("No data to display.\n");
+  RobotData* iter = head;
+  BomNode* bomIter;
+  char i;
+  while(iter!= NULL){
+    bomIter = iter->bom_head;
+    printf("Robot %x:\n",iter->id);
+    for(i=0;i<5;i++)
+      printf("\tSharp IR %i : %i\n\n",i,iter->IR[i]);
+    if(BomIter == NULL){
+        printf("No Bom Data to Display\n\n\n");
+    }
+    else{
+      while(bomIter!=NULL){
+        printf("\tBom reading for robot %x : %i",BomIter->id, BomIter->value);
+        bomIter = bomIter->next;
+      }
+    }
+  }
+}
Index: branches/slam/code/projects/slam/computer/computer_main.c
===================================================================
--- branches/slam/code/projects/slam/computer/computer_main.c	(nonexistent)
+++ branches/slam/code/projects/slam/computer/computer_main.c	(revision 121)
@@ -0,0 +1,133 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthread.h>
+#include "../../libwireless/lib/wireless.h"
+#include "../../libwireless/lib/wl_token_ring.h"
+#include "slam_analyzer.h"
+
+//Currently request information 2 times a second.
+#define SLAM_REQUEST_DELAY 500000
+
+void handle_receive(char type, int source, unsigned char* packet, int length);
+void unregister(void);
+
+void slam_request_thread(void*);
+
+RobotData* getRobot(int id);
+
+RobotData* head_bot;
+RobotData* current_bot;
+
+int main(void)
+{
+  PacketGroupHandler* pgh = malloc(sizeof(PacketGroupHandler)); 
+  pgh->groupCode = SLAM_PACKET_GROUP;
+  pgh->timeout_handler = NULL;
+  pgh->handle_response = NULL;
+  pgh->handle_receive = handle_receive;
+  pgh->unregister = unregister;
+
+  
+  wl_init();
+  wl_register_packet_group(pgh);
+  wl_token_ring_register();
+  
+  //wl_token_ring_join();
+
+
+  printf("Computer SLAM initialized\n\n");
+ 
+  //Run the requesting thread simultaneously.
+  pthread_t request_thread;
+  pthread_create(&request_thread,NULL,slam_request_thread,NULL);
+  while(1){
+      wl_do(); //Receive packets (responses to Request packets.)
+  }
+	return 0;
+}
+
+//Blocking thread.
+void slam_request_thread(void* asdf){
+    
+    //int count = 0;
+    
+    while(1){
+      
+      wl_token_iterator_begin();
+      
+      while(wl_token_iterator_has_next()){
+        int next = wl_token_iterator_next();
+        printf("Sending a request packet to %i\n",next);
+        wl_send_robot_to_robot_packet(SLAM_PACKET_GROUP,REQUEST_PACKET_TYPE,
+          NULL,0,next,0);  
+      }
+      usleep(50000);
+    }
+    usleep(50000);
+}
+
+void handle_receive(char type, int source, unsigned char* packet, int length){
+  printf("Received a packet\n");
+  if(type == ROBOT_RESPONSE){
+    int i=0; 
+    current_bot = getRobot(source);
+    if(current_bot == NULL){
+      //Add the new robot to the front of the list.
+      current_bot = malloc(sizeof(RobotData));
+      current_bot->next = head_bot; //Works even if head_bot is null.
+      head_bot = current_bot;
+    }
+    for(i=0;i<5;i++){
+      current_bot->IR[i] = packet[i];
+      printf("*");
+    }
+    i++; //i=5 
+   
+    //Bom Handling.
+    //Clear the current information.
+    BomNode* head = current_bot->bom_head;
+    if(head!=NULL){
+      BomNode* next = head->next;
+      while(next!=NULL){
+        free(head);
+        head = next;
+        next = head->next;
+      }
+      free(head);
+    }
+    //All of the memory allocated for the BomList is free.
+
+    //The remainder of the packet is bom data. 
+    BomNode* bom_node;
+    current_bot->bom_head = bom_node;
+    //i still points to the first bom information spot at 5. 
+    while(i<length){
+      printf("*"); 
+      bom_node = malloc(sizeof(BomNode));
+      bom_node->id = ((short int)((short)packet[i++]<<8) + packet[i++]);
+      if(i>=length){
+        printf("Packet not constructed correctly. Terminate. \n");
+        exit(0);
+      }
+      bom_node->value = packet[i++];
+      if(i>=length){
+        printf("Packet not constructed correctly. Terminate. \n");
+        exit(0);
+      }
+      bom_node = bom_node->next;
+    }
+  }
+}
+
+RobotData* getRobot(int id){
+  RobotData* next = head_bot; 
+  while(next->id != id && next->next!=NULL);
+  
+  if(next->id != id) return NULL;
+  else return next;
+}
+
+void unregister(void){
+  return;
+}
Index: branches/slam/code/projects/slam/computer/computerize_lib.sh
===================================================================
--- branches/slam/code/projects/slam/computer/computerize_lib.sh	(nonexistent)
+++ branches/slam/code/projects/slam/computer/computerize_lib.sh	(revision 121)
@@ -0,0 +1,5 @@
+cd ../../libwireless/lib;
+make clean;
+make computer;
+make publish;
+cd ../../slam/computer;

Property changes on: branches/slam/code/projects/slam/computer/computerize_lib.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/slam/code/projects/slam/computer/slam_analyzer.h
===================================================================
--- branches/slam/code/projects/slam/computer/slam_analyzer.h	(nonexistent)
+++ branches/slam/code/projects/slam/computer/slam_analyzer.h	(revision 121)
@@ -0,0 +1,3 @@
+#include "../slam_defs.h"
+void slam_analyze(RobotData* head);
+void slam_print_data(RobotData* head);
Index: branches/slam/code/projects/slam/computer/Makefile
===================================================================
--- branches/slam/code/projects/slam/computer/Makefile	(nonexistent)
+++ branches/slam/code/projects/slam/computer/Makefile	(revision 121)
@@ -0,0 +1,14 @@
+CC = gcc
+CFLAGS = -Wall -g
+
+all: computer_main
+ifndef COLONYROOT
+COLONYROOT = ../../..
+endif
+
+computer_main: *.c 
+	$(CC) $(CFLAGS) computer_main.c -L$(COLONYROOT)/code/lib/bin -o computer_main -lwireless
+
+clean:
+	rm computer_main
+
