Index: trunk/code/projects/mapping/robot/odometry.h
===================================================================
--- trunk/code/projects/mapping/robot/odometry.h	(revision 1065)
+++ trunk/code/projects/mapping/robot/odometry.h	(nonexistent)
@@ -1 +0,0 @@
-link ../odometry/odometry.h
\ No newline at end of file

Property changes on: trunk/code/projects/mapping/robot/odometry.h
___________________________________________________________________
Deleted: svn:special
## -1 +0,0 ##
-*
\ No newline at end of property
Index: trunk/code/projects/mapping/robot/data_response.c
===================================================================
--- trunk/code/projects/mapping/robot/data_response.c	(revision 1065)
+++ trunk/code/projects/mapping/robot/data_response.c	(nonexistent)
@@ -1,98 +0,0 @@
-#include "dragonfly_lib.h"
-#include "data_response.h"
-#include "wl_token_ring.h"
-#include "wireless.h"
-#include "serial.h"
-
-PacketGroupHandler pgh;
-
-void handle_receive(char type, int source, unsigned char* packet, int length);
-int generate_bom_packet(char** buf);
-int generate_IR_packet(char** buf);
-
-
-/** 
-* @brief The only function that should be called by user code.
-  Prepares the robot to receive and respond to data requests.
-*/
-void data_response_init(void){
-  //usb_init();
-  //usb_puts("USB initialized!\n\r");
-  range_init();
-  pgh.groupCode=DATA_REQUEST_GROUP; 
-  pgh.timeout_handler = NULL;
-  pgh.handle_response = NULL;
-  pgh.handle_receive = handle_receive;
-  pgh.unregister = NULL;
-  wl_register_packet_group(&pgh);
-  //usb_puts("Packet Group Registered!\n\r");
-}
-
-
-void handle_receive(char type, int source, unsigned char* packet, int length){
-  
-  char buf[MAX_PACKET_LENGTH]; 
-  int size;
-  int i=0;
-  short int robot_id, ir_value; 
-  char ranges[] = {IR1,IR2,IR3,IR4,IR5}; 
-  
-  switch(type){
-  case BOM_TYPE:
-    
-    wl_token_iterator_begin();
-    while(wl_token_iterator_has_next() && i<=96){
-      robot_id = wl_token_iterator_next();
-      buf[i++] = (char)((robot_id>>8) & 255);
-      buf[i++] = (char)(robot_id & 255);
-      buf[i++] = (char)(wl_token_get_my_sensor_reading(robot_id));
-    }
-    
-    //i is one greater than the index of the last byte... the size.
-    wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,BOM_TYPE,buf,i,source,0);
-    break;
-  
-  case IR_TYPE:
-
-    for(i=0;i<5;i++){
-      ir_value = (short)range_read_distance(ranges[i]);
-      buf[2*i] = (char)((ir_value>>8)&255);   
-      buf[2*i+1] = (ir_value&255);   
-    }
-    size = 10;
-
-    //usb_puts("Packet Contents: ");
-    /*for(i = 0; i<size;i++){
-        //usb_puti(buf[i]);
-        usb_putc(' ');
-    }*/
-    wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,IR_TYPE,buf,size,source,0);
-  
-    break; 
-  
-  case ENCODER_TYPE:
-    break; 
-    //Not yet supported.
-  
-  case ALL_TYPE:
-    for(i=0;i<5;i++){
-      ir_value = (short)range_read_distance(ranges[i]);
-      buf[2*i] = (char)((ir_value>>8)&255);   
-      buf[2*i+1] = (ir_value&255);   
-    } //Buf 0...9 filled.
-
-    //Tack on the Encoder data... 
-    //Then BOM: 
-    wl_token_iterator_begin();
-    while(wl_token_iterator_has_next() && i<=96){
-      robot_id = wl_token_iterator_next();
-      buf[i++] = (char)((robot_id>>8) & 255);
-      buf[i++] = (char)(robot_id & 255);
-      buf[i++] = (char)(wl_token_get_my_sensor_reading(robot_id));
-    }
-    wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,ALL_TYPE,buf,size,source,0);
-    break;
-  }
-}
-
-
Index: trunk/code/projects/mapping/robot/smart_run_around_fsm.c
===================================================================
--- trunk/code/projects/mapping/robot/smart_run_around_fsm.c	(revision 1065)
+++ trunk/code/projects/mapping/robot/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(ADC_START);
-  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: trunk/code/projects/mapping/robot/robot_main.c
===================================================================
--- trunk/code/projects/mapping/robot/robot_main.c	(revision 1065)
+++ trunk/code/projects/mapping/robot/robot_main.c	(nonexistent)
@@ -1,162 +0,0 @@
-#include <dragonfly_lib.h>
-#include <wireless.h>
-#include <encoders.h>
-#include "odometry.h"
-
-#define CHAN 0xE
-
-#define POLLING_INTERVAL 50    //interval in ms to get sensor data
-#define MAP 1	// packet group for sending data points
-#define POINT_ODO 2
-
-#define WL_CNTL_GROUP 4
-
-#define CNTL_FORWARD 0
-#define CNTL_BACK    1
-#define CNTL_LEFT    2
-#define CNTL_RIGHT   3
-#define CNTL_LEFT_CURVE 4
-#define CNTL_RIGHT_CURVE 5
-#define CNTL_STOP    6
-#define CNTL_VEL_UP  7
-#define CNTL_VEL_DOWN 8
-
-int state;
-int velocity;
-char buf[100];
-
-void packet_receive (char type, int source, unsigned char* packet, int length);
-void set_motion (void);
-
-PacketGroupHandler packetHandler = {WL_CNTL_GROUP, NULL, NULL, &packet_receive, NULL};
-
-int main(void)
-{
-    /* initialize components and join the token ring */
-    dragonfly_init(ALL_ON);
-    odometry_init(); // breaks motors (interrupt-related?)
-    orb_enable();
-    wl_init();
-    wl_set_channel(CHAN);
-    wl_register_packet_group(&packetHandler);
-   
-    // initial control values
-    velocity = 190;
-    state = CNTL_STOP;
-    
-    // use when sending odometry data
-    int x, y;
-    double theta;
-
-    int store[9];
-    char *send;   // for transmission
-
-    while(1)
-    {
-        wl_do();
-        delay_ms(POLLING_INTERVAL);	// until it's time to grab map data
-        x = odometry_dx(); // use when sending odometry data
-        y = odometry_dy();
-        theta = odometry_angle();
-        store[0] = x;
-        store[1] = y;
-        *((double*)(store + 2)) = theta;
-        store[4] = range_read_distance(IR1);	// IR1 range
-        store[5] = range_read_distance(IR2);	// IR2 range
-        store[6] = range_read_distance(IR3);	// IR3 range
-        store[7] = range_read_distance(IR4);	// IR4 range
-        store[8] = range_read_distance(IR5);	// IR5 range
-        sprintf( buf, "%d %d %f %d %d %d %d %d\n", store[0], store[1],
-                 *((double *)(store+2)), store[4], store[5], store[6],
-                 store[7], store[8] );
-        usb_puts(buf);
-
-        send = (char*) store;
-
-        wl_send_global_packet(MAP, POINT_ODO, send, 18, 0);
-    }
-
-    wl_terminate();
-    return 0;
-}
-
-void packet_receive (char type, int source, unsigned char* packet, int length) {
-    sprintf(buf, "received packet: %d\n", type);
-    usb_puts(buf);
-    switch (type) {
-        case CNTL_FORWARD:
-            state = CNTL_FORWARD;
-            break;
-        case CNTL_BACK:
-            state = CNTL_BACK;
-            break;
-        case CNTL_LEFT:
-            state = CNTL_LEFT;
-            break;
-        case CNTL_RIGHT:
-            state = CNTL_RIGHT;
-            break;
-        case CNTL_LEFT_CURVE:
-            state = CNTL_LEFT_CURVE;
-            break;
-        case CNTL_RIGHT_CURVE:
-            state = CNTL_RIGHT_CURVE;
-            break;
-        case CNTL_STOP:
-            state = CNTL_STOP;
-            break;
-        case CNTL_VEL_UP:
-            if (velocity > 250)
-                velocity = 250;
-            else
-                velocity += 5;
-            break;
-        case CNTL_VEL_DOWN:
-            velocity -= 5;
-            if (velocity < 150)
-                velocity = 150;
-            break;
-        default:
-            state = CNTL_STOP;
-            break;
-    }
-    set_motion();
-}
-
-void set_motion (void) {
-    switch (state) {
-        case CNTL_FORWARD:
-            orb_set_color(GREEN);
-            move(velocity, 0);
-            break;
-        case CNTL_BACK:
-            orb_set_color(BLUE);
-            move(-velocity, 0);
-            break;
-        case CNTL_LEFT:
-            orb_set_color(ORANGE);
-            motor1_set(0, velocity);
-            motor2_set(1, velocity);
-            break;
-        case CNTL_RIGHT:
-            orb_set_color(YELLOW);
-            motor1_set(1, velocity);
-            motor2_set(0, velocity);
-            break;
-        case CNTL_LEFT_CURVE:
-            orb_set_color(MAGENTA);
-            motor1_set(1, 150);
-            motor2_set(1, velocity);
-            break;
-        case CNTL_RIGHT_CURVE:
-            orb_set_color(CYAN);
-            motor1_set(1, velocity);
-            motor2_set(1, 150);
-            break;
-        case CNTL_STOP:
-            orb_set_color(RED);
-            move(0, 0);
-            break;
-    }
-}
-
Index: trunk/code/projects/mapping/robot/robotize_lib.sh
===================================================================
--- trunk/code/projects/mapping/robot/robotize_lib.sh	(revision 1065)
+++ trunk/code/projects/mapping/robot/robotize_lib.sh	(nonexistent)
@@ -1,5 +0,0 @@
-cd ../../libwireless/lib;
-make clean;
-make all;
-make publish;
-cd ../../slam/computer;
Index: trunk/code/projects/mapping/robot/multi_robot_behavior.txt
===================================================================
--- trunk/code/projects/mapping/robot/multi_robot_behavior.txt	(revision 1065)
+++ trunk/code/projects/mapping/robot/multi_robot_behavior.txt	(nonexistent)
@@ -1,58 +0,0 @@
-/**
-
-Optimal Behavior for Mapping
-
-Desired Properties
-- Overlapping maps
-- Shared origin
- * robots must know where they are in relation to each other
-
-
-
-Actual Behavior
-- make BOM contact with another robot
- * estimated distance reading would help
-- try to follow another robot
- * could parallel path but moved over slightly 
-   to give a wider view while also corroborating data
- * then treat as leader/follower in actions
- * get groups to link up with each other and then separate to 
-   establish meeting point between maps
-  
-  
-  
-  
-  
-Thoughts on improving overall efficiency
-----------------------------------------
-Robot:
-- use a shorter polling interval for rangefinders, 
-  then average readings between wireless polling intervals
-- if the rangefinder value = MAX, then mark it as -1
-  so the program doesn't draw that point
-- try bursts of data every second or farther apart
-  containing multiple data points
- * this reduces stress on wireless timing and allows for 
-   overhead created by token ring
-- one solution to the 'master origin' problem for multiple robots
-  is to start each robot at the same point with the same orientation
- * this isn't very useful and takes effort, but it works
- * could also establish an initial offset in robots,
-   but accurate initial placement would still be an issue
-  
-Server:
-- if the rangefinder value = MAX or -1, don't use that point
-  or set it to infinity
-- if robots have linked as leader/follower pair, use
-  one point of origin for both robots
-- when two or more robots meet, set one robot as the 
-  master coordinates, and modify all other robots to use
-  those master coordinates
- * easiest is to start a new map with one robot at the origin and
-   all others starting based off that robot
- * backdating the coordinate change would be better
- * using both approaches is likely most accurate
-
-
-  
-*/
\ No newline at end of file
Index: trunk/code/projects/mapping/robot/data_response.h
===================================================================
--- trunk/code/projects/mapping/robot/data_response.h	(revision 1065)
+++ trunk/code/projects/mapping/robot/data_response.h	(nonexistent)
@@ -1,16 +0,0 @@
-#ifndef _DATA_RESPONSE_H
-#define _DATA_REQUESTS_H
-
-#define DATA_REQUEST_GROUP 7
-#define BOM_TYPE 0
-#define IR_TYPE 1
-#define ENCODER_TYPE 2
-#define ALL_TYPE 3
-
-#define MAX_PACKET_LENGTH 100
-
-/* This requires the wireless library
-and the token ring to already be initialized.*/
-void data_response_init(void);
-
-#endif
Index: trunk/code/projects/mapping/robot/smart_run_around_fsm.h
===================================================================
--- trunk/code/projects/mapping/robot/smart_run_around_fsm.h	(revision 1065)
+++ trunk/code/projects/mapping/robot/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: trunk/code/projects/mapping/robot/Makefile
===================================================================
--- trunk/code/projects/mapping/robot/Makefile	(revision 1065)
+++ trunk/code/projects/mapping/robot/Makefile	(nonexistent)
@@ -1,520 +0,0 @@
-########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/ttyUSB0
-#
-#
-###################################
-
-# 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: trunk/code/projects/mapping/robot/odometry.c
===================================================================
--- trunk/code/projects/mapping/robot/odometry.c	(revision 1065)
+++ trunk/code/projects/mapping/robot/odometry.c	(nonexistent)
@@ -1 +0,0 @@
-link ../odometry/odometry.c
\ No newline at end of file

Property changes on: trunk/code/projects/mapping/robot/odometry.c
___________________________________________________________________
Deleted: svn:special
## -1 +0,0 ##
-*
\ No newline at end of property
Index: trunk/code/projects/mapping/auto/robot_main.c
===================================================================
--- trunk/code/projects/mapping/auto/robot_main.c	(nonexistent)
+++ trunk/code/projects/mapping/auto/robot_main.c	(revision 1066)
@@ -0,0 +1,158 @@
+#include <dragonfly_lib.h>
+#include <wireless.h>
+#include <encoders.h>
+#include "odometry.h"
+
+#define POLLING_INTERVAL 50    //interval in ms to get sensor data
+#define MAP 1	// packet group for sending data points
+#define POINT_ODO 2
+
+#define WL_CNTL_GROUP 4
+
+#define CNTL_FORWARD 0
+#define CNTL_BACK    1
+#define CNTL_LEFT    2
+#define CNTL_RIGHT   3
+#define CNTL_LEFT_CURVE 4
+#define CNTL_RIGHT_CURVE 5
+#define CNTL_STOP    6
+#define CNTL_VEL_UP  7
+#define CNTL_VEL_DOWN 8
+
+int state;
+int velocity;
+char buf[100];
+
+void packet_receive (char type, int source, unsigned char* packet, int length);
+void set_motion (void);
+
+PacketGroupHandler packetHandler = {WL_CNTL_GROUP, NULL, NULL, &packet_receive, NULL};
+
+int main(void)
+{
+    /* initialize components and join the token ring */
+    dragonfly_init(ALL_ON);
+    odometry_init();
+    orb_enable();
+    wl_init();
+    wl_set_channel(0xE);
+    wl_register_packet_group(&packetHandler);
+    
+    velocity = 190;
+    state = CNTL_STOP;
+
+    int x, y; // use when sending odometry data
+    double theta;
+
+    int store[9];
+    char *send;   // for transmission
+
+    while(1)
+    {
+	wl_do();
+	delay_ms(POLLING_INTERVAL);	/* until it's time to grab map data */
+	x = odometry_dx(); // use when sending odometry data
+	y = odometry_dy();
+	theta = odometry_angle();
+	store[0] = x;
+	store[1] = y;
+	*((double*)(store + 2)) = theta;
+	store[4] = range_read_distance(IR1);	// IR1 range
+	store[5] = range_read_distance(IR2);	// IR2 range
+	store[6] = range_read_distance(IR3);	// IR3 range
+	store[7] = range_read_distance(IR4);	// IR4 range
+	store[8] = range_read_distance(IR5);	// IR5 range
+	sprintf( buf, "%d %d %f %d %d %d %d %d\n", store[0], store[1],
+	    *((double *)(store+2)), store[4], store[5], store[6],
+	    store[7], store[8] );
+	usb_puts(buf);
+
+	send = (char*) store;
+
+	wl_send_global_packet(MAP, POINT_ODO, send, 18, 0);
+    }
+
+    wl_terminate();
+    return 0;
+}
+
+void packet_receive (char type, int source, unsigned char* packet, int length) {
+    sprintf(buf, "received packet: %d\n", type);
+    usb_puts(buf);
+    switch (type) {
+        case CNTL_FORWARD:
+            state = CNTL_FORWARD;
+            break;
+        case CNTL_BACK:
+            state = CNTL_BACK;
+            break;
+        case CNTL_LEFT:
+            state = CNTL_LEFT;
+            break;
+        case CNTL_RIGHT:
+            state = CNTL_RIGHT;
+            break;
+        case CNTL_LEFT_CURVE:
+            state = CNTL_LEFT_CURVE;
+            break;
+        case CNTL_RIGHT_CURVE:
+            state = CNTL_RIGHT_CURVE;
+            break;
+        case CNTL_STOP:
+            state = CNTL_STOP;
+            break;
+        case CNTL_VEL_UP:
+            if (velocity > 250)
+                velocity = 250;
+            else
+                velocity += 5;
+            break;
+        case CNTL_VEL_DOWN:
+            velocity -= 5;
+            if (velocity < 150)
+                velocity = 150;
+            break;
+        default:
+            state = CNTL_STOP;
+            break;
+    }
+    set_motion();
+}
+
+void set_motion (void) {
+    switch (state) {
+        case CNTL_FORWARD:
+            orb_set_color(GREEN);
+            move(velocity, 0);
+            break;
+        case CNTL_BACK:
+            orb_set_color(BLUE);
+            move(-velocity, 0);
+            break;
+        case CNTL_LEFT:
+            orb_set_color(ORANGE);
+            motor1_set(0, velocity);
+            motor2_set(1, velocity);
+            break;
+        case CNTL_RIGHT:
+            orb_set_color(YELLOW);
+            motor1_set(1, velocity);
+            motor2_set(0, velocity);
+            break;
+        case CNTL_LEFT_CURVE:
+            orb_set_color(MAGENTA);
+            motor1_set(1, 150);
+            motor2_set(1, velocity);
+            break;
+        case CNTL_RIGHT_CURVE:
+            orb_set_color(CYAN);
+            motor1_set(1, velocity);
+            motor2_set(1, 150);
+            break;
+        case CNTL_STOP:
+            orb_set_color(RED);
+            move(0, 0);
+            break;
+    }
+}
+
Index: trunk/code/projects/mapping/auto/odometry.c
===================================================================
--- trunk/code/projects/mapping/auto/odometry.c	(nonexistent)
+++ trunk/code/projects/mapping/auto/odometry.c	(revision 1066)
@@ -0,0 +1 @@
+link ../odometry/odometry.c
\ No newline at end of file

Property changes on: trunk/code/projects/mapping/auto/odometry.c
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/code/projects/mapping/auto/odometry.h
===================================================================
--- trunk/code/projects/mapping/auto/odometry.h	(nonexistent)
+++ trunk/code/projects/mapping/auto/odometry.h	(revision 1066)
@@ -0,0 +1 @@
+link ../odometry/odometry.h
\ No newline at end of file

Property changes on: trunk/code/projects/mapping/auto/odometry.h
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/code/projects/mapping/auto/multi_robot_behavior.txt
===================================================================
--- trunk/code/projects/mapping/auto/multi_robot_behavior.txt	(nonexistent)
+++ trunk/code/projects/mapping/auto/multi_robot_behavior.txt	(revision 1066)
@@ -0,0 +1,58 @@
+/**
+
+Optimal Behavior for Mapping
+
+Desired Properties
+- Overlapping maps
+- Shared origin
+ * robots must know where they are in relation to each other
+
+
+
+Actual Behavior
+- make BOM contact with another robot
+ * estimated distance reading would help
+- try to follow another robot
+ * could parallel path but moved over slightly 
+   to give a wider view while also corroborating data
+ * then treat as leader/follower in actions
+ * get groups to link up with each other and then separate to 
+   establish meeting point between maps
+  
+  
+  
+  
+  
+Thoughts on improving overall efficiency
+----------------------------------------
+Robot:
+- use a shorter polling interval for rangefinders, 
+  then average readings between wireless polling intervals
+- if the rangefinder value = MAX, then mark it as -1
+  so the program doesn't draw that point
+- try bursts of data every second or farther apart
+  containing multiple data points
+ * this reduces stress on wireless timing and allows for 
+   overhead created by token ring
+- one solution to the 'master origin' problem for multiple robots
+  is to start each robot at the same point with the same orientation
+ * this isn't very useful and takes effort, but it works
+ * could also establish an initial offset in robots,
+   but accurate initial placement would still be an issue
+  
+Server:
+- if the rangefinder value = MAX or -1, don't use that point
+  or set it to infinity
+- if robots have linked as leader/follower pair, use
+  one point of origin for both robots
+- when two or more robots meet, set one robot as the 
+  master coordinates, and modify all other robots to use
+  those master coordinates
+ * easiest is to start a new map with one robot at the origin and
+   all others starting based off that robot
+ * backdating the coordinate change would be better
+ * using both approaches is likely most accurate
+
+
+  
+*/
\ No newline at end of file
Index: trunk/code/projects/mapping/auto/Makefile
===================================================================
--- trunk/code/projects/mapping/auto/Makefile	(nonexistent)
+++ trunk/code/projects/mapping/auto/Makefile	(revision 1066)
@@ -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/ttyUSB0
+#
+#
+###################################
+
+# 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: trunk/code/projects/mapping/auto/smart_run_around_fsm.c
===================================================================
--- trunk/code/projects/mapping/auto/smart_run_around_fsm.c	(nonexistent)
+++ trunk/code/projects/mapping/auto/smart_run_around_fsm.c	(revision 1066)
@@ -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(ADC_START);
+  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: trunk/code/projects/mapping/auto/data_response.c
===================================================================
--- trunk/code/projects/mapping/auto/data_response.c	(nonexistent)
+++ trunk/code/projects/mapping/auto/data_response.c	(revision 1066)
@@ -0,0 +1,98 @@
+#include "dragonfly_lib.h"
+#include "data_response.h"
+#include "wl_token_ring.h"
+#include "wireless.h"
+#include "serial.h"
+
+PacketGroupHandler pgh;
+
+void handle_receive(char type, int source, unsigned char* packet, int length);
+int generate_bom_packet(char** buf);
+int generate_IR_packet(char** buf);
+
+
+/** 
+* @brief The only function that should be called by user code.
+  Prepares the robot to receive and respond to data requests.
+*/
+void data_response_init(void){
+  //usb_init();
+  //usb_puts("USB initialized!\n\r");
+  range_init();
+  pgh.groupCode=DATA_REQUEST_GROUP; 
+  pgh.timeout_handler = NULL;
+  pgh.handle_response = NULL;
+  pgh.handle_receive = handle_receive;
+  pgh.unregister = NULL;
+  wl_register_packet_group(&pgh);
+  //usb_puts("Packet Group Registered!\n\r");
+}
+
+
+void handle_receive(char type, int source, unsigned char* packet, int length){
+  
+  char buf[MAX_PACKET_LENGTH]; 
+  int size;
+  int i=0;
+  short int robot_id, ir_value; 
+  char ranges[] = {IR1,IR2,IR3,IR4,IR5}; 
+  
+  switch(type){
+  case BOM_TYPE:
+    
+    wl_token_iterator_begin();
+    while(wl_token_iterator_has_next() && i<=96){
+      robot_id = wl_token_iterator_next();
+      buf[i++] = (char)((robot_id>>8) & 255);
+      buf[i++] = (char)(robot_id & 255);
+      buf[i++] = (char)(wl_token_get_my_sensor_reading(robot_id));
+    }
+    
+    //i is one greater than the index of the last byte... the size.
+    wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,BOM_TYPE,buf,i,source,0);
+    break;
+  
+  case IR_TYPE:
+
+    for(i=0;i<5;i++){
+      ir_value = (short)range_read_distance(ranges[i]);
+      buf[2*i] = (char)((ir_value>>8)&255);   
+      buf[2*i+1] = (ir_value&255);   
+    }
+    size = 10;
+
+    //usb_puts("Packet Contents: ");
+    /*for(i = 0; i<size;i++){
+        //usb_puti(buf[i]);
+        usb_putc(' ');
+    }*/
+    wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,IR_TYPE,buf,size,source,0);
+  
+    break; 
+  
+  case ENCODER_TYPE:
+    break; 
+    //Not yet supported.
+  
+  case ALL_TYPE:
+    for(i=0;i<5;i++){
+      ir_value = (short)range_read_distance(ranges[i]);
+      buf[2*i] = (char)((ir_value>>8)&255);   
+      buf[2*i+1] = (ir_value&255);   
+    } //Buf 0...9 filled.
+
+    //Tack on the Encoder data... 
+    //Then BOM: 
+    wl_token_iterator_begin();
+    while(wl_token_iterator_has_next() && i<=96){
+      robot_id = wl_token_iterator_next();
+      buf[i++] = (char)((robot_id>>8) & 255);
+      buf[i++] = (char)(robot_id & 255);
+      buf[i++] = (char)(wl_token_get_my_sensor_reading(robot_id));
+    }
+    wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,ALL_TYPE,buf,size,source,0);
+    break;
+  }
+}
+
+
Index: trunk/code/projects/mapping/auto/data_response.h
===================================================================
--- trunk/code/projects/mapping/auto/data_response.h	(nonexistent)
+++ trunk/code/projects/mapping/auto/data_response.h	(revision 1066)
@@ -0,0 +1,16 @@
+#ifndef _DATA_RESPONSE_H
+#define _DATA_REQUESTS_H
+
+#define DATA_REQUEST_GROUP 7
+#define BOM_TYPE 0
+#define IR_TYPE 1
+#define ENCODER_TYPE 2
+#define ALL_TYPE 3
+
+#define MAX_PACKET_LENGTH 100
+
+/* This requires the wireless library
+and the token ring to already be initialized.*/
+void data_response_init(void);
+
+#endif
Index: trunk/code/projects/mapping/auto/robotize_lib.sh
===================================================================
--- trunk/code/projects/mapping/auto/robotize_lib.sh	(nonexistent)
+++ trunk/code/projects/mapping/auto/robotize_lib.sh	(revision 1066)
@@ -0,0 +1,5 @@
+cd ../../libwireless/lib;
+make clean;
+make all;
+make publish;
+cd ../../slam/computer;
Index: trunk/code/projects/mapping/auto/smart_run_around_fsm.h
===================================================================
--- trunk/code/projects/mapping/auto/smart_run_around_fsm.h	(nonexistent)
+++ trunk/code/projects/mapping/auto/smart_run_around_fsm.h	(revision 1066)
@@ -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: trunk/code/projects/mapping/auto
===================================================================
--- trunk/code/projects/mapping/auto	(nonexistent)
+++ trunk/code/projects/mapping/auto	(revision 1066)

Property changes on: trunk/code/projects/mapping/auto
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/mapping/drive/robot_main.c
===================================================================
--- trunk/code/projects/mapping/drive/robot_main.c	(nonexistent)
+++ trunk/code/projects/mapping/drive/robot_main.c	(revision 1066)
@@ -0,0 +1,158 @@
+#include <dragonfly_lib.h>
+#include <wireless.h>
+#include <encoders.h>
+#include "odometry.h"
+
+#define POLLING_INTERVAL 50    //interval in ms to get sensor data
+#define MAP 1	// packet group for sending data points
+#define POINT_ODO 2
+
+#define WL_CNTL_GROUP 4
+
+#define CNTL_FORWARD 0
+#define CNTL_BACK    1
+#define CNTL_LEFT    2
+#define CNTL_RIGHT   3
+#define CNTL_LEFT_CURVE 4
+#define CNTL_RIGHT_CURVE 5
+#define CNTL_STOP    6
+#define CNTL_VEL_UP  7
+#define CNTL_VEL_DOWN 8
+
+int state;
+int velocity;
+char buf[100];
+
+void packet_receive (char type, int source, unsigned char* packet, int length);
+void set_motion (void);
+
+PacketGroupHandler packetHandler = {WL_CNTL_GROUP, NULL, NULL, &packet_receive, NULL};
+
+int main(void)
+{
+    /* initialize components and join the token ring */
+    dragonfly_init(ALL_ON);
+    odometry_init();
+    orb_enable();
+    wl_init();
+    wl_set_channel(0xE);
+    wl_register_packet_group(&packetHandler);
+    
+    velocity = 190;
+    state = CNTL_STOP;
+
+    int x, y; // use when sending odometry data
+    double theta;
+
+    int store[9];
+    char *send;   // for transmission
+
+    while(1)
+    {
+	wl_do();
+	delay_ms(POLLING_INTERVAL);	/* until it's time to grab map data */
+	x = odometry_dx(); // use when sending odometry data
+	y = odometry_dy();
+	theta = odometry_angle();
+	store[0] = x;
+	store[1] = y;
+	*((double*)(store + 2)) = theta;
+	store[4] = range_read_distance(IR1);	// IR1 range
+	store[5] = range_read_distance(IR2);	// IR2 range
+	store[6] = range_read_distance(IR3);	// IR3 range
+	store[7] = range_read_distance(IR4);	// IR4 range
+	store[8] = range_read_distance(IR5);	// IR5 range
+	sprintf( buf, "%d %d %f %d %d %d %d %d\n", store[0], store[1],
+	    *((double *)(store+2)), store[4], store[5], store[6],
+	    store[7], store[8] );
+	usb_puts(buf);
+
+	send = (char*) store;
+
+	wl_send_global_packet(MAP, POINT_ODO, send, 18, 0);
+    }
+
+    wl_terminate();
+    return 0;
+}
+
+void packet_receive (char type, int source, unsigned char* packet, int length) {
+    sprintf(buf, "received packet: %d\n", type);
+    usb_puts(buf);
+    switch (type) {
+        case CNTL_FORWARD:
+            state = CNTL_FORWARD;
+            break;
+        case CNTL_BACK:
+            state = CNTL_BACK;
+            break;
+        case CNTL_LEFT:
+            state = CNTL_LEFT;
+            break;
+        case CNTL_RIGHT:
+            state = CNTL_RIGHT;
+            break;
+        case CNTL_LEFT_CURVE:
+            state = CNTL_LEFT_CURVE;
+            break;
+        case CNTL_RIGHT_CURVE:
+            state = CNTL_RIGHT_CURVE;
+            break;
+        case CNTL_STOP:
+            state = CNTL_STOP;
+            break;
+        case CNTL_VEL_UP:
+            if (velocity > 250)
+                velocity = 250;
+            else
+                velocity += 5;
+            break;
+        case CNTL_VEL_DOWN:
+            velocity -= 5;
+            if (velocity < 150)
+                velocity = 150;
+            break;
+        default:
+            state = CNTL_STOP;
+            break;
+    }
+    set_motion();
+}
+
+void set_motion (void) {
+    switch (state) {
+        case CNTL_FORWARD:
+            orb_set_color(GREEN);
+            move(velocity, 0);
+            break;
+        case CNTL_BACK:
+            orb_set_color(BLUE);
+            move(-velocity, 0);
+            break;
+        case CNTL_LEFT:
+            orb_set_color(ORANGE);
+            motor1_set(0, velocity);
+            motor2_set(1, velocity);
+            break;
+        case CNTL_RIGHT:
+            orb_set_color(YELLOW);
+            motor1_set(1, velocity);
+            motor2_set(0, velocity);
+            break;
+        case CNTL_LEFT_CURVE:
+            orb_set_color(MAGENTA);
+            motor1_set(1, 150);
+            motor2_set(1, velocity);
+            break;
+        case CNTL_RIGHT_CURVE:
+            orb_set_color(CYAN);
+            motor1_set(1, velocity);
+            motor2_set(1, 150);
+            break;
+        case CNTL_STOP:
+            orb_set_color(RED);
+            move(0, 0);
+            break;
+    }
+}
+
Index: trunk/code/projects/mapping/drive/odometry.c
===================================================================
--- trunk/code/projects/mapping/drive/odometry.c	(nonexistent)
+++ trunk/code/projects/mapping/drive/odometry.c	(revision 1066)
@@ -0,0 +1 @@
+link ../odometry/odometry.c
\ No newline at end of file

Property changes on: trunk/code/projects/mapping/drive/odometry.c
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/code/projects/mapping/drive/odometry.h
===================================================================
--- trunk/code/projects/mapping/drive/odometry.h	(nonexistent)
+++ trunk/code/projects/mapping/drive/odometry.h	(revision 1066)
@@ -0,0 +1 @@
+link ../odometry/odometry.h
\ No newline at end of file

Property changes on: trunk/code/projects/mapping/drive/odometry.h
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/code/projects/mapping/drive/multi_robot_behavior.txt
===================================================================
--- trunk/code/projects/mapping/drive/multi_robot_behavior.txt	(nonexistent)
+++ trunk/code/projects/mapping/drive/multi_robot_behavior.txt	(revision 1066)
@@ -0,0 +1,58 @@
+/**
+
+Optimal Behavior for Mapping
+
+Desired Properties
+- Overlapping maps
+- Shared origin
+ * robots must know where they are in relation to each other
+
+
+
+Actual Behavior
+- make BOM contact with another robot
+ * estimated distance reading would help
+- try to follow another robot
+ * could parallel path but moved over slightly 
+   to give a wider view while also corroborating data
+ * then treat as leader/follower in actions
+ * get groups to link up with each other and then separate to 
+   establish meeting point between maps
+  
+  
+  
+  
+  
+Thoughts on improving overall efficiency
+----------------------------------------
+Robot:
+- use a shorter polling interval for rangefinders, 
+  then average readings between wireless polling intervals
+- if the rangefinder value = MAX, then mark it as -1
+  so the program doesn't draw that point
+- try bursts of data every second or farther apart
+  containing multiple data points
+ * this reduces stress on wireless timing and allows for 
+   overhead created by token ring
+- one solution to the 'master origin' problem for multiple robots
+  is to start each robot at the same point with the same orientation
+ * this isn't very useful and takes effort, but it works
+ * could also establish an initial offset in robots,
+   but accurate initial placement would still be an issue
+  
+Server:
+- if the rangefinder value = MAX or -1, don't use that point
+  or set it to infinity
+- if robots have linked as leader/follower pair, use
+  one point of origin for both robots
+- when two or more robots meet, set one robot as the 
+  master coordinates, and modify all other robots to use
+  those master coordinates
+ * easiest is to start a new map with one robot at the origin and
+   all others starting based off that robot
+ * backdating the coordinate change would be better
+ * using both approaches is likely most accurate
+
+
+  
+*/
\ No newline at end of file
Index: trunk/code/projects/mapping/drive/Makefile
===================================================================
--- trunk/code/projects/mapping/drive/Makefile	(nonexistent)
+++ trunk/code/projects/mapping/drive/Makefile	(revision 1066)
@@ -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/ttyUSB0
+#
+#
+###################################
+
+# 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: trunk/code/projects/mapping/drive/smart_run_around_fsm.c
===================================================================
--- trunk/code/projects/mapping/drive/smart_run_around_fsm.c	(nonexistent)
+++ trunk/code/projects/mapping/drive/smart_run_around_fsm.c	(revision 1066)
@@ -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(ADC_START);
+  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: trunk/code/projects/mapping/drive/data_response.c
===================================================================
--- trunk/code/projects/mapping/drive/data_response.c	(nonexistent)
+++ trunk/code/projects/mapping/drive/data_response.c	(revision 1066)
@@ -0,0 +1,98 @@
+#include "dragonfly_lib.h"
+#include "data_response.h"
+#include "wl_token_ring.h"
+#include "wireless.h"
+#include "serial.h"
+
+PacketGroupHandler pgh;
+
+void handle_receive(char type, int source, unsigned char* packet, int length);
+int generate_bom_packet(char** buf);
+int generate_IR_packet(char** buf);
+
+
+/** 
+* @brief The only function that should be called by user code.
+  Prepares the robot to receive and respond to data requests.
+*/
+void data_response_init(void){
+  //usb_init();
+  //usb_puts("USB initialized!\n\r");
+  range_init();
+  pgh.groupCode=DATA_REQUEST_GROUP; 
+  pgh.timeout_handler = NULL;
+  pgh.handle_response = NULL;
+  pgh.handle_receive = handle_receive;
+  pgh.unregister = NULL;
+  wl_register_packet_group(&pgh);
+  //usb_puts("Packet Group Registered!\n\r");
+}
+
+
+void handle_receive(char type, int source, unsigned char* packet, int length){
+  
+  char buf[MAX_PACKET_LENGTH]; 
+  int size;
+  int i=0;
+  short int robot_id, ir_value; 
+  char ranges[] = {IR1,IR2,IR3,IR4,IR5}; 
+  
+  switch(type){
+  case BOM_TYPE:
+    
+    wl_token_iterator_begin();
+    while(wl_token_iterator_has_next() && i<=96){
+      robot_id = wl_token_iterator_next();
+      buf[i++] = (char)((robot_id>>8) & 255);
+      buf[i++] = (char)(robot_id & 255);
+      buf[i++] = (char)(wl_token_get_my_sensor_reading(robot_id));
+    }
+    
+    //i is one greater than the index of the last byte... the size.
+    wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,BOM_TYPE,buf,i,source,0);
+    break;
+  
+  case IR_TYPE:
+
+    for(i=0;i<5;i++){
+      ir_value = (short)range_read_distance(ranges[i]);
+      buf[2*i] = (char)((ir_value>>8)&255);   
+      buf[2*i+1] = (ir_value&255);   
+    }
+    size = 10;
+
+    //usb_puts("Packet Contents: ");
+    /*for(i = 0; i<size;i++){
+        //usb_puti(buf[i]);
+        usb_putc(' ');
+    }*/
+    wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,IR_TYPE,buf,size,source,0);
+  
+    break; 
+  
+  case ENCODER_TYPE:
+    break; 
+    //Not yet supported.
+  
+  case ALL_TYPE:
+    for(i=0;i<5;i++){
+      ir_value = (short)range_read_distance(ranges[i]);
+      buf[2*i] = (char)((ir_value>>8)&255);   
+      buf[2*i+1] = (ir_value&255);   
+    } //Buf 0...9 filled.
+
+    //Tack on the Encoder data... 
+    //Then BOM: 
+    wl_token_iterator_begin();
+    while(wl_token_iterator_has_next() && i<=96){
+      robot_id = wl_token_iterator_next();
+      buf[i++] = (char)((robot_id>>8) & 255);
+      buf[i++] = (char)(robot_id & 255);
+      buf[i++] = (char)(wl_token_get_my_sensor_reading(robot_id));
+    }
+    wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,ALL_TYPE,buf,size,source,0);
+    break;
+  }
+}
+
+
Index: trunk/code/projects/mapping/drive/data_response.h
===================================================================
--- trunk/code/projects/mapping/drive/data_response.h	(nonexistent)
+++ trunk/code/projects/mapping/drive/data_response.h	(revision 1066)
@@ -0,0 +1,16 @@
+#ifndef _DATA_RESPONSE_H
+#define _DATA_REQUESTS_H
+
+#define DATA_REQUEST_GROUP 7
+#define BOM_TYPE 0
+#define IR_TYPE 1
+#define ENCODER_TYPE 2
+#define ALL_TYPE 3
+
+#define MAX_PACKET_LENGTH 100
+
+/* This requires the wireless library
+and the token ring to already be initialized.*/
+void data_response_init(void);
+
+#endif
Index: trunk/code/projects/mapping/drive/robotize_lib.sh
===================================================================
--- trunk/code/projects/mapping/drive/robotize_lib.sh	(nonexistent)
+++ trunk/code/projects/mapping/drive/robotize_lib.sh	(revision 1066)
@@ -0,0 +1,5 @@
+cd ../../libwireless/lib;
+make clean;
+make all;
+make publish;
+cd ../../slam/computer;
Index: trunk/code/projects/mapping/drive/smart_run_around_fsm.h
===================================================================
--- trunk/code/projects/mapping/drive/smart_run_around_fsm.h	(nonexistent)
+++ trunk/code/projects/mapping/drive/smart_run_around_fsm.h	(revision 1066)
@@ -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: trunk/code/projects/mapping/drive
===================================================================
--- trunk/code/projects/mapping/drive	(nonexistent)
+++ trunk/code/projects/mapping/drive	(revision 1066)

Property changes on: trunk/code/projects/mapping/drive
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
