<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://hades.mech.northwestern.edu//api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jonathan+Lee</id>
	<title>Mech - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://hades.mech.northwestern.edu//api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jonathan+Lee"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php/Special:Contributions/Jonathan_Lee"/>
	<updated>2026-05-22T01:30:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14472</id>
		<title>RGB Swarm Robot Project E-puck Code (outdated)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14472"/>
		<updated>2009-09-11T20:01:51Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* #define ADDITIONAL_NUMS 8 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the e-puck code for the RGB Sensing Swarm Robotics project. The code on the e-puck was written in C and compiled using Microchip&#039;s MPLAB C Compiler for dsPIC DSCs (student version). &lt;br /&gt;
&lt;br /&gt;
This code is a branch of the [[Swarm Project E-puck Code]].&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===Complete===&lt;br /&gt;
* Got ADC working for color sensor&lt;br /&gt;
** Set up filtering to address projector PWM&lt;br /&gt;
* Restructured code to make more modular.&lt;br /&gt;
** Split dsPIC_XBeePackets and wheel_speed_coordinator into h and c files&lt;br /&gt;
** Pulled packet assembling code out of main and created send_packet() function in send_packet.h/c.&lt;br /&gt;
** Pulled a bunch of variables and defines (&#039;&#039;NUM_DATA_SETS, NUMBERS_PER_SET, DATATYPE_BYTELENGTH , DATA_ARRAY_LENGTH , ADDITIONAL_NUMS, notRTS, T1_INT_FLAG, x_i, u_i, w_i, x_sum, w_sum, MAX_WHEEL_V_TICKS, deadband, COMMR, SAFEDIST, MINDIST, u_x_ideal, u_y_ideal, x_motion_integral, y_motion_integral, SQUARE&#039;&#039;) that were scattered across h files into global_vars.h/c. Makes it easy to include them in a particular file with the &#039;&#039;extern&#039;&#039; keyword.&lt;br /&gt;
* Added color_cal() function in color_cal.h/c&lt;br /&gt;
* Added wheelSpeedSingleBot to wheel_speed_coordinator&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
* Finish color calibration (color_cal) program, to facilitate simple calibration for each e-puck that does not require large amount of data collected for each run, and with minimal user input/control (desire automation and simplification)&lt;br /&gt;
* Improve the vision system position information updater&lt;br /&gt;
** So that the e-puck does not automatically assume every packet from the Vision System is true, rather &#039;checks&#039; for accuracy&lt;br /&gt;
* Replace wheelSpeedSingleBot with the three step move controller from NUtest.c&lt;br /&gt;
**Implement this so that the e-puck can be moved with position and orientation (this is ideal so that data from every orientation of the e-puck can be recorded while calibrating or collecting data&lt;br /&gt;
* Implement new algorithm from paper&lt;br /&gt;
&lt;br /&gt;
==Project Package==&lt;br /&gt;
The source code for the project is available here:&lt;br /&gt;
*[[Media:RGB_Swarm_Puck_Code_working_version.zip|&#039;&#039;&#039;RGB Swarm Puck Code working version.zip&#039;&#039;&#039;]]&lt;br /&gt;
**Open swarm_epucks.mcw and you should be good to go.&lt;br /&gt;
&lt;br /&gt;
==Description of the files and functions==&lt;br /&gt;
&lt;br /&gt;
===global_vars(.c/.h)===&lt;br /&gt;
* .c/.h: declare and define global variables and macros&lt;br /&gt;
====Packet Length Constants====&lt;br /&gt;
These variables determine the length of the XBee packets.  See [[Swarm_Robot_Project_Documentation#Data_Frame|Data Frame]] and the section on XBee API packets in the XBee manual for further clarification.&lt;br /&gt;
&lt;br /&gt;
Much of this is still sending integral consensus estimator data. This can be removed or replaces with data needed for decentralized color sensing. &lt;br /&gt;
&lt;br /&gt;
=====#define NUM_DATA_SETS 5 =====	&lt;br /&gt;
Number of statistics on which you are running the consensus estimator.  This this particular case, 5. (Ix, Iy, Ixx, Ixy, Iyy)&lt;br /&gt;
&lt;br /&gt;
=====#define NUMBERS_PER_SET 2=====&lt;br /&gt;
Number of variables in each data set (see above) that the consensus estimator needs to transmit to other agents.  In this case, 2 because there is &amp;lt;tt&amp;gt;x_i&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;w_i&amp;lt;/tt&amp;gt; for each statistic.&lt;br /&gt;
&lt;br /&gt;
=====#define DATATYPE_BYTELENGTH 4	=====&lt;br /&gt;
Number of bytes in the data type (used in the consensus estimator (float = 4 bytes long).  This is important because we need to split the numbers into individual bytes to be able to send them out the serial port.&lt;br /&gt;
&lt;br /&gt;
=====#define DATA_ARRAY_LENGTH (NUM_DATA_SETS*NUMBERS_PER_SET)=====&lt;br /&gt;
Total number of data variables needed for the consensus estimator.  In this case, it is 5*2=10.&lt;br /&gt;
&lt;br /&gt;
=====#define ADDITIONAL_NUMS 8=====&lt;br /&gt;
Additional number of data to be appended to data array.  It is 5 in this case, so that we can append &lt;br /&gt;
# Robot X coordinate&lt;br /&gt;
# Robot Y coordinate&lt;br /&gt;
# Robot Theta orientation&lt;br /&gt;
# Robot left wheel speed&lt;br /&gt;
# Robot right wheel speed&lt;br /&gt;
# &#039;&#039;Sensor Red Value&#039;&#039;&lt;br /&gt;
# &#039;&#039;Sensor Green Value&#039;&#039;&lt;br /&gt;
# &#039;&#039;Sensor Blue Value&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===main(.c/.h)===&lt;br /&gt;
* .c: This contains the entry point of the code and contains the initialization routines, main loop, and interrupt service routines. &lt;br /&gt;
* .h: Contains variables, function prototypes, and delay function needed for main.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _T1Interrupt(void)=====&lt;br /&gt;
Timer1 ISR. Sets T1_INT_FLAG which provides timing for the main loop.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void)=====&lt;br /&gt;
UART2 receive ISR. Runs with the XBee receives packets. The switch/case structure handles the packets.&lt;br /&gt;
&lt;br /&gt;
The current handling of coordinate data from the vision system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
case 0: //coordinate data&lt;br /&gt;
					e_set_configuration(&lt;br /&gt;
					InPacket.data[1].dataFloat,&lt;br /&gt;
					InPacket.data[2].dataFloat, &lt;br /&gt;
					InPacket.data[3].dataFloat);&lt;br /&gt;
					break;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====TO DO=====&lt;br /&gt;
Needs to be improved. Suggested new function:&lt;br /&gt;
* Get vision system data&lt;br /&gt;
* Check if it&#039;s wildly off from current puck estimate&lt;br /&gt;
** If not, update, clear log of rejected packets&lt;br /&gt;
** If so, reject and log&lt;br /&gt;
*** If we have rejected enough packets (some threshold) and they&#039;ve all been in similar place (within tolerance), we can assume the puck is wrong and vision system is right. In this case, update with vision system data and clear rejected data log.&lt;br /&gt;
&lt;br /&gt;
=====int main(void)=====&lt;br /&gt;
Setup functions and main loop.&lt;br /&gt;
&lt;br /&gt;
===color_cal(.c/.h)===&lt;br /&gt;
* .c: Contains void calibrate_color(void) function to run the calibration routine.&lt;br /&gt;
* .h: Contains function prototype and constant definitions for calibrate_color.&lt;br /&gt;
&lt;br /&gt;
=====void calibrate_color(void)=====&lt;br /&gt;
This function runs the color calibration routine. Eventually this should be turned into a separate e-puck command from the vision system. Currently it just runs the puck through a zig zag pattern on the floor and sends packets. You can collect these with the data logger and process them in matlab. From this, you should be able to get a calibration function.&lt;br /&gt;
&lt;br /&gt;
=====TO DO=====&lt;br /&gt;
* Add to the pattern. Need to collect more data.&lt;br /&gt;
* Possibly have the puck store data, find a best fit, and create the calibration function on board.&lt;br /&gt;
* Store the calibration function in the EEPROM (flash memory) so it&#039;s non-volatile. The coefficients of function will be specific to each puck, so it would be nice to not have to program each puck, each time you change the battery.&lt;br /&gt;
&lt;br /&gt;
===dsPIC_XBeePackets(.c/.h)===&lt;br /&gt;
* .c/.h: Contains functions and data structures for assembling and receiving XBee packets.&lt;br /&gt;
&lt;br /&gt;
=====int readPacket( void)=====&lt;br /&gt;
Parses XBee data from UART2. Makes it accessable in the &#039;&#039;InPacket&#039;&#039; struct.&lt;br /&gt;
&lt;br /&gt;
The UART2 receive ISR takes error codes from this function and flashes the corresponding puck LED (absolute value of the error code).&lt;br /&gt;
&lt;br /&gt;
Error codes are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	//////////////ERROR CODES/////////////////&lt;br /&gt;
	// &lt;br /&gt;
	// -1: Timeout waiting for UART2&lt;br /&gt;
	// -2: Start delimiter wrong&lt;br /&gt;
	// -3: Checksum Error&lt;br /&gt;
	// -4: UART2 not ready at beginning&lt;br /&gt;
	// -5: API_ID unidentified&lt;br /&gt;
	// -6: Send Packet CCA failuue&lt;br /&gt;
	// -7: Modem Status packet failure&lt;br /&gt;
	//////////////////////////////////////////&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===send_packet(.c/.h)===&lt;br /&gt;
* .c: Contains the void send_packet(void) function which fills an array with data and calls the needed XBee functions to send a packet.&lt;br /&gt;
* .h: Contains function prototype.&lt;br /&gt;
&lt;br /&gt;
=====void send_packet(void)=====&lt;br /&gt;
* Creates &#039;&#039;packet&#039;&#039; array.&lt;br /&gt;
* Adds consensus estimator data to the array.&lt;br /&gt;
* Adds robot statistics to the array.&lt;br /&gt;
* Adds color sensor values to the array.&lt;br /&gt;
* Asserts flow control line to stop XBee from sending&lt;br /&gt;
* Calls assemblePacket to send the packet.&lt;br /&gt;
* Deasserts flow control; Xbee can send again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function e_get_acc_filtered returns a running average of the acc specified. Syntax is:&lt;br /&gt;
&lt;br /&gt;
return value = e_get_acc_filtered(acc_channel, number of samples to average)&lt;br /&gt;
&lt;br /&gt;
The number of samples averaged must be less than ACC_SAMP_NB as defined in e_ad_conv.h.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
packet[i]=e_get_acc_filtered(2, 136); // red&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(1, 136); // green&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(0, 136); // blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PI_consensus_estimator(.h)===&lt;br /&gt;
* .h: Contains functions and data structures for the PI consensus estimator. &lt;br /&gt;
* This will probably be replaced by the algorithm for sensor consensus. &lt;br /&gt;
&lt;br /&gt;
===wheel_speed_coordinator(.c/.h)===&lt;br /&gt;
* .c: Contains functions for robot motion control&lt;br /&gt;
* .h: Function prototypes and variabls.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeed(int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speeds for the inertial consensus estimator based on the group goal.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeedSingleBot(float gotox, float gotoy, int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speed to get this individual bot to (gotox, gotoy). It&#039;s a hacked fix. Should be replaced with the 3 step motion controller from NUtest.c.&lt;br /&gt;
&lt;br /&gt;
===e_acc(.c/.h)===&lt;br /&gt;
* .c: Functions for reading the accelerometers (which is the color sensor).&lt;br /&gt;
* .h: Function prototypes.&lt;br /&gt;
&lt;br /&gt;
This is original e-puck library code with the following modifications:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
//changed by Sam, July 10, default offset is 2000. we want 0 for RGB sensor.&lt;br /&gt;
static int centre_z = 0;			//zero value for z axe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====int e_get_acc_filtered(unsigned int captor, unsigned int filter_size)=====&lt;br /&gt;
&lt;br /&gt;
===e_ad_conv(.c/.h)===&lt;br /&gt;
Set up the ADCs on the puck. Original e-puck library code, with the following modifications&lt;br /&gt;
* .h: Define constants and functional prototypes&lt;br /&gt;
&lt;br /&gt;
MIC_SAMP_FREQ sets the baseline sampling frequency for the ADC, everything else must be a fraction of this. 16384 Hz is the highest possible.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MIC_SAMP_FREQ 16384.0	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_PROX_SAMP_FREQ sets the sampling frequency for the accelerometers (color sensor). We found in testing that the puck become non-responsive with this set to 8192 Hz or 16384 Hz.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// sampling frequency for the accelerometres and proximetres&lt;br /&gt;
//#define ACC_PROX_SAMP_FREQ 256.0	// WARNING: should be a fraction of MIC_SAMP_FREQ&lt;br /&gt;
#define ACC_PROX_SAMP_FREQ 4096	//			to ensure a good timing precision&lt;br /&gt;
									// So your options are: 1  2  4  8  16  32  64  128  &lt;br /&gt;
									//  256  512  1024  2048  4096  8192  16384&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_SAMP_NB is the number of samples to store. We can do an average of &#039;&#039;up to&#039;&#039; this many samples. This is set to 140 so we can average 136 samples, which is 4 projector periods.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ACC_SAMP_NB  140	// number of accelerometer samples to store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* .c: Functions and interrupt service routines for ADCs. Original e-puck library, no modifications.&lt;br /&gt;
&lt;br /&gt;
=====e_init_ad_scan(ALL_ADC)=====&lt;br /&gt;
Call to setup ADC and have it work in the background. Use e_acc functions to access data.&lt;br /&gt;
&lt;br /&gt;
===e_init_port(.c/.h)===&lt;br /&gt;
* .c/.h: Initializes the ports on the e-puck. File is from the standard e-puck library. &lt;br /&gt;
&lt;br /&gt;
=====e_init_ports(void)=====&lt;br /&gt;
This function sets up ports on the e-puck. Call before using any ports.&lt;br /&gt;
&lt;br /&gt;
===e_led(.c/.h)===&lt;br /&gt;
* .c/.h: This is a standard e-puck library file that contains functions for manipulating LEDs.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_led(unsigned int led_number, unsigned int value)=====&lt;br /&gt;
Set led_number (0-7) to value (0=off 1=on higher=inverse).&lt;br /&gt;
&lt;br /&gt;
[[Image:e-puck_LED_numbering.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&#039;all&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===e_motors_swarm(.c/.h)===&lt;br /&gt;
* .c/.h: This file is a modified version of the e_motors.h e-puck library file.  This version keeps track of the robot&#039;s position and orientation, and the motor stepping function contains code to update the robot&#039;s position when the wheels turn. &lt;br /&gt;
* The functions like e_rotate and e_translate have been removed and this version is not dependent on e_agenda. &lt;br /&gt;
&lt;br /&gt;
=====#define POINT_OFFSET -31.75 =====&lt;br /&gt;
In addition to constants like wheel radius and wheel base, the offset between the center point of the bot and the point we&#039;re driving is set in e_motors_swarm.h. -31.75 mm is the distance betwene the center and the color sensor. So technically, we&#039;re driving backwards.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T5Interrupt(void)=====&lt;br /&gt;
Timer5 ISR, interrupt for left motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
    xpos = xpos + cval*LINSTEP;&lt;br /&gt;
    ypos = ypos + sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T4Interrupt(void)=====&lt;br /&gt;
Timer4 ISR, interrupt for right motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
	xpos = xpos - cval*LINSTEP;&lt;br /&gt;
    ypos = ypos - sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void e_init_motors(void)=====&lt;br /&gt;
Call this function before other motor functions to initialize the motors.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_speed_left(int motor_speed)/void e_set_speed_right(int motor_speed)=====&lt;br /&gt;
Set the motor speed in steps/second.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the center reference point.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_configuration(float x, float y, float theta)=====&lt;br /&gt;
Sets x, y, theta to values. This is used to overwrite the puck position/orientation estimates with data from the vision system.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration_front(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the front reference point (used for motor control).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;br /&gt;
[[Category:e-puck]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14471</id>
		<title>RGB Swarm Robot Project E-puck Code (outdated)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14471"/>
		<updated>2009-09-11T20:01:26Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Project Package */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the e-puck code for the RGB Sensing Swarm Robotics project. The code on the e-puck was written in C and compiled using Microchip&#039;s MPLAB C Compiler for dsPIC DSCs (student version). &lt;br /&gt;
&lt;br /&gt;
This code is a branch of the [[Swarm Project E-puck Code]].&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===Complete===&lt;br /&gt;
* Got ADC working for color sensor&lt;br /&gt;
** Set up filtering to address projector PWM&lt;br /&gt;
* Restructured code to make more modular.&lt;br /&gt;
** Split dsPIC_XBeePackets and wheel_speed_coordinator into h and c files&lt;br /&gt;
** Pulled packet assembling code out of main and created send_packet() function in send_packet.h/c.&lt;br /&gt;
** Pulled a bunch of variables and defines (&#039;&#039;NUM_DATA_SETS, NUMBERS_PER_SET, DATATYPE_BYTELENGTH , DATA_ARRAY_LENGTH , ADDITIONAL_NUMS, notRTS, T1_INT_FLAG, x_i, u_i, w_i, x_sum, w_sum, MAX_WHEEL_V_TICKS, deadband, COMMR, SAFEDIST, MINDIST, u_x_ideal, u_y_ideal, x_motion_integral, y_motion_integral, SQUARE&#039;&#039;) that were scattered across h files into global_vars.h/c. Makes it easy to include them in a particular file with the &#039;&#039;extern&#039;&#039; keyword.&lt;br /&gt;
* Added color_cal() function in color_cal.h/c&lt;br /&gt;
* Added wheelSpeedSingleBot to wheel_speed_coordinator&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
* Finish color calibration (color_cal) program, to facilitate simple calibration for each e-puck that does not require large amount of data collected for each run, and with minimal user input/control (desire automation and simplification)&lt;br /&gt;
* Improve the vision system position information updater&lt;br /&gt;
** So that the e-puck does not automatically assume every packet from the Vision System is true, rather &#039;checks&#039; for accuracy&lt;br /&gt;
* Replace wheelSpeedSingleBot with the three step move controller from NUtest.c&lt;br /&gt;
**Implement this so that the e-puck can be moved with position and orientation (this is ideal so that data from every orientation of the e-puck can be recorded while calibrating or collecting data&lt;br /&gt;
* Implement new algorithm from paper&lt;br /&gt;
&lt;br /&gt;
==Project Package==&lt;br /&gt;
The source code for the project is available here:&lt;br /&gt;
*[[Media:RGB_Swarm_Puck_Code_working_version.zip|&#039;&#039;&#039;RGB Swarm Puck Code working version.zip&#039;&#039;&#039;]]&lt;br /&gt;
**Open swarm_epucks.mcw and you should be good to go.&lt;br /&gt;
&lt;br /&gt;
==Description of the files and functions==&lt;br /&gt;
&lt;br /&gt;
===global_vars(.c/.h)===&lt;br /&gt;
* .c/.h: declare and define global variables and macros&lt;br /&gt;
====Packet Length Constants====&lt;br /&gt;
These variables determine the length of the XBee packets.  See [[Swarm_Robot_Project_Documentation#Data_Frame|Data Frame]] and the section on XBee API packets in the XBee manual for further clarification.&lt;br /&gt;
&lt;br /&gt;
Much of this is still sending integral consensus estimator data. This can be removed or replaces with data needed for decentralized color sensing. &lt;br /&gt;
&lt;br /&gt;
=====#define NUM_DATA_SETS 5 =====	&lt;br /&gt;
Number of statistics on which you are running the consensus estimator.  This this particular case, 5. (Ix, Iy, Ixx, Ixy, Iyy)&lt;br /&gt;
&lt;br /&gt;
=====#define NUMBERS_PER_SET 2=====&lt;br /&gt;
Number of variables in each data set (see above) that the consensus estimator needs to transmit to other agents.  In this case, 2 because there is &amp;lt;tt&amp;gt;x_i&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;w_i&amp;lt;/tt&amp;gt; for each statistic.&lt;br /&gt;
&lt;br /&gt;
=====#define DATATYPE_BYTELENGTH 4	=====&lt;br /&gt;
Number of bytes in the data type (used in the consensus estimator (float = 4 bytes long).  This is important because we need to split the numbers into individual bytes to be able to send them out the serial port.&lt;br /&gt;
&lt;br /&gt;
=====#define DATA_ARRAY_LENGTH (NUM_DATA_SETS*NUMBERS_PER_SET)=====&lt;br /&gt;
Total number of data variables needed for the consensus estimator.  In this case, it is 5*2=10.&lt;br /&gt;
&lt;br /&gt;
=====#define ADDITIONAL_NUMS 8=====&lt;br /&gt;
Additional number of data to be appended to data array.  It is 5 in this case, so that we can append &lt;br /&gt;
# Robot X coordinate&lt;br /&gt;
# Robot Y coordinate&lt;br /&gt;
# Robot Theta orientation&lt;br /&gt;
# Robot left wheel speed&lt;br /&gt;
# Robot right wheel speed&lt;br /&gt;
# Sensor Red Value&lt;br /&gt;
# Sensor Green Value&lt;br /&gt;
# Sensor Blue Value&lt;br /&gt;
&lt;br /&gt;
===main(.c/.h)===&lt;br /&gt;
* .c: This contains the entry point of the code and contains the initialization routines, main loop, and interrupt service routines. &lt;br /&gt;
* .h: Contains variables, function prototypes, and delay function needed for main.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _T1Interrupt(void)=====&lt;br /&gt;
Timer1 ISR. Sets T1_INT_FLAG which provides timing for the main loop.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void)=====&lt;br /&gt;
UART2 receive ISR. Runs with the XBee receives packets. The switch/case structure handles the packets.&lt;br /&gt;
&lt;br /&gt;
The current handling of coordinate data from the vision system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
case 0: //coordinate data&lt;br /&gt;
					e_set_configuration(&lt;br /&gt;
					InPacket.data[1].dataFloat,&lt;br /&gt;
					InPacket.data[2].dataFloat, &lt;br /&gt;
					InPacket.data[3].dataFloat);&lt;br /&gt;
					break;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====TO DO=====&lt;br /&gt;
Needs to be improved. Suggested new function:&lt;br /&gt;
* Get vision system data&lt;br /&gt;
* Check if it&#039;s wildly off from current puck estimate&lt;br /&gt;
** If not, update, clear log of rejected packets&lt;br /&gt;
** If so, reject and log&lt;br /&gt;
*** If we have rejected enough packets (some threshold) and they&#039;ve all been in similar place (within tolerance), we can assume the puck is wrong and vision system is right. In this case, update with vision system data and clear rejected data log.&lt;br /&gt;
&lt;br /&gt;
=====int main(void)=====&lt;br /&gt;
Setup functions and main loop.&lt;br /&gt;
&lt;br /&gt;
===color_cal(.c/.h)===&lt;br /&gt;
* .c: Contains void calibrate_color(void) function to run the calibration routine.&lt;br /&gt;
* .h: Contains function prototype and constant definitions for calibrate_color.&lt;br /&gt;
&lt;br /&gt;
=====void calibrate_color(void)=====&lt;br /&gt;
This function runs the color calibration routine. Eventually this should be turned into a separate e-puck command from the vision system. Currently it just runs the puck through a zig zag pattern on the floor and sends packets. You can collect these with the data logger and process them in matlab. From this, you should be able to get a calibration function.&lt;br /&gt;
&lt;br /&gt;
=====TO DO=====&lt;br /&gt;
* Add to the pattern. Need to collect more data.&lt;br /&gt;
* Possibly have the puck store data, find a best fit, and create the calibration function on board.&lt;br /&gt;
* Store the calibration function in the EEPROM (flash memory) so it&#039;s non-volatile. The coefficients of function will be specific to each puck, so it would be nice to not have to program each puck, each time you change the battery.&lt;br /&gt;
&lt;br /&gt;
===dsPIC_XBeePackets(.c/.h)===&lt;br /&gt;
* .c/.h: Contains functions and data structures for assembling and receiving XBee packets.&lt;br /&gt;
&lt;br /&gt;
=====int readPacket( void)=====&lt;br /&gt;
Parses XBee data from UART2. Makes it accessable in the &#039;&#039;InPacket&#039;&#039; struct.&lt;br /&gt;
&lt;br /&gt;
The UART2 receive ISR takes error codes from this function and flashes the corresponding puck LED (absolute value of the error code).&lt;br /&gt;
&lt;br /&gt;
Error codes are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	//////////////ERROR CODES/////////////////&lt;br /&gt;
	// &lt;br /&gt;
	// -1: Timeout waiting for UART2&lt;br /&gt;
	// -2: Start delimiter wrong&lt;br /&gt;
	// -3: Checksum Error&lt;br /&gt;
	// -4: UART2 not ready at beginning&lt;br /&gt;
	// -5: API_ID unidentified&lt;br /&gt;
	// -6: Send Packet CCA failuue&lt;br /&gt;
	// -7: Modem Status packet failure&lt;br /&gt;
	//////////////////////////////////////////&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===send_packet(.c/.h)===&lt;br /&gt;
* .c: Contains the void send_packet(void) function which fills an array with data and calls the needed XBee functions to send a packet.&lt;br /&gt;
* .h: Contains function prototype.&lt;br /&gt;
&lt;br /&gt;
=====void send_packet(void)=====&lt;br /&gt;
* Creates &#039;&#039;packet&#039;&#039; array.&lt;br /&gt;
* Adds consensus estimator data to the array.&lt;br /&gt;
* Adds robot statistics to the array.&lt;br /&gt;
* Adds color sensor values to the array.&lt;br /&gt;
* Asserts flow control line to stop XBee from sending&lt;br /&gt;
* Calls assemblePacket to send the packet.&lt;br /&gt;
* Deasserts flow control; Xbee can send again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function e_get_acc_filtered returns a running average of the acc specified. Syntax is:&lt;br /&gt;
&lt;br /&gt;
return value = e_get_acc_filtered(acc_channel, number of samples to average)&lt;br /&gt;
&lt;br /&gt;
The number of samples averaged must be less than ACC_SAMP_NB as defined in e_ad_conv.h.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
packet[i]=e_get_acc_filtered(2, 136); // red&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(1, 136); // green&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(0, 136); // blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PI_consensus_estimator(.h)===&lt;br /&gt;
* .h: Contains functions and data structures for the PI consensus estimator. &lt;br /&gt;
* This will probably be replaced by the algorithm for sensor consensus. &lt;br /&gt;
&lt;br /&gt;
===wheel_speed_coordinator(.c/.h)===&lt;br /&gt;
* .c: Contains functions for robot motion control&lt;br /&gt;
* .h: Function prototypes and variabls.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeed(int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speeds for the inertial consensus estimator based on the group goal.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeedSingleBot(float gotox, float gotoy, int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speed to get this individual bot to (gotox, gotoy). It&#039;s a hacked fix. Should be replaced with the 3 step motion controller from NUtest.c.&lt;br /&gt;
&lt;br /&gt;
===e_acc(.c/.h)===&lt;br /&gt;
* .c: Functions for reading the accelerometers (which is the color sensor).&lt;br /&gt;
* .h: Function prototypes.&lt;br /&gt;
&lt;br /&gt;
This is original e-puck library code with the following modifications:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
//changed by Sam, July 10, default offset is 2000. we want 0 for RGB sensor.&lt;br /&gt;
static int centre_z = 0;			//zero value for z axe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====int e_get_acc_filtered(unsigned int captor, unsigned int filter_size)=====&lt;br /&gt;
&lt;br /&gt;
===e_ad_conv(.c/.h)===&lt;br /&gt;
Set up the ADCs on the puck. Original e-puck library code, with the following modifications&lt;br /&gt;
* .h: Define constants and functional prototypes&lt;br /&gt;
&lt;br /&gt;
MIC_SAMP_FREQ sets the baseline sampling frequency for the ADC, everything else must be a fraction of this. 16384 Hz is the highest possible.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MIC_SAMP_FREQ 16384.0	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_PROX_SAMP_FREQ sets the sampling frequency for the accelerometers (color sensor). We found in testing that the puck become non-responsive with this set to 8192 Hz or 16384 Hz.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// sampling frequency for the accelerometres and proximetres&lt;br /&gt;
//#define ACC_PROX_SAMP_FREQ 256.0	// WARNING: should be a fraction of MIC_SAMP_FREQ&lt;br /&gt;
#define ACC_PROX_SAMP_FREQ 4096	//			to ensure a good timing precision&lt;br /&gt;
									// So your options are: 1  2  4  8  16  32  64  128  &lt;br /&gt;
									//  256  512  1024  2048  4096  8192  16384&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_SAMP_NB is the number of samples to store. We can do an average of &#039;&#039;up to&#039;&#039; this many samples. This is set to 140 so we can average 136 samples, which is 4 projector periods.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ACC_SAMP_NB  140	// number of accelerometer samples to store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* .c: Functions and interrupt service routines for ADCs. Original e-puck library, no modifications.&lt;br /&gt;
&lt;br /&gt;
=====e_init_ad_scan(ALL_ADC)=====&lt;br /&gt;
Call to setup ADC and have it work in the background. Use e_acc functions to access data.&lt;br /&gt;
&lt;br /&gt;
===e_init_port(.c/.h)===&lt;br /&gt;
* .c/.h: Initializes the ports on the e-puck. File is from the standard e-puck library. &lt;br /&gt;
&lt;br /&gt;
=====e_init_ports(void)=====&lt;br /&gt;
This function sets up ports on the e-puck. Call before using any ports.&lt;br /&gt;
&lt;br /&gt;
===e_led(.c/.h)===&lt;br /&gt;
* .c/.h: This is a standard e-puck library file that contains functions for manipulating LEDs.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_led(unsigned int led_number, unsigned int value)=====&lt;br /&gt;
Set led_number (0-7) to value (0=off 1=on higher=inverse).&lt;br /&gt;
&lt;br /&gt;
[[Image:e-puck_LED_numbering.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&#039;all&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===e_motors_swarm(.c/.h)===&lt;br /&gt;
* .c/.h: This file is a modified version of the e_motors.h e-puck library file.  This version keeps track of the robot&#039;s position and orientation, and the motor stepping function contains code to update the robot&#039;s position when the wheels turn. &lt;br /&gt;
* The functions like e_rotate and e_translate have been removed and this version is not dependent on e_agenda. &lt;br /&gt;
&lt;br /&gt;
=====#define POINT_OFFSET -31.75 =====&lt;br /&gt;
In addition to constants like wheel radius and wheel base, the offset between the center point of the bot and the point we&#039;re driving is set in e_motors_swarm.h. -31.75 mm is the distance betwene the center and the color sensor. So technically, we&#039;re driving backwards.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T5Interrupt(void)=====&lt;br /&gt;
Timer5 ISR, interrupt for left motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
    xpos = xpos + cval*LINSTEP;&lt;br /&gt;
    ypos = ypos + sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T4Interrupt(void)=====&lt;br /&gt;
Timer4 ISR, interrupt for right motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
	xpos = xpos - cval*LINSTEP;&lt;br /&gt;
    ypos = ypos - sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void e_init_motors(void)=====&lt;br /&gt;
Call this function before other motor functions to initialize the motors.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_speed_left(int motor_speed)/void e_set_speed_right(int motor_speed)=====&lt;br /&gt;
Set the motor speed in steps/second.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the center reference point.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_configuration(float x, float y, float theta)=====&lt;br /&gt;
Sets x, y, theta to values. This is used to overwrite the puck position/orientation estimates with data from the vision system.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration_front(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the front reference point (used for motor control).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;br /&gt;
[[Category:e-puck]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14470</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14470"/>
		<updated>2009-09-11T19:59:58Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Machine Vision Localization System Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide|&#039;&#039;&#039;RGB Swarm Quickstart Guide&#039;&#039;&#039;]] for information on how start and use the RGB Swarm system and its setup.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| [[Image:E puck XBee board2.JPG|vertical|169px|thumb|e-puck with Xbee Board 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
This is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
[[Image:E puck LED board.jpg|280px|right|thumb|e-puck with LED pattern board]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System.zip&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
Pulse Width Modulation can lead to problems when recording data. For instance, when first setting up data recording for the Xbee radios, it was discovered that the RGB values would fluctuate across a period of several minutes, skewing that data. Doing more research into the projector, such as by using the digital oscilloscopes, the problem was fixed on the fact that projector does not project exactly across 120 hz, resulting a period that is slight off from the 8ms that was being used to sample data. The solution to the problem was to record several samples (currently 4), average the samples, and use the average the correct value. There is time to record 4 samples, or 32ms of data, as puck has 400ms (.4s) to record data, construct a packet, and send the packet out. The result of this averaging is that the irregularities due to PWM are phased out, resulting in a clean and stable trace without low-frequency modulations.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
====e-puck Modifications====&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
====DV Camera====&lt;br /&gt;
A camera will be used to record and document the experiments while they take place inside the tent. The quality must be high enough to show/broadcast to interested parties (such as online video streaming), and possible for presentations, etc.&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control), such as play/pause/record controls from the computer to the camera&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º using a focal length of 36mm converted to 21.6mm by 0.6X magnification, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
====Computer Additions====&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
*Get a firewire card to accommodate DV camera, but may not be necessary if camera only uses USB 2.0 ports (mentioned above)&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14469</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14469"/>
		<updated>2009-09-11T19:58:54Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Version 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide|&#039;&#039;&#039;RGB Swarm Quickstart Guide&#039;&#039;&#039;]] for information on how start and use the RGB Swarm system and its setup.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| [[Image:E puck XBee board2.JPG|vertical|169px|thumb|e-puck with Xbee Board 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
This is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
[[Image:E puck LED board.jpg|280px|right|thumb|e-puck with LED pattern board]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
Pulse Width Modulation can lead to problems when recording data. For instance, when first setting up data recording for the Xbee radios, it was discovered that the RGB values would fluctuate across a period of several minutes, skewing that data. Doing more research into the projector, such as by using the digital oscilloscopes, the problem was fixed on the fact that projector does not project exactly across 120 hz, resulting a period that is slight off from the 8ms that was being used to sample data. The solution to the problem was to record several samples (currently 4), average the samples, and use the average the correct value. There is time to record 4 samples, or 32ms of data, as puck has 400ms (.4s) to record data, construct a packet, and send the packet out. The result of this averaging is that the irregularities due to PWM are phased out, resulting in a clean and stable trace without low-frequency modulations.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
====e-puck Modifications====&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
====DV Camera====&lt;br /&gt;
A camera will be used to record and document the experiments while they take place inside the tent. The quality must be high enough to show/broadcast to interested parties (such as online video streaming), and possible for presentations, etc.&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control), such as play/pause/record controls from the computer to the camera&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º using a focal length of 36mm converted to 21.6mm by 0.6X magnification, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
====Computer Additions====&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
*Get a firewire card to accommodate DV camera, but may not be necessary if camera only uses USB 2.0 ports (mentioned above)&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14468</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14468"/>
		<updated>2009-09-11T19:58:03Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* RGB Swarm Quickstart Guide */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide|&#039;&#039;&#039;RGB Swarm Quickstart Guide&#039;&#039;&#039;]] for information on how start and use the RGB Swarm system and its setup.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| [[Image:E puck XBee board2.JPG|vertical|169px|thumb|e-puck with Xbee Board 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
[[Image:E puck LED board.jpg|280px|right|thumb|e-puck with LED pattern board]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
Pulse Width Modulation can lead to problems when recording data. For instance, when first setting up data recording for the Xbee radios, it was discovered that the RGB values would fluctuate across a period of several minutes, skewing that data. Doing more research into the projector, such as by using the digital oscilloscopes, the problem was fixed on the fact that projector does not project exactly across 120 hz, resulting a period that is slight off from the 8ms that was being used to sample data. The solution to the problem was to record several samples (currently 4), average the samples, and use the average the correct value. There is time to record 4 samples, or 32ms of data, as puck has 400ms (.4s) to record data, construct a packet, and send the packet out. The result of this averaging is that the irregularities due to PWM are phased out, resulting in a clean and stable trace without low-frequency modulations.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
====e-puck Modifications====&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
====DV Camera====&lt;br /&gt;
A camera will be used to record and document the experiments while they take place inside the tent. The quality must be high enough to show/broadcast to interested parties (such as online video streaming), and possible for presentations, etc.&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control), such as play/pause/record controls from the computer to the camera&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º using a focal length of 36mm converted to 21.6mm by 0.6X magnification, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
====Computer Additions====&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
*Get a firewire card to accommodate DV camera, but may not be necessary if camera only uses USB 2.0 ports (mentioned above)&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14467</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14467"/>
		<updated>2009-09-11T19:56:30Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Analysis Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code for the e-puck&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***&#039;&#039;&#039;Note&#039;&#039;&#039;: both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps, so please read carefully&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
Obtain the Matlab Tools and instructions from [[RGB_Swarm_Robot_Project#MATLAB_Code_for_RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB_Swarm_Robot_Project: MATLAB Code for RGB Swarm Robot Project&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: remember to change the &#039;&#039;additional nums&#039;&#039; variable in both these programs to be equal to eight (8) if you are using them with the RGB program, if they are set as five (5) they will not work with the e-pucks or the logger radios&lt;br /&gt;
*[[media:Swarm packet data viewer.zip|&#039;&#039;&#039;Swarm Packet Data Viewer.zip&#039;&#039;&#039;]]&lt;br /&gt;
*[[media:Swarm XBee packet sender.zip|&#039;&#039;&#039;Swarm XBee Packet Sender.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14458</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14458"/>
		<updated>2009-09-11T17:43:40Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Machine Vision Localization System Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code for the e-puck&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***&#039;&#039;&#039;Note&#039;&#039;&#039;: both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps, so please read carefully&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
Obtain the Matlab Tools and instructions from [[RGB_Swarm_Robot_Project#MATLAB_Code_for_RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB_Swarm_Robot_Project: MATLAB Code for RGB Swarm Robot Project&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
*[[media:Swarm packet data viewer.zip|&#039;&#039;&#039;Swarm Packet Data Viewer.zip&#039;&#039;&#039;]]&lt;br /&gt;
*[[media:Swarm XBee packet sender.zip|&#039;&#039;&#039;Swarm XBee Packet Sender.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14457</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14457"/>
		<updated>2009-09-11T17:43:06Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Troubleshooting the XBee Radios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code for the e-puck&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***&#039;&#039;&#039;Note&#039;&#039;&#039;: both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
Obtain the Matlab Tools and instructions from [[RGB_Swarm_Robot_Project#MATLAB_Code_for_RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB_Swarm_Robot_Project: MATLAB Code for RGB Swarm Robot Project&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
*[[media:Swarm packet data viewer.zip|&#039;&#039;&#039;Swarm Packet Data Viewer.zip&#039;&#039;&#039;]]&lt;br /&gt;
*[[media:Swarm XBee packet sender.zip|&#039;&#039;&#039;Swarm XBee Packet Sender.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14456</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14456"/>
		<updated>2009-09-11T17:42:10Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Checklist */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code for the e-puck&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
Obtain the Matlab Tools and instructions from [[RGB_Swarm_Robot_Project#MATLAB_Code_for_RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB_Swarm_Robot_Project: MATLAB Code for RGB Swarm Robot Project&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
*[[media:Swarm packet data viewer.zip|&#039;&#039;&#039;Swarm Packet Data Viewer.zip&#039;&#039;&#039;]]&lt;br /&gt;
*[[media:Swarm XBee packet sender.zip|&#039;&#039;&#039;Swarm XBee Packet Sender.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14455</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14455"/>
		<updated>2009-09-11T17:41:09Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Visual Studio Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
Obtain the Matlab Tools and instructions from [[RGB_Swarm_Robot_Project#MATLAB_Code_for_RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB_Swarm_Robot_Project: MATLAB Code for RGB Swarm Robot Project&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
*[[media:Swarm packet data viewer.zip|&#039;&#039;&#039;Swarm Packet Data Viewer.zip&#039;&#039;&#039;]]&lt;br /&gt;
*[[media:Swarm XBee packet sender.zip|&#039;&#039;&#039;Swarm XBee Packet Sender.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14454</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14454"/>
		<updated>2009-09-11T17:40:07Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Visual Studio Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
Obtain the Matlab Tools and instructions from [[RGB_Swarm_Robot_Project#MATLAB_Code_for_RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB_Swarm_Robot_Project: MATLAB Code for RGB Swarm Robot Project&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
*[[media:Swarm packet data viewer.zip|&#039;&#039;&#039;Swarm packet data viewer.zip&#039;&#039;&#039;]]&lt;br /&gt;
*[[media:Swarm XBee packet sender.zip|&#039;&#039;&#039;Swarm XBee packet sender.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14453</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14453"/>
		<updated>2009-09-11T17:39:47Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Visual Studio Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
Obtain the Matlab Tools and instructions from [[RGB_Swarm_Robot_Project#MATLAB_Code_for_RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB_Swarm_Robot_Project: MATLAB Code for RGB Swarm Robot Project&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
*[[Image:Swarm packet data viewer.zip|&#039;&#039;&#039;Swarm packet data viewer.zip&#039;&#039;&#039;]]&lt;br /&gt;
*[[Image:Swarm XBee packet sender.zip|&#039;&#039;&#039;Swarm XBee packet sender.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14452</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14452"/>
		<updated>2009-09-11T17:38:37Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Matlab Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
Obtain the Matlab Tools and instructions from [[RGB_Swarm_Robot_Project#MATLAB_Code_for_RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB_Swarm_Robot_Project: MATLAB Code for RGB Swarm Robot Project&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14451</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14451"/>
		<updated>2009-09-11T17:37:19Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Troubleshooting the XBee Radios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14449</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14449"/>
		<updated>2009-09-11T16:53:03Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Projector PWM Waveform */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| [[Image:E puck XBee board2.JPG|vertical|169px|thumb|e-puck with Xbee Board 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
[[Image:E puck LED board.jpg|280px|right|thumb|e-puck with LED pattern board]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
Pulse Width Modulation can lead to problems when recording data. For instance, when first setting up data recording for the Xbee radios, it was discovered that the RGB values would fluctuate across a period of several minutes, skewing that data. Doing more research into the projector, such as by using the digital oscilloscopes, the problem was fixed on the fact that projector does not project exactly across 120 hz, resulting a period that is slight off from the 8ms that was being used to sample data. The solution to the problem was to record several samples (currently 4), average the samples, and use the average the correct value. There is time to record 4 samples, or 32ms of data, as puck has 400ms (.4s) to record data, construct a packet, and send the packet out. The result of this averaging is that the irregularities due to PWM are phased out, resulting in a clean and stable trace without low-frequency modulations.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
====e-puck Modifications====&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
====DV Camera====&lt;br /&gt;
A camera will be used to record and document the experiments while they take place inside the tent. The quality must be high enough to show/broadcast to interested parties (such as online video streaming), and possible for presentations, etc.&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control), such as play/pause/record controls from the computer to the camera&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º using a focal length of 36mm converted to 21.6mm by 0.6X magnification, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
====Computer Additions====&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
*Get a firewire card to accommodate DV camera, but may not be necessary if camera only uses USB 2.0 ports (mentioned above)&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14445</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14445"/>
		<updated>2009-09-11T16:46:29Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* LED Pattern Board */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| [[Image:E puck XBee board2.JPG|vertical|169px|thumb|e-puck with Xbee Board 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
[[Image:E puck LED board.jpg|280px|right|thumb|e-puck with LED pattern board]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
====e-puck Modifications====&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
====DV Camera====&lt;br /&gt;
A camera will be used to record and document the experiments while they take place inside the tent. The quality must be high enough to show/broadcast to interested parties (such as online video streaming), and possible for presentations, etc.&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control), such as play/pause/record controls from the computer to the camera&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º using a focal length of 36mm converted to 21.6mm by 0.6X magnification, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
====Computer Additions====&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
*Get a firewire card to accommodate DV camera, but may not be necessary if camera only uses USB 2.0 ports (mentioned above)&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:E_puck_LED_board.jpg&amp;diff=14443</id>
		<title>File:E puck LED board.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:E_puck_LED_board.jpg&amp;diff=14443"/>
		<updated>2009-09-11T16:44:34Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: uploaded a new version of &amp;quot;Image:E puck LED board.jpg&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:E_puck_XBee_board2.JPG&amp;diff=14442</id>
		<title>File:E puck XBee board2.JPG</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:E_puck_XBee_board2.JPG&amp;diff=14442"/>
		<updated>2009-09-11T16:43:35Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: uploaded a new version of &amp;quot;Image:E puck XBee board2.JPG&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14441</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14441"/>
		<updated>2009-09-11T16:41:22Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* XBee Interface Extension Board Version 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| [[Image:E puck XBee board2.JPG|vertical|169px|thumb|e-puck with Xbee Board 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
[[Image:E puck LED board.jpg|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
====e-puck Modifications====&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
====DV Camera====&lt;br /&gt;
A camera will be used to record and document the experiments while they take place inside the tent. The quality must be high enough to show/broadcast to interested parties (such as online video streaming), and possible for presentations, etc.&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control), such as play/pause/record controls from the computer to the camera&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º using a focal length of 36mm converted to 21.6mm by 0.6X magnification, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
====Computer Additions====&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
*Get a firewire card to accommodate DV camera, but may not be necessary if camera only uses USB 2.0 ports (mentioned above)&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:E_puck_XBee_board2.JPG&amp;diff=14439</id>
		<title>File:E puck XBee board2.JPG</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:E_puck_XBee_board2.JPG&amp;diff=14439"/>
		<updated>2009-09-11T16:38:09Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14438</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14438"/>
		<updated>2009-09-11T16:33:28Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* LED Pattern Board */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
[[Image:E puck LED board.jpg|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
====e-puck Modifications====&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
====DV Camera====&lt;br /&gt;
A camera will be used to record and document the experiments while they take place inside the tent. The quality must be high enough to show/broadcast to interested parties (such as online video streaming), and possible for presentations, etc.&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control), such as play/pause/record controls from the computer to the camera&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º using a focal length of 36mm converted to 21.6mm by 0.6X magnification, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
====Computer Additions====&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
*Get a firewire card to accommodate DV camera, but may not be necessary if camera only uses USB 2.0 ports (mentioned above)&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:E_puck_LED_board.jpg&amp;diff=14437</id>
		<title>File:E puck LED board.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:E_puck_LED_board.jpg&amp;diff=14437"/>
		<updated>2009-09-11T16:31:14Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14432</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14432"/>
		<updated>2009-09-11T16:11:15Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
====e-puck Modifications====&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
====DV Camera====&lt;br /&gt;
A camera will be used to record and document the experiments while they take place inside the tent. The quality must be high enough to show/broadcast to interested parties (such as online video streaming), and possible for presentations, etc.&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control), such as play/pause/record controls from the computer to the camera&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º using a focal length of 36mm converted to 21.6mm by 0.6X magnification, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
====Computer Additions====&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
*Get a firewire card to accommodate DV camera, but may not be necessary if camera only uses USB 2.0 ports (mentioned above)&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14431</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14431"/>
		<updated>2009-09-11T16:07:06Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Troubleshooting the XBee Radios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the plug is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
**#Use Matlab tools, such as the&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14428</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14428"/>
		<updated>2009-09-11T15:58:15Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control)&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º using a focal length of 36mm converted to 21.6mm by 0.6X magnification, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14426</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14426"/>
		<updated>2009-09-11T15:55:16Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* MATLAB Code for RGB Swarm Robot Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
*Contains:&lt;br /&gt;
**&#039;&#039;&#039;open_serial.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;color_hist.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;&lt;br /&gt;
**&#039;&#039;&#039;close_serial.m&#039;&#039;&#039;&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#** After running RGB Swarm Data Grabber, run &#039;&#039;&#039;color_hist.m&#039;&#039;&#039;. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control)&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14424</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14424"/>
		<updated>2009-09-11T15:53:02Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* What to do with the files: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
#Run &#039;&#039;&#039;open_serial.m&#039;&#039;&#039; first. &lt;br /&gt;
#*In the .m file, please be sure to change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
#* &#039;&#039;&#039;Remember: this COM Port cannot be the same COM port as the vision system COM port, you will need two (2) radios if operating on one computer&#039;&#039;&#039;. &lt;br /&gt;
#You have the option to run several programs now:&lt;br /&gt;
#*You can run &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m&#039;&#039;&#039;, which reads through packets it receives, and then plots the packet values that you want. Currently it is configured to grab the RGB values that the e-puck sends back in each packet. It then plots the values in a moving plot. Handy for testing the response of the color sensor.&lt;br /&gt;
#**Run &#039;&#039;&#039;color_hist.m:&#039;&#039;&#039; after running RGB_Swarm_Data_Grabber.m. This program plots a histogram of the data collected. This was useful for checking the distribution/standard deviation of several thousand packets received from a stationary e-puck exposed to one projected shade (no sweeping).&lt;br /&gt;
#*You can also run &#039;&#039;&#039;RGB_avg_std_logger.m&#039;&#039;&#039;, which is an interactive point logger. This program reads a set number (currently set at 100) of the packets from the e-puck, and the averages the values received. Simply follow the prompts to grab some nice averaged data. This was most useful for recording the color sensor responses from a stationary e-puck while the projector colors were changed or swept from one range of the spectrum to the other (e.g. R,G,B: 0,0,0 to R,G,B: 255,255,255) &lt;br /&gt;
# &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done with Matlab programs to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control)&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14423</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14423"/>
		<updated>2009-09-11T15:51:57Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Troubleshooting the XBee Radios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the blue is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
***&#039;&#039;&#039;Use packet analysis tools&#039;&#039;&#039;: these analysis tools allow for direct visualization of packets. Below is a list of tools you can use&lt;br /&gt;
**#Open up X-CTU to a connected serial adapter board and XBee radio, and see if you are getting any sort of signal in the terminal box. If the radios are configured to work with one another (e.g. with a e-puck XBee radio and a data logger XBee radio), one should be able to see some signal (it will look like gibberish, this is because it is in hex)&lt;br /&gt;
**#Use a Visual Studio packet tools, such as the [[Swarm_Robot_Project_Documentation#Packet_Sender|&#039;&#039;&#039;Packet Data Sender&#039;&#039;&#039;]] or [[Swarm_Robot_Project_Documentation#Packet_Viewer|&#039;&#039;&#039;Packet Data Viewer&#039;&#039;&#039;]] to check if your XBee radios are working&lt;br /&gt;
**#Use Matlab tools, such as the&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14417</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14417"/>
		<updated>2009-09-11T15:22:37Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Additional Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the blue is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Analysis Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14416</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14416"/>
		<updated>2009-09-11T15:22:06Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Checklist */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external; ours looks like [http://content.etilize.com/Large/11811577.jpg this]&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the blue is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Additional Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14414</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14414"/>
		<updated>2009-09-10T21:43:30Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
* &#039;&#039;&#039;open_serial.m:&#039;&#039;&#039; Change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
* &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
* &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m:&#039;&#039;&#039; Use this to plot the values from the RGB sensor of one puck. It shows a moving plot. Handy for testing.&lt;br /&gt;
* &#039;&#039;&#039;RGB_avg_std_logger.m:&#039;&#039;&#039; Interactive point logger. Follow the prompts to grab some nice data. Useful for testing.&lt;br /&gt;
* &#039;&#039;&#039;color_hist.m:&#039;&#039;&#039; Plot a histogram from RGB_Swarm_Data_Grabber.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control)&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
*Get another video/graphics card for the computer in order to run calibration software from the same computer that is projecting, thus running a dual monitor setup&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14413</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14413"/>
		<updated>2009-09-10T21:42:33Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* e-puck Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
* &#039;&#039;&#039;open_serial.m:&#039;&#039;&#039; Change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
* &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
* &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m:&#039;&#039;&#039; Use this to plot the values from the RGB sensor of one puck. It shows a moving plot. Handy for testing.&lt;br /&gt;
* &#039;&#039;&#039;RGB_avg_std_logger.m:&#039;&#039;&#039; Interactive point logger. Follow the prompts to grab some nice data. Useful for testing.&lt;br /&gt;
* &#039;&#039;&#039;color_hist.m:&#039;&#039;&#039; Plot a histogram from RGB_Swarm_Data_Grabber.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control)&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Make a flow chart demonstrating the decision/command scheme of the e-puck as it is working&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14412</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14412"/>
		<updated>2009-09-10T21:35:25Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
* &#039;&#039;&#039;open_serial.m:&#039;&#039;&#039; Change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
* &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
* &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m:&#039;&#039;&#039; Use this to plot the values from the RGB sensor of one puck. It shows a moving plot. Handy for testing.&lt;br /&gt;
* &#039;&#039;&#039;RGB_avg_std_logger.m:&#039;&#039;&#039; Interactive point logger. Follow the prompts to grab some nice data. Useful for testing.&lt;br /&gt;
* &#039;&#039;&#039;color_hist.m:&#039;&#039;&#039; Plot a histogram from RGB_Swarm_Data_Grabber.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control)&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seem to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14411</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14411"/>
		<updated>2009-09-10T21:34:59Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Future Work and To Do */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
* &#039;&#039;&#039;open_serial.m:&#039;&#039;&#039; Change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
* &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
* &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m:&#039;&#039;&#039; Use this to plot the values from the RGB sensor of one puck. It shows a moving plot. Handy for testing.&lt;br /&gt;
* &#039;&#039;&#039;RGB_avg_std_logger.m:&#039;&#039;&#039; Interactive point logger. Follow the prompts to grab some nice data. Useful for testing.&lt;br /&gt;
* &#039;&#039;&#039;color_hist.m:&#039;&#039;&#039; Plot a histogram from RGB_Swarm_Data_Grabber.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control)&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seems to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor, allowing for the camera to be only 5.4&#039; off the ground&lt;br /&gt;
***The amount of magnification (x) = 1/x amount of FOV; thus a 0.5X magnification lens = 2X amount of FOV&lt;br /&gt;
***Find the amount of focal length the camera has at its widest view (this is the smallest number, and in mm), and then apply the magnification appropriately), so 0.5X magnification = 0.5X focal length&lt;br /&gt;
**#Go online to [http://www.tawbaware.com/maxlyons/calc.htm this site], look for the &#039;&#039;&#039;Angular Field of View Calculator&#039;&#039;&#039; to determine the horizontal and vertical FOV angles&lt;br /&gt;
**#Use these angles, to calculate the height need for the camera to capture the entire image&lt;br /&gt;
**#For example, if the camera is mounted above the center of the floor, the width of the floor is 9&#039;, and the horizontal FOV calculated is 79.6º, then the math to get the height is: 9&#039;/2 = 4.5&#039;, 79.6º/2 = 39.8º; 4.5&#039;/atan(39.8º) = &#039;&#039;&#039;5.4&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14410</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14410"/>
		<updated>2009-09-10T21:22:00Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Future Work and To Do */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
* &#039;&#039;&#039;open_serial.m:&#039;&#039;&#039; Change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
* &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
* &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m:&#039;&#039;&#039; Use this to plot the values from the RGB sensor of one puck. It shows a moving plot. Handy for testing.&lt;br /&gt;
* &#039;&#039;&#039;RGB_avg_std_logger.m:&#039;&#039;&#039; Interactive point logger. Follow the prompts to grab some nice data. Useful for testing.&lt;br /&gt;
* &#039;&#039;&#039;color_hist.m:&#039;&#039;&#039; Plot a histogram from RGB_Swarm_Data_Grabber.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
===Hardware===&lt;br /&gt;
*Measure resistance of potentiometers on e-pucks, then remove them and replace with fixed resistors to further reduce variability&lt;br /&gt;
*Get a DV camera, check for fit with the existing physical set up (see projector/webcam framework)&lt;br /&gt;
*Check DV camera control functionality when plugged into computer (firewire control)&lt;br /&gt;
*Select a camera, wide angle lens, fireware card&lt;br /&gt;
**Mini DV cameras seems to be the best bet as they are designed to accommodate for control via firewire cable due to necessity of capturing data from the tape&lt;br /&gt;
**A 0.6X magnification lens accommodates 9&#039; x 6&#039; floor &lt;br /&gt;
&lt;br /&gt;
===Vision System===&lt;br /&gt;
*Complete vision system calibration by being able to move from floor coordinates to pixel row/column coordinates and then back&lt;br /&gt;
*Update vision system to accommodate change between black/white pattern recognition and LED/light intensity recognition (eliminate going through code)\&lt;br /&gt;
&lt;br /&gt;
===e-puck Code===&lt;br /&gt;
*Get rid of sin/cos calculations which take more cycles than desired&lt;br /&gt;
**Calculate discrete # of possible angles per wheel (use ticks/revolution), create a look up table, check the angle from the vision system packets, use standardized table to calculate appropriate vector (reducing total number of calculations and eliminating use of sin/cos)&lt;br /&gt;
*Complete/finish calibration scheme (color_cal) to calibrate e-pucks for the projector set up&lt;br /&gt;
**Finish writing program to &#039;lawnmower&#039; e-puck, allowing to collect data from all positions and all orientations across the floor&lt;br /&gt;
***Implement 3 part turn from NUtest.c code for e-puck to accommodate control of position and orientation&lt;br /&gt;
**Need to analyze the data collected in different ways&lt;br /&gt;
***Generate table/equation for different floor positions and e-puck orientations, only one color/shade&lt;br /&gt;
***Generate table of scalars (for different positions on the floor) for an equation which can be used to equate e-puck ADC outputs with RGB input, full spectrum sweep&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14409</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14409"/>
		<updated>2009-09-10T21:03:53Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* &amp;#039;&amp;#039;Conclusion&amp;#039;&amp;#039; */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
* &#039;&#039;&#039;open_serial.m:&#039;&#039;&#039; Change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
* &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
* &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m:&#039;&#039;&#039; Use this to plot the values from the RGB sensor of one puck. It shows a moving plot. Handy for testing.&lt;br /&gt;
* &#039;&#039;&#039;RGB_avg_std_logger.m:&#039;&#039;&#039; Interactive point logger. Follow the prompts to grab some nice data. Useful for testing.&lt;br /&gt;
* &#039;&#039;&#039;color_hist.m:&#039;&#039;&#039; Plot a histogram from RGB_Swarm_Data_Grabber.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14408</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14408"/>
		<updated>2009-09-10T21:03:44Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* &amp;#039;&amp;#039;&amp;#039;Conclusion&amp;#039;&amp;#039;&amp;#039; */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
* &#039;&#039;&#039;open_serial.m:&#039;&#039;&#039; Change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
* &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
* &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m:&#039;&#039;&#039; Use this to plot the values from the RGB sensor of one puck. It shows a moving plot. Handy for testing.&lt;br /&gt;
* &#039;&#039;&#039;RGB_avg_std_logger.m:&#039;&#039;&#039; Interactive point logger. Follow the prompts to grab some nice data. Useful for testing.&lt;br /&gt;
* &#039;&#039;&#039;color_hist.m:&#039;&#039;&#039; Plot a histogram from RGB_Swarm_Data_Grabber.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&#039;&#039;Conclusion&#039;&#039;==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data.&lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14407</id>
		<title>RGB Swarm Robot Project Documentation</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_Documentation&amp;diff=14407"/>
		<updated>2009-09-10T21:03:28Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The swarm robot project has gone through several phases, with each phase focusing on different aspects of swarm robotics and the implementation of the project. This entry focuses on the most recent phase of the project, covering topics such as, but not limited to, &#039;&#039;&#039;Xbee Interface Extension Boards&#039;&#039;&#039;, &#039;&#039;&#039;LED light boards&#039;&#039;&#039;, and &#039;&#039;&#039;changes made to the Machine Vision Localization System&#039;&#039;&#039;, and the overall conversion to LED boards and a controlled light environment. These entries help provide insight into setup and specific details to allow others to replicate or reproduce our results, and to provide additional information for those working on similar projects or this project at a later time. Other articles in the &#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039; category focus on topics such as the swarm theory and algorithms implemented, as well as previous phases of the project, such as motion control and consensus estimation. You may reach these articles and others by following the category link at the bottom of every page, or through this link - [[:Category:SwarmRobotProject|&#039;&#039;&#039;Swarm Robot Project&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm Quickstart Guide==&lt;br /&gt;
&lt;br /&gt;
Refer to [[RGB Swarm Quickstart Guide]] for information.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===XBee Interface Extension Board Version 2===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v1.gif|250px|thumb|alt=Traxmaker Image of the Previous Xbee Extension Board|Xbee Interface Extension Board Version]]&lt;br /&gt;
| [[Image:IMG 1390-1-.jpg|300px|thumb|alt=Image of an e-Puck with the RGB Xbee Extension Board|e-Puck with previous board ]]&lt;br /&gt;
| [[Image:XBee_interface_extenstion_board_v2.gif|vertical|250px|thumb|alt=Traxmaker Image of the Xbee Interface Exension Board Version 2|Xbee Interface Extension Board Version 2]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Previous Version====&lt;br /&gt;
&lt;br /&gt;
The previous version of XBee Interface Extension Board, designed by Michael Hwang.&lt;br /&gt;
Its configuration is shown in the figure on the left, with an actual image of the board mounted on an e-Puck seen in the figure in the center. This version of the XBee Interface Board does not contain a color sensor in it. Details about this version of XBee Interface Extension Board, such as parts used and Traxmaker files can be found on the [[Swarm_Robot_Project_Documentation#Current_Version|Swarm Robot Project Documentation page]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Version 2====&lt;br /&gt;
Th is the updated version of the Xbee board, or XBee Interface Extension Board Version 2. It is designed by Michael Hwang to accommodate further projects in the Swarm Robot Project. For this reason, the Xbee Interface Extension Board Version 2 has a color sensor circuit built in. The details of the color sensor circuit can be found in the color sensor section below. A copy of the Traxmaker PCB file for the Xbee Board Version 2 can be found below:&lt;br /&gt;
*[[Media:epuck_xbee_board_v2.zip|&#039;&#039;&#039;Xbee Interface Extension Board Version 2.zip&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
The RTS flow control line on the XBee is connected to the sel3 line of the e-puck. Although the CTS line is not connected to the sel2 pin in this board design, it can be easily connected with a jumper. &lt;br /&gt;
&lt;br /&gt;
The XBee Interface Extension Board Version 2 design was actually built and implemented on the e-puck #3. In order to see if there is any working problem in this board design, it is first tested with the other e-puck which uses the previous XBee Boards. &lt;br /&gt;
&lt;br /&gt;
The e-puck #3 upgraded with the new XBee board did not show any problem in communicating with other e-pucks. According to the goal defined, all e-pucks, including e-puck #3, locate themselves to the desired location.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
=====Color Sensor Circuit=====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_R.gif|300px|thumb|Red Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_G.gif|315px|thumb|Green Color Sensor Circuit]]&lt;br /&gt;
| [[Image:color_sensor_circuit_diagram_v1_B.gif|300px|thumb|Blue Color Sensor Circuit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As you may draw from the circuit diagrams above, as each photodiode receives light, a certain amount of current start to flow through the photodiodes and generates a voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K. Each photodiode is designed to detect the certain range of wavelength of the light, and the amount of current flowing through the photodiodes is determined according to the amount of the corresponding light to each photodiode. The op-amp (LMC6484) takes the voltage generated across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; as the input signal, amplifying it by a ratio particular to the circuit. This ratio is also known as gain, and is defined by resistance of the potentiometer. The now amplified output is then sent to the analog digital converter, which on the e-Puck had been used as the X,Y, and Z axis accelerometers. This convenient, as each accelerometer axis can be used as a channel for the color sensors three colors. The converted signal can then be used to measure the response of the color sensor to light. The corresponding equation for the circuits illustrated above are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;|V_o| = |V_i * \frac{R_2}{R_{pot}}|&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*R&amp;lt;sub&amp;gt;pot&amp;lt;/sub&amp;gt; = resistance of the potentiometer (shown in the diagram)&lt;br /&gt;
*R&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 100K (shown in the diagram)&lt;br /&gt;
*V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; = voltage across R&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; = 680K, which the op-amp takes as an input&lt;br /&gt;
*V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; = output signal amplified from the op-amp&lt;br /&gt;
&lt;br /&gt;
The gain of the color sensor circuits is approximately 20. Thus, the input voltage, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, is amplified to be 20V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, which is V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;. As mentioned above, the gain can be adjusted properly by controlling the resistance of the potentiometer.&lt;br /&gt;
&lt;br /&gt;
As shown in the circuit diagram on the left, the siganl from the red photodiode goes into the pin #5, and the amplified signal is sent out through the pin # 7. Similarly, the signal from the green photodiode goes into the pin #3 and it is sent out from pin #1 while the signal from the blue photodiode goes into the pin #12, and it is sent out from pin #14. &lt;br /&gt;
&lt;br /&gt;
Output Pins&lt;br /&gt;
*Pin #7 - Amplified Red photodiode signal&lt;br /&gt;
*Pin #1 - Amplified Green photodiode signal&lt;br /&gt;
*Pin #14 - Amplified Blue photodiode signal&lt;br /&gt;
&lt;br /&gt;
=====Parts used=====&lt;br /&gt;
Parts used in both the previous version and the new version of XBee Interface Extension Board&lt;br /&gt;
*2x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
*LE-33 low dropout voltage regulator (Digikey 497-4258-1-ND) &lt;br /&gt;
*2.2uF tantalum capacitor (Digikey 399-3536-ND) &lt;br /&gt;
*2x Samtec BTE-020-02-L-D-A (Order directly from Samtec) &lt;br /&gt;
*0.1&amp;quot;header pins for RTS and CTS pins (you can also use wire for a permanent connection) &lt;br /&gt;
*2x 0.1&amp;quot; jumpers for connecting RTS and CTS pins if you used header pins(Digikey S9000-ND) &lt;br /&gt;
&lt;br /&gt;
Additional parts for new version of XBee Interface Extension Board&lt;br /&gt;
*3x 100K resistors&lt;br /&gt;
*3x 680K resistors&lt;br /&gt;
*3x 10K potentiometer&lt;br /&gt;
*3x 5pF capacitor&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02, [http://jp.hamamatsu.com/resources/products/ssd/pdf/s9032-02_kspd1067e03.pdf Datasheet])&lt;br /&gt;
*1x High impedence op-amp LMC6484&lt;br /&gt;
&lt;br /&gt;
=====Future modifications=====&lt;br /&gt;
As mentioned in the overview, the black dot patterns of e-pucks are replaced with new LED patterns by implementing LED pattern board at the top of each e-puck. Thus, in order for the color sensor to collect data properly, it is necessary to move the color sensor from the XBee Interface Extension Board to the LED pattern board so that nothing will block the color sensor. All other components for the color sensor circuit remains in the XBee Interface Extension Board and only the color sensor will be place in the LED pattern board. We can use a jumper to connect the color sensor placed at the LED pattern board to the color sensor circuit place in the XBee Interface Extension Board. The datails of this LED pattern Board will be presented at the section below.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===LED Pattern Board===&lt;br /&gt;
[[Image:LED_pattern_board.gif|280px|right|thumb]]&lt;br /&gt;
This is the LED pattern board, which was introduced for the RGB Swarm Robot Project. Currently, the unique black dot pattern of each e-puck  was used for the machine vision system to recognize each e-puck. However, this black dot pattern requires a white background in order for the machine vision system to recognize e-pucks. The new LED pattern board uses LEDs with the proper brightness, instead of the black dot pattern. By doing so, the machine vision system can now recognize e-pucks on any background. The reason why this LED pattern is recognized on any background will be presented briefly in the Code section below. In addition, in order to apply this LED pattern to the machine vision system, we made a modification in code. This modification will also be presented in the Code Section below. The PCB file can be downloaded here:&lt;br /&gt;
*[[Media:LED_Pattern_Board.zip|&#039;&#039;&#039;LED Pattern Board.zip&#039;&#039;&#039;]]&lt;br /&gt;
**This file contains the Traxmaker PCB files for an individual LED Pattern Board, as well as a 2x2 array, along with the necessary Gerber and drill files necessary for ordering PCBs.&lt;br /&gt;
&lt;br /&gt;
====LED Pattern Board Design====&lt;br /&gt;
This LED Pattern Board is created using Traxmaker. This LED Board design can be downloaded here:&lt;br /&gt;
Although we replaced the black dots with LEDs, we maintain each pattern of dots. The horizontal distance and the vertical distance between the two adjacent LEDs are both 0.8 inch. In order to reduce power consumption of the e-puck battery, we implement a seperate pair of AAA batteries to supply power to the LEDs. This LED board can be turned on and off by the switch.&lt;br /&gt;
The millicandela rating of the LEDs used is 4850 mcd. In addition, this LED has diffused lens style. The reason to choose this LED is that it has a proper brightness and power consumption, and it is diffused so that the machine vision system can capture this LED in any places.The resistor used are 68.7 ohm.  &lt;br /&gt;
&lt;br /&gt;
As mentioned in the XBee Interface Extension Board section, the color sensor has to be moved to this LED pattern board from the XBee Interface Extension Board so that nothing blocks the sensor. Thus, as you can see in the Figure on the left, the color sensor is place at the front, and each photodiode is connected to the 10 pin header. This header connects the color sensor on the LED pattern board to the remaining part of color sensor circuit on the XBee Interface Extension Board v2. &lt;br /&gt;
&lt;br /&gt;
====Parts used====&lt;br /&gt;
*3x LED (Digikey 516-1697-ND): Some e-pucks require 4 LEDs since they have a pattern composed of 4 dots&lt;br /&gt;
*3x 68.7 ohm resistors : Some e-pucks require 4 resistors since they have 4 LEDs&lt;br /&gt;
*2x AAA Battery Holder (Digikey 2466K-ND)&lt;br /&gt;
*1x Switch (Digikey CKN1068-ND)&lt;br /&gt;
*1x RGB color sensor (Order directly from HAMAMATSU, part#:s9032-02)&lt;br /&gt;
*1x 10 pos. 2 mm pitch socket (Digikey S5751-10-ND) &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
=====LED Distance vs Color Sensor Signal=====&lt;br /&gt;
Tests need be done in order to note the affect of the LED light on the color sensor due to potential interference. The first experiment performed is designed to see how much interference will be caused as the distance between the LED and the color sensor changes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used in this experiment because the white LED will cover the entire wavelengh ranges of the visible light. The experiment with the white LED can yield a general result, while the experiment with the colored LEDs will yield more specific result focused on the interference between the certain photodiode and the certain color.&lt;br /&gt;
*LED: 18950 mcd (millicandela), digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. The LED and the color sensor were placed at the same plane, and both are facing upward. &lt;br /&gt;
&lt;br /&gt;
4. Distance between the color sensor and the LED is increased by 0.25 inch each time from 1 inch to 2.5 inch.&lt;br /&gt;
&lt;br /&gt;
5. The amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
&lt;br /&gt;
With Ambient light&lt;br /&gt;
[[Image:Distance_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 1 || 1.4 || 0.469&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 1.259 || 1.716 || 0.832&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 1.185 || 1.619 || 0.757&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 1.135 || 1.529 || 0.669&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 1.097 || 1.503 || 0.613&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 1.086 || 1.481 || 0.589&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 1.071 || 1.47 || 0.563&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 1.06 || 1.453 || 0.546&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Distance_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Distance vs Amplified Output&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Distance !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| No LED|| 0.028 || 0.025 || 0.019&lt;br /&gt;
|-&lt;br /&gt;
| 1 inch  || 0.244 || 0.221 || 0.223&lt;br /&gt;
|-&lt;br /&gt;
| 1.25 inch || 0.195 || 0.166 || 0.143&lt;br /&gt;
|-&lt;br /&gt;
| 1.5 inch || 0.162 || 0.123 || 0.097&lt;br /&gt;
|-&lt;br /&gt;
| 1.75 inch  || 0.130 || 0.097 || 0.069&lt;br /&gt;
|-&lt;br /&gt;
| 2 inch || 0.102 || 0.077 || 0.054&lt;br /&gt;
|-&lt;br /&gt;
| 2.25 inch  || 0.087 || 0.064 || 0.045&lt;br /&gt;
|-&lt;br /&gt;
| 2.5 inch || 0.073 || 0.056 || 0.039&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
As you can see in the two graphs above, the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the LED is closest to it. As the distance between the LED and the color sensor increases, the interference decreases. When the color sensor is most affected by the LED under the presence of the room light, the output increases up to 25.9%, 22.6%, and 43.6 % of the original output. As the LED is 2.5 inch away from the color sensor, the output becomes very close to the original value. &lt;br /&gt;
In this experiment, we see that the lights from LEDs can affect the color sensor. However, we used much brighter LED in this experiment than the ones we use in the LED pattern board. The brightness of the LED used in the experiment is 4 times larger than the ones in the LED pattern board. Thus, more experiment with the LEDs used in the LED pattern board is required.&lt;br /&gt;
&lt;br /&gt;
=====LED Angle vs Color Sensor Signal=====&lt;br /&gt;
&lt;br /&gt;
The second experiment is designed to see how much interference will be caused as the angle between LED and color sensor changes. Different from the first experiment, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;, the voltage before amplified, is mesured since amplified output, V&amp;lt;sub&amp;gt;o&amp;lt;/sub&amp;gt;, easily reaches to the maximum.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup and Results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. A white LED is used again in this experiment with the same reason above for the first experiment.&lt;br /&gt;
*LED: 18950 mcd, Digikey part number: C503B-WAN-CABBB151-ND&lt;br /&gt;
&lt;br /&gt;
2. The experiment was performed under the two conditions; with the ambient light and without the ambient light. &lt;br /&gt;
&lt;br /&gt;
3. In this experiment, the distance between LED and color sensor is kept constant, 1 inch. &lt;br /&gt;
&lt;br /&gt;
4. Angle between LED and color sensor is increased by 15º each time from 0º to 90º.&lt;br /&gt;
&lt;br /&gt;
When the angle is 0º, the LED and the color sensor is placed at the same horizontal plane. The LED is facing toward the color sensor(this means that the LED is parallel to the horizontal plane with its head facing the color sensor, which is placed on the same horizontal plane), and the color sensor is facing upward. We increased the angle by 15º each time, and increasing amounts of light from the LED shines onto the color sensor. When the angle is 90º, the LED is right above the color sensor, facing the color sensor directly. This means that the LED and the color sensor are now on the same vertical line, and the LED is facing downward.&lt;br /&gt;
&lt;br /&gt;
5. The voltage before amplified, V&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; as shown in the circuit diagram above, of each photodiode is measured.&lt;br /&gt;
* The reason to measure the volatage before amplified is that the output becomes too large after amplified.&lt;br /&gt;
&lt;br /&gt;
With the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_with_room_light.gif|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.437 || 0.425 || 0.404&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.475 || 0.470 || 0.451&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.490 || 0.491 || 0.501&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.505 || 0.506 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.484 || 0.468 || 0.484&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.457 || 0.453 || 0.440&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.439 || 0.430 || 0.408&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the Ambient Light&lt;br /&gt;
[[Image:Angle_vs_output_without_room_light.jpg|450px|left|thumb]]&lt;br /&gt;
*Unit: Volt, V&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Angle vs Voltage Before Amplified&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Angle !! R !! G !! B  &lt;br /&gt;
|-&lt;br /&gt;
| 0º || 0.446 || 0.436 || 0.416&lt;br /&gt;
|-&lt;br /&gt;
| 15º  || 0.454 || 0.491 || 0.461&lt;br /&gt;
|-&lt;br /&gt;
| 30º || 0.493 || 0.505 || 0.480&lt;br /&gt;
|-&lt;br /&gt;
| 45º || 0.512 || 0.521 || 0.520&lt;br /&gt;
|-&lt;br /&gt;
| 60º  || 0.498 || 0.486 || 0.491&lt;br /&gt;
|-&lt;br /&gt;
| 75º || 0.498 || 0.492 || 0.487&lt;br /&gt;
|-&lt;br /&gt;
| 90º  || 0.485 || 0.479 || 0.515&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the first experiment, two graph above shows that the color sensor is affected by the light from the LED. The color sensor is most affectd by the LED when the angle between two is 45º. The inteference increases as the angle goes to 45º, and reaches to the peak at 45º. Then it decreases as the angle goes to 90º. When the color sensor is most affected by the LED under the presence of the room light, the output increases upto 15.6%, 19.1%, and 28.7% of Vi. As angle becomes 90º, the output becomes very close to the value at the angle of 0º. The reason why the interference is reduced as the angle reaches 90º is that the ambient light presented are blocked by the LED board. When we perform this experiment, the LEDs are implemented on the LED plane. This LED plane blocks the light and make a shadow on the color sensor. Thus, the amount of light that the color sensor receives decreases. That is why the output becomes close to its original value while the angle increases.&lt;br /&gt;
&lt;br /&gt;
====Next Steps====&lt;br /&gt;
The LED Pattern Board design above needs to be modified in the following parts.&lt;br /&gt;
*The hole size for the LEDs has to increase so that it can accomodate the standoff of the LED chosen.&lt;br /&gt;
*The hole size for the switch has to increase so that the switch can be completely inserted through the hole.&lt;br /&gt;
*Currently, 10 pos 2mm pitch socket is used to connect the color sensor to the circuit using wires. Instead, the proper header for the color sensor has to be found to connect the color sensor and the circuit more conveniently.&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System Modification==&lt;br /&gt;
Below is the documentation of changes made to the original machine vision localization system code to accommodate changed setup of the RGB Swarm Robot Project. This version of the code can be downloaded in the link below. For more information about the operation of the system, look through the [[Machine Vision Localization System]] article.&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB Machine Vision Localization System&#039;&#039;&#039;]] &#039;&#039;&#039;(Project Files with Source Code)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Compatibility Problem of Original Code with LEDs===&lt;br /&gt;
The Machine Vision Localization System takes the real (color) image from the four cameras, and converts it into a grey-scale image. Then, using a threshold set in the machine vision code, the grey-scaled image is divided into black and white, and this black and white image is presented on the machine vision system computer screen. With this set-up, the white background on the floor is presented as black, and black dot patterns on e-pucks are presented as white patterns. The system recognizes theses white dot patterns and identify e-pucks, and broadcasts the position coordinates to each e-puck via the Xbee Radio. For more information about the theory refer to the [[Machine Vision Localization System]] article.&lt;br /&gt;
&lt;br /&gt;
However, there is a problem with using black dot patterns to identify e-pucks. Since the machine vision system and code use a preset threshold to divide the grey image into black and white, black dot patterns are affected by the background color due to lack of contrast. For instance, if the background is black, or any color besides white, the system would have a difficult time distinguishing the pattern from the background, and possible not capture them at all. In addition, other problems arise from dirt and debris tracked onto the white surface of the floor, resulting in false patterns, further throwing the system.&lt;br /&gt;
&lt;br /&gt;
A solution is to substitute the black dots with LEDs placed atop the e-pucks, allowing the machine vision system to capture the identification pattern clearly regardless of background color and condition. By adjusting the threshold set in the machine vision code, the system will rely on the contrast of light intensity, minimizing the interference of the operating environment whose light intensity is which is naturally weaker than LEDs&#039;.  &lt;br /&gt;
====Change from Original Code====&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; in &#039;&#039;&#039;RGBVisionTracking.vcproj&#039;&#039;&#039;, the RGB Vision project, the code has been changed in&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 56&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(greyImage[camerai], thresholdedImage[camerai], threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 731&#039;&#039;&#039;:&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;);&lt;br /&gt;
 to&lt;br /&gt;
 cvThreshold(grey, thresholded_image, threshold, 255, &#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
Also, in &#039;&#039;&#039;global_vars.h&#039;&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Line 65&#039;&#039;&#039;:&lt;br /&gt;
 double threshold = &#039;&#039;&#039;75&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
 to&lt;br /&gt;
 double threshold = &#039;&#039;&#039;200&#039;&#039;&#039;;   //black/white threshold&lt;br /&gt;
&lt;br /&gt;
As change &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY_INV&#039;&#039;&#039;&#039;&#039; in both line 48 and 735 to &#039;&#039;&#039;&#039;&#039;CV_THRESH_BINARY&#039;&#039;&#039;&#039;&#039; and adjust the value of threshold from &#039;&#039;&#039;&#039;&#039;75&#039;&#039;&#039;&#039;&#039; to &#039;&#039;&#039;&#039;&#039;200&#039;&#039;&#039;&#039;&#039;, the system now clearly presents LED patterns as white dot patterns on the screen, so it can identify e-pucks according to LED patterns.&lt;br /&gt;
&lt;br /&gt;
====Threshold Testing====&lt;br /&gt;
The threshold value of &#039;&#039;200&#039;&#039; is determined to be good enough for the test inside. With various conditions, however, the threshold value can, or should, be changed more properly. In addition, the results for different range of threshold under the same test condition is presented below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;3&amp;quot;&lt;br /&gt;
|+&#039;&#039;&#039;Threshold range&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Range !! Result &lt;br /&gt;
|-&lt;br /&gt;
|  0 - 94 || System cannot caputure LED patterns at all; whole screen is white.&lt;br /&gt;
|-&lt;br /&gt;
|  95 - 170 || System can recognize the pattern but it is unstable, since most of background becomes white.&lt;br /&gt;
|-&lt;br /&gt;
|  171 - 252 || System cleary captures and recognizes LED patterns.&lt;br /&gt;
|-&lt;br /&gt;
|  253|| System can recognize the pattern but it is unstable since pattern is too small; stronger intensity is required.&lt;br /&gt;
|-&lt;br /&gt;
|  254 - 255 || System cannot caputure LED patterns at all; whole screen is black.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An e-puck was fitted with a LED pattern board and then tested with the machine vision localization system. With the changes implemented, the machine vision localization system did not show any problems, showing the ability to capture and locate the e-puck located in anywhere in the field of vision of the cameras. In addition, the vision system was able to capture and locate the e-puck as it moved. There was no loss of positional accuracy as compared to previous implementations of identification systems. The recognition of the e-puck by the machine vision localization system displayed the stability of the LED boards with the vision system, further supporting their implementation for further experiments.&lt;br /&gt;
&lt;br /&gt;
===Center of Mass Problem with LEDs===&lt;br /&gt;
Another problem with the implementation of the LED pattern boards is related to the method that the machine vision localization system generates a position of a puck. Originally, the vision system determines the center of the mass of the paper dice dot patterns (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039;), and calculates the world position coordinate using the calibration information. From this, the vision system then assigns &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; as the center of mass of the e-puck (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;). While &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is typically not located over &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, the paper dots location was shifted in order to match &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, this is not achievable with the LED pattern boards. As LED pattern board&#039;s location on the e-puck cannot be shifted, the vision system needs to be able to shift &#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to accommodate for this position error. By augmenting the &#039;&#039;&#039;target_classifiers.txt&#039;&#039;&#039; file with additional data, the modified vision system refers to a look-up table in order to determine the amount and direction that the coordinates of center of mass of the LED dots (&#039;&#039;&#039;R&amp;lt;sub&amp;gt;LEDs&amp;lt;/sub&amp;gt;&#039;&#039;&#039;) needs to be shifted to align with &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. The look-up table contains values that are unique and constant to each rotationally invariant pattern, and as a result, only a few simple calculations are needed to generate correct coordinates for the e-puck.&lt;br /&gt;
&lt;br /&gt;
The result is the vision system yields a much more accurate position data for the e-puck. A simple test, which consists of rotating the e-puck around the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; shows that the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by roughly 4-5mm when using the RGB modified code. Using the original Machine Vision Localization System code, the coordinate data for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; varies by much more, between 40-50mm. Note that the only difference between these two tests, is the application of code to shift the &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; back into place; otherwise both sets of code are changed to accommodate the LED pattern boards, which were used in this test.&lt;br /&gt;
&lt;br /&gt;
====Addition to the Original Code====&lt;br /&gt;
There are only a few minor changes in the code from the original machine vision code to the RGB machine vision code. The change focused around the introduction of &#039;&#039;&#039;centermag&#039;&#039;&#039; and &#039;&#039;&#039;centeroffset&#039;&#039;&#039;, two new variables. &#039;&#039;&#039;Centermag&#039;&#039;&#039; refers to the magnitude from the vision system calculated &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. This value differs from e-puck to e-puck, the the value remains constant for each e-puck regardless of orientation. &#039;&#039;&#039;Centeroffset&#039;&#039;&#039; refers to the angle offset between the vision system calculated angle, and the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;. Again, this value differs from e-puck to e-puck, and also remains constant for each e-puck regardless of orientation.&lt;br /&gt;
&lt;br /&gt;
The actual code which shifts the coordinate data from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to the desired &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is simple.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;main.cpp&#039;&#039;&#039; of &#039;&#039;&#039;RGBVisionTracking.proj&#039;&#039;&#039;, the code is as follows:&lt;br /&gt;
&lt;br /&gt;
 line &#039;&#039;&#039;1082&#039;&#039;&#039; through line &#039;&#039;&#039;1109&#039;&#039;&#039;&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wx = targets_temp[camerai]-&amp;gt;group.wx + -1*targets_temp[camerai]-&amp;gt;centermag*cos(Adjusted);&lt;br /&gt;
 targets_temp[camerai]-&amp;gt;group.wy = targets_temp[camerai]-&amp;gt;group.wy + -1*targets_temp[camerai]-&amp;gt;centermag*sin(Adjusted);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adjusted&#039;&#039;&#039; is the center offset angle plus the orientation angle, or &#039;&#039;&#039;centeroffset + angle&#039;&#039;&#039;, which results is the angle of the line from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;, from zero degrees. With knowledge of this angle, a simply trigonometry problem is performed to determine the x and y values to add/subtract from &#039;&#039;&#039;R&amp;lt;sub&amp;gt;dots&amp;lt;/sub&amp;gt;&#039;&#039;&#039; to get coordinates for &#039;&#039;&#039;R&amp;lt;sub&amp;gt;e-puck&amp;lt;/sub&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The values for centermag and centeroffset are found in the txt file, &#039;&#039;&#039;target_classifiers_augmented&#039;&#039;&#039;, as the fourth and fifth values, respectively. This file can be round in the modified code zip file above.&lt;br /&gt;
&lt;br /&gt;
===Other Considerations===&lt;br /&gt;
While there do not need to be any additional changes to the set up of the machine vision localization system, there may be additional considerations for further development.  One such consideration is the &#039;background&#039;, or floor material, of the setup. With the modified machine vision code, light intensity is what is picked up and filtered by the system, thus rendering the LEDs from the e-pucks to be the only tracked objects. However, with more advanced set ups, such as one featuring light that is projected onto the background, this may present a problem with the machine vision system picking up reflected light. More testing has to be done with modifying the machine vision system threshold to see if there is an ideal threshold to accommodate this setup. Another option may be to use a non-reflective or matte surface for the background.&lt;br /&gt;
&lt;br /&gt;
Another consideration involves the hardware of the setup, or the themselves. The cameras are equipped with the Logitech software which automatically adjusts the exposure and light contrast settings to correct for poor lighting and setup conditions. However, this leads to issues as with increased exposure (due to light blocking set up) and bright LEDs results in blurry or blobby images received. The machine vision localization system cannot read these images, and as a result cannot track the e-pucks. One potential solution may be to adjust the threshold of the vision system. Other solutions may be to use LEDs with a lower millicandela, or increase the background lighting of the setup, for instance with upward casting lights.&lt;br /&gt;
&lt;br /&gt;
==RGB Swarm E-puck Code Overview==&lt;br /&gt;
Detailed code outline: [[Swarm RGB E-puck Code]]&lt;br /&gt;
&lt;br /&gt;
==MATLAB Code for RGB Swarm Robot Project==&lt;br /&gt;
&lt;br /&gt;
*[[Media:RGB_Swarm_MATLAB_09-03-09.zip|&#039;&#039;&#039;RGB_Swarm_MATLAB_09-03-09.zip&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
====What to do with the files:====&lt;br /&gt;
* &#039;&#039;&#039;open_serial.m:&#039;&#039;&#039; Change the COM call to whatever COM port your XBee radio is plugged into (COM1, COM2, ...). Run this to open the COM port before you run anything else. It will create a COM object in your workspace. It takes a long time, be patient.&lt;br /&gt;
* &#039;&#039;&#039;close_serial.m:&#039;&#039;&#039; Run after you&#039;re done to close the COM port. Keeps matlab and your computer happy.&lt;br /&gt;
* &#039;&#039;&#039;RGB_Swarm_Data_Grabber.m:&#039;&#039;&#039; Use this to plot the values from the RGB sensor of one puck. It shows a moving plot. Handy for testing.&lt;br /&gt;
* &#039;&#039;&#039;RGB_avg_std_logger.m:&#039;&#039;&#039; Interactive point logger. Follow the prompts to grab some nice data. Useful for testing.&lt;br /&gt;
* &#039;&#039;&#039;color_hist.m:&#039;&#039;&#039; Plot a histogram from RGB_Swarm_Data_Grabber.&lt;br /&gt;
&lt;br /&gt;
==Physical Setup==&lt;br /&gt;
In the RGB swarm robot project, the epucks pick up light from a projector. This projector has to project onto the floor so that the top mounted light sensors can pick up the light. The floor which the epucks roll on must be completely enclosed so that the only light which reaches it, is the light from the projector. Also this floor must be smooth, flat and durable. See the overhead view below.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:RGBswarmsetup.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Curtains===&lt;br /&gt;
The floor is enclosed by two walls and 6 curtains. Two bars protrude from the walls and are connected by an L-joint. There are 3 Eclipse absolute zero curtains on each bar (see diagram). These curtains block 100% light and are sewn together so that no light comes through between them. Covering the whole enclosure, above the projector mount are 7 more curtains sewn together to block all light. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Floor===&lt;br /&gt;
The floor is currently a vinyl sheet from home depot. The sheet had a raised pattern on the front, so it was flipped over. The underside of the vinyl floor is not very durable, but holds up as long as no shoes are used when stepping on it. In the future, a more durable light colored floor may want to be used. Also, the floor is taped down with packing tape. The tape should not be removed as the floor has markings which show where the camera calibration dots should go and where the projected image should fall.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Projector===&lt;br /&gt;
The projector is a Benq MP771 DLP prpjector. It has a digital user manual on a CD in the projection computer. &lt;br /&gt;
&lt;br /&gt;
Since it is DLP, it has an array of tiny mirrors which reflect the light from the bulb. The light from the bulb is shown through a color wheel which shines red, green, and blue on to the mirror array. The frequency with which the mirrors turn on and off (reflect light and don&#039;t) determines the intensity of light. For example if a dark red was being projected, the mirrors would be on more than off in a certain interval. In the case of our projector that interval is 8.2 millisecond. See the pulse width modulation below.&lt;br /&gt;
&lt;br /&gt;
Each mirror represents a different pixel projected from the projector. This projector has a resolution of 1024 x 768, so in order to get a 1 to 1 pixel ratio, the projection computer should be set to display at 1024 x 768. &lt;br /&gt;
&lt;br /&gt;
As detailed in the user manual, the projector should not be tilted forward or backward more that 15°. Because of this and the wide throw of the projector, a keystone projection shape could not be avoided on the floor. The projector is currently set to compensate for the maximum amount of keystone. &lt;br /&gt;
&lt;br /&gt;
The size of the projected image is currently 113.25&amp;quot; x 76.5&amp;quot; or (in mm).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Projector PWM Waveform====&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:Projector-waveform-longtime.jpg|200px|thumb|alt=Waveform from the color sensor under projector light (long timescale)|Waveform from the color sensor under projector light (long timescale)]]&lt;br /&gt;
| [[Image:Red-high-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected high value red|Waveform from the color sensor under projected high value red]]&lt;br /&gt;
| [[Image:Red-med-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected medium value red|Waveform from the color sensor under projected medium value red]]&lt;br /&gt;
| [[Image:Red-low-value.jpg|200px|thumb|alt=Waveform from the color sensor under projected low value red|Waveform from the color sensor under projected low value red]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
The projector pulse width modulates the color output. So you need to average the measured intensity over the period of the projector to measure the color. The period of the projector is 8.2ms.&lt;br /&gt;
&lt;br /&gt;
===Projector Mount===&lt;br /&gt;
The projector mount was ordered online using 80/20®. The order form complete with the parts for the mount is here [https://docs.google.com/a/u.northwestern.edu/gview?a=v&amp;amp;pid=gmail&amp;amp;attid=0.1&amp;amp;thid=1227a8bb603d85e5&amp;amp;mt=application%2Fpdf&amp;amp;url=https%3A%2F%2Fmail.google.com%2Fa%2Fu.northwestern.edu%2F%3Fui%3D2%26ik%3D81c0708ccd%26view%3Datt%26th%3D1227a8bb603d85e5%26attid%3D0.1%26disp%3Dattd%26zw&amp;amp;sig=AHBy-hZJxFDToenWNtF3J9ym_QrcbepVbQ&amp;amp;AuthEventSource=SSO]. The mount is highly adjustable so that the projector can be mounted at any angle and height. The cameras are mounted so that they cover the entire projected area. The cameras overlap by one object described in the camera calibration routine.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left&amp;quot; cellpadding = &amp;quot;25&amp;quot; &lt;br /&gt;
! [[Image:Projector_Camera Mount.png.jpg|600px|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&#039;&#039;&#039;Conclusion&#039;&#039;&#039;==&lt;br /&gt;
&lt;br /&gt;
The new XBee Interface Extension Board design was tested, and we found out that it does not have any problem. In addition, the black dot pattern of the e-pucks are upgraded to LED patterns. The advantage of this improvement is that the machine vision system can recoginize each e-puck no matter where the e-pucks are located. The color of the background also does not affect the vision system. However, we had to move the color sensor to the LED pattern board since the LED pattern board will block the sensor if the sensor is located in the XBee Interface Extension Board. Thus, we now consider the light interference between the LEDs and the color sensor. In the light interference test, we found out that the color sensor is affected by the light from LED. However, since we used much brighter LEDs in our light interference test than the LEDs used for the LED pattern board, we have to do more experiment on this in order to have more accurate interference data. &lt;br /&gt;
&lt;br /&gt;
==Future Work and To Do==&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14406</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14406"/>
		<updated>2009-09-10T21:02:30Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|&#039;&#039;&#039;RGB Swarm Robot Project&#039;&#039;&#039;]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the blue is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Additional Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14405</id>
		<title>RGB Swarm Robot Project E-puck Code (outdated)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14405"/>
		<updated>2009-09-10T21:01:45Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* void calibrate_color(void) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the e-puck code for the RGB Sensing Swarm Robotics project. The code on the e-puck was written in C and compiled using Microchip&#039;s MPLAB C Compiler for dsPIC DSCs (student version). &lt;br /&gt;
&lt;br /&gt;
This code is a branch of the [[Swarm Project E-puck Code]].&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===Complete===&lt;br /&gt;
* Got ADC working for color sensor&lt;br /&gt;
** Set up filtering to address projector PWM&lt;br /&gt;
* Restructured code to make more modular.&lt;br /&gt;
** Split dsPIC_XBeePackets and wheel_speed_coordinator into h and c files&lt;br /&gt;
** Pulled packet assembling code out of main and created send_packet() function in send_packet.h/c.&lt;br /&gt;
** Pulled a bunch of variables and defines (&#039;&#039;NUM_DATA_SETS, NUMBERS_PER_SET, DATATYPE_BYTELENGTH , DATA_ARRAY_LENGTH , ADDITIONAL_NUMS, notRTS, T1_INT_FLAG, x_i, u_i, w_i, x_sum, w_sum, MAX_WHEEL_V_TICKS, deadband, COMMR, SAFEDIST, MINDIST, u_x_ideal, u_y_ideal, x_motion_integral, y_motion_integral, SQUARE&#039;&#039;) that were scattered across h files into global_vars.h/c. Makes it easy to include them in a particular file with the &#039;&#039;extern&#039;&#039; keyword.&lt;br /&gt;
* Added color_cal() function in color_cal.h/c&lt;br /&gt;
* Added wheelSpeedSingleBot to wheel_speed_coordinator&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
* Finish color calibration (color_cal) program, to facilitate simple calibration for each e-puck that does not require large amount of data collected for each run, and with minimal user input/control (desire automation and simplification)&lt;br /&gt;
* Improve the vision system position information updater&lt;br /&gt;
** So that the e-puck does not automatically assume every packet from the Vision System is true, rather &#039;checks&#039; for accuracy&lt;br /&gt;
* Replace wheelSpeedSingleBot with the three step move controller from NUtest.c&lt;br /&gt;
**Implement this so that the e-puck can be moved with position and orientation (this is ideal so that data from every orientation of the e-puck can be recorded while calibrating or collecting data&lt;br /&gt;
* Implement new algorithm from paper&lt;br /&gt;
&lt;br /&gt;
==Project Package==&lt;br /&gt;
The source code for the project is available here: [[Media:RGB_Swarm_Puck_Code_working_version.zip]]. Open swarm_epucks.mcw and you should be good to go.&lt;br /&gt;
&lt;br /&gt;
==Description of the files and functions==&lt;br /&gt;
&lt;br /&gt;
===global_vars(.c/.h)===&lt;br /&gt;
* .c/.h: declare and define global variables and macros&lt;br /&gt;
====Packet Length Constants====&lt;br /&gt;
These variables determine the length of the XBee packets.  See [[Swarm_Robot_Project_Documentation#Data_Frame|Data Frame]] and the section on XBee API packets in the XBee manual for further clarification.&lt;br /&gt;
&lt;br /&gt;
Much of this is still sending integral consensus estimator data. This can be removed or replaces with data needed for decentralized color sensing. &lt;br /&gt;
&lt;br /&gt;
=====#define NUM_DATA_SETS 5 =====	&lt;br /&gt;
Number of statistics on which you are running the consensus estimator.  This this particular case, 5. (Ix, Iy, Ixx, Ixy, Iyy)&lt;br /&gt;
&lt;br /&gt;
=====#define NUMBERS_PER_SET 2=====&lt;br /&gt;
Number of variables in each data set (see above) that the consensus estimator needs to transmit to other agents.  In this case, 2 because there is &amp;lt;tt&amp;gt;x_i&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;w_i&amp;lt;/tt&amp;gt; for each statistic.&lt;br /&gt;
&lt;br /&gt;
=====#define DATATYPE_BYTELENGTH 4	=====&lt;br /&gt;
Number of bytes in the data type (used in the consensus estimator (float = 4 bytes long).  This is important because we need to split the numbers into individual bytes to be able to send them out the serial port.&lt;br /&gt;
&lt;br /&gt;
=====#define DATA_ARRAY_LENGTH (NUM_DATA_SETS*NUMBERS_PER_SET)=====&lt;br /&gt;
Total number of data variables needed for the consensus estimator.  In this case, it is 5*2=10.&lt;br /&gt;
&lt;br /&gt;
=====#define ADDITIONAL_NUMS 8=====&lt;br /&gt;
Additional number of data to be appended to data array.  It is 5 in this case, so that we can append &lt;br /&gt;
# Robot X coordinate&lt;br /&gt;
# Robot Y coordinate&lt;br /&gt;
# Robot Theta orientation&lt;br /&gt;
# Robot left wheel speed&lt;br /&gt;
# Robot right wheel speed&lt;br /&gt;
# Sensor Red Value&lt;br /&gt;
# Sensor Green Value&lt;br /&gt;
# Sensor Blue Value&lt;br /&gt;
&lt;br /&gt;
===main(.c/.h)===&lt;br /&gt;
* .c: This contains the entry point of the code and contains the initialization routines, main loop, and interrupt service routines. &lt;br /&gt;
* .h: Contains variables, function prototypes, and delay function needed for main.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _T1Interrupt(void)=====&lt;br /&gt;
Timer1 ISR. Sets T1_INT_FLAG which provides timing for the main loop.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void)=====&lt;br /&gt;
UART2 receive ISR. Runs with the XBee receives packets. The switch/case structure handles the packets.&lt;br /&gt;
&lt;br /&gt;
The current handling of coordinate data from the vision system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
case 0: //coordinate data&lt;br /&gt;
					e_set_configuration(&lt;br /&gt;
					InPacket.data[1].dataFloat,&lt;br /&gt;
					InPacket.data[2].dataFloat, &lt;br /&gt;
					InPacket.data[3].dataFloat);&lt;br /&gt;
					break;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====TO DO=====&lt;br /&gt;
Needs to be improved. Suggested new function:&lt;br /&gt;
* Get vision system data&lt;br /&gt;
* Check if it&#039;s wildly off from current puck estimate&lt;br /&gt;
** If not, update, clear log of rejected packets&lt;br /&gt;
** If so, reject and log&lt;br /&gt;
*** If we have rejected enough packets (some threshold) and they&#039;ve all been in similar place (within tolerance), we can assume the puck is wrong and vision system is right. In this case, update with vision system data and clear rejected data log.&lt;br /&gt;
&lt;br /&gt;
=====int main(void)=====&lt;br /&gt;
Setup functions and main loop.&lt;br /&gt;
&lt;br /&gt;
===color_cal(.c/.h)===&lt;br /&gt;
* .c: Contains void calibrate_color(void) function to run the calibration routine.&lt;br /&gt;
* .h: Contains function prototype and constant definitions for calibrate_color.&lt;br /&gt;
&lt;br /&gt;
=====void calibrate_color(void)=====&lt;br /&gt;
This function runs the color calibration routine. Eventually this should be turned into a separate e-puck command from the vision system. Currently it just runs the puck through a zig zag pattern on the floor and sends packets. You can collect these with the data logger and process them in matlab. From this, you should be able to get a calibration function.&lt;br /&gt;
&lt;br /&gt;
=====TO DO=====&lt;br /&gt;
* Add to the pattern. Need to collect more data.&lt;br /&gt;
* Possibly have the puck store data, find a best fit, and create the calibration function on board.&lt;br /&gt;
* Store the calibration function in the EEPROM (flash memory) so it&#039;s non-volatile. The coefficients of function will be specific to each puck, so it would be nice to not have to program each puck, each time you change the battery.&lt;br /&gt;
&lt;br /&gt;
===dsPIC_XBeePackets(.c/.h)===&lt;br /&gt;
* .c/.h: Contains functions and data structures for assembling and receiving XBee packets.&lt;br /&gt;
&lt;br /&gt;
=====int readPacket( void)=====&lt;br /&gt;
Parses XBee data from UART2. Makes it accessable in the &#039;&#039;InPacket&#039;&#039; struct.&lt;br /&gt;
&lt;br /&gt;
The UART2 receive ISR takes error codes from this function and flashes the corresponding puck LED (absolute value of the error code).&lt;br /&gt;
&lt;br /&gt;
Error codes are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	//////////////ERROR CODES/////////////////&lt;br /&gt;
	// &lt;br /&gt;
	// -1: Timeout waiting for UART2&lt;br /&gt;
	// -2: Start delimiter wrong&lt;br /&gt;
	// -3: Checksum Error&lt;br /&gt;
	// -4: UART2 not ready at beginning&lt;br /&gt;
	// -5: API_ID unidentified&lt;br /&gt;
	// -6: Send Packet CCA failuue&lt;br /&gt;
	// -7: Modem Status packet failure&lt;br /&gt;
	//////////////////////////////////////////&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===send_packet(.c/.h)===&lt;br /&gt;
* .c: Contains the void send_packet(void) function which fills an array with data and calls the needed XBee functions to send a packet.&lt;br /&gt;
* .h: Contains function prototype.&lt;br /&gt;
&lt;br /&gt;
=====void send_packet(void)=====&lt;br /&gt;
* Creates &#039;&#039;packet&#039;&#039; array.&lt;br /&gt;
* Adds consensus estimator data to the array.&lt;br /&gt;
* Adds robot statistics to the array.&lt;br /&gt;
* Adds color sensor values to the array.&lt;br /&gt;
* Asserts flow control line to stop XBee from sending&lt;br /&gt;
* Calls assemblePacket to send the packet.&lt;br /&gt;
* Deasserts flow control; Xbee can send again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function e_get_acc_filtered returns a running average of the acc specified. Syntax is:&lt;br /&gt;
&lt;br /&gt;
return value = e_get_acc_filtered(acc_channel, number of samples to average)&lt;br /&gt;
&lt;br /&gt;
The number of samples averaged must be less than ACC_SAMP_NB as defined in e_ad_conv.h.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
packet[i]=e_get_acc_filtered(2, 136); // red&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(1, 136); // green&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(0, 136); // blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PI_consensus_estimator(.h)===&lt;br /&gt;
* .h: Contains functions and data structures for the PI consensus estimator. &lt;br /&gt;
* This will probably be replaced by the algorithm for sensor consensus. &lt;br /&gt;
&lt;br /&gt;
===wheel_speed_coordinator(.c/.h)===&lt;br /&gt;
* .c: Contains functions for robot motion control&lt;br /&gt;
* .h: Function prototypes and variabls.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeed(int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speeds for the inertial consensus estimator based on the group goal.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeedSingleBot(float gotox, float gotoy, int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speed to get this individual bot to (gotox, gotoy). It&#039;s a hacked fix. Should be replaced with the 3 step motion controller from NUtest.c.&lt;br /&gt;
&lt;br /&gt;
===e_acc(.c/.h)===&lt;br /&gt;
* .c: Functions for reading the accelerometers (which is the color sensor).&lt;br /&gt;
* .h: Function prototypes.&lt;br /&gt;
&lt;br /&gt;
This is original e-puck library code with the following modifications:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
//changed by Sam, July 10, default offset is 2000. we want 0 for RGB sensor.&lt;br /&gt;
static int centre_z = 0;			//zero value for z axe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====int e_get_acc_filtered(unsigned int captor, unsigned int filter_size)=====&lt;br /&gt;
&lt;br /&gt;
===e_ad_conv(.c/.h)===&lt;br /&gt;
Set up the ADCs on the puck. Original e-puck library code, with the following modifications&lt;br /&gt;
* .h: Define constants and functional prototypes&lt;br /&gt;
&lt;br /&gt;
MIC_SAMP_FREQ sets the baseline sampling frequency for the ADC, everything else must be a fraction of this. 16384 Hz is the highest possible.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MIC_SAMP_FREQ 16384.0	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_PROX_SAMP_FREQ sets the sampling frequency for the accelerometers (color sensor). We found in testing that the puck become non-responsive with this set to 8192 Hz or 16384 Hz.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// sampling frequency for the accelerometres and proximetres&lt;br /&gt;
//#define ACC_PROX_SAMP_FREQ 256.0	// WARNING: should be a fraction of MIC_SAMP_FREQ&lt;br /&gt;
#define ACC_PROX_SAMP_FREQ 4096	//			to ensure a good timing precision&lt;br /&gt;
									// So your options are: 1  2  4  8  16  32  64  128  &lt;br /&gt;
									//  256  512  1024  2048  4096  8192  16384&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_SAMP_NB is the number of samples to store. We can do an average of &#039;&#039;up to&#039;&#039; this many samples. This is set to 140 so we can average 136 samples, which is 4 projector periods.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ACC_SAMP_NB  140	// number of accelerometer samples to store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* .c: Functions and interrupt service routines for ADCs. Original e-puck library, no modifications.&lt;br /&gt;
&lt;br /&gt;
=====e_init_ad_scan(ALL_ADC)=====&lt;br /&gt;
Call to setup ADC and have it work in the background. Use e_acc functions to access data.&lt;br /&gt;
&lt;br /&gt;
===e_init_port(.c/.h)===&lt;br /&gt;
* .c/.h: Initializes the ports on the e-puck. File is from the standard e-puck library. &lt;br /&gt;
&lt;br /&gt;
=====e_init_ports(void)=====&lt;br /&gt;
This function sets up ports on the e-puck. Call before using any ports.&lt;br /&gt;
&lt;br /&gt;
===e_led(.c/.h)===&lt;br /&gt;
* .c/.h: This is a standard e-puck library file that contains functions for manipulating LEDs.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_led(unsigned int led_number, unsigned int value)=====&lt;br /&gt;
Set led_number (0-7) to value (0=off 1=on higher=inverse).&lt;br /&gt;
&lt;br /&gt;
[[Image:e-puck_LED_numbering.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&#039;all&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===e_motors_swarm(.c/.h)===&lt;br /&gt;
* .c/.h: This file is a modified version of the e_motors.h e-puck library file.  This version keeps track of the robot&#039;s position and orientation, and the motor stepping function contains code to update the robot&#039;s position when the wheels turn. &lt;br /&gt;
* The functions like e_rotate and e_translate have been removed and this version is not dependent on e_agenda. &lt;br /&gt;
&lt;br /&gt;
=====#define POINT_OFFSET -31.75 =====&lt;br /&gt;
In addition to constants like wheel radius and wheel base, the offset between the center point of the bot and the point we&#039;re driving is set in e_motors_swarm.h. -31.75 mm is the distance betwene the center and the color sensor. So technically, we&#039;re driving backwards.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T5Interrupt(void)=====&lt;br /&gt;
Timer5 ISR, interrupt for left motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
    xpos = xpos + cval*LINSTEP;&lt;br /&gt;
    ypos = ypos + sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T4Interrupt(void)=====&lt;br /&gt;
Timer4 ISR, interrupt for right motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
	xpos = xpos - cval*LINSTEP;&lt;br /&gt;
    ypos = ypos - sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void e_init_motors(void)=====&lt;br /&gt;
Call this function before other motor functions to initialize the motors.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_speed_left(int motor_speed)/void e_set_speed_right(int motor_speed)=====&lt;br /&gt;
Set the motor speed in steps/second.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the center reference point.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_configuration(float x, float y, float theta)=====&lt;br /&gt;
Sets x, y, theta to values. This is used to overwrite the puck position/orientation estimates with data from the vision system.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration_front(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the front reference point (used for motor control).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;br /&gt;
[[Category:e-puck]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14404</id>
		<title>RGB Swarm Robot Project E-puck Code (outdated)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14404"/>
		<updated>2009-09-10T21:01:15Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* To Do */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the e-puck code for the RGB Sensing Swarm Robotics project. The code on the e-puck was written in C and compiled using Microchip&#039;s MPLAB C Compiler for dsPIC DSCs (student version). &lt;br /&gt;
&lt;br /&gt;
This code is a branch of the [[Swarm Project E-puck Code]].&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===Complete===&lt;br /&gt;
* Got ADC working for color sensor&lt;br /&gt;
** Set up filtering to address projector PWM&lt;br /&gt;
* Restructured code to make more modular.&lt;br /&gt;
** Split dsPIC_XBeePackets and wheel_speed_coordinator into h and c files&lt;br /&gt;
** Pulled packet assembling code out of main and created send_packet() function in send_packet.h/c.&lt;br /&gt;
** Pulled a bunch of variables and defines (&#039;&#039;NUM_DATA_SETS, NUMBERS_PER_SET, DATATYPE_BYTELENGTH , DATA_ARRAY_LENGTH , ADDITIONAL_NUMS, notRTS, T1_INT_FLAG, x_i, u_i, w_i, x_sum, w_sum, MAX_WHEEL_V_TICKS, deadband, COMMR, SAFEDIST, MINDIST, u_x_ideal, u_y_ideal, x_motion_integral, y_motion_integral, SQUARE&#039;&#039;) that were scattered across h files into global_vars.h/c. Makes it easy to include them in a particular file with the &#039;&#039;extern&#039;&#039; keyword.&lt;br /&gt;
* Added color_cal() function in color_cal.h/c&lt;br /&gt;
* Added wheelSpeedSingleBot to wheel_speed_coordinator&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
* Finish color calibration (color_cal) program, to facilitate simple calibration for each e-puck that does not require large amount of data collected for each run, and with minimal user input/control (desire automation and simplification)&lt;br /&gt;
* Improve the vision system position information updater&lt;br /&gt;
** So that the e-puck does not automatically assume every packet from the Vision System is true, rather &#039;checks&#039; for accuracy&lt;br /&gt;
* Replace wheelSpeedSingleBot with the three step move controller from NUtest.c&lt;br /&gt;
**Implement this so that the e-puck can be moved with position and orientation (this is ideal so that data from every orientation of the e-puck can be recorded while calibrating or collecting data&lt;br /&gt;
* Implement new algorithm from paper&lt;br /&gt;
&lt;br /&gt;
==Project Package==&lt;br /&gt;
The source code for the project is available here: [[Media:RGB_Swarm_Puck_Code_working_version.zip]]. Open swarm_epucks.mcw and you should be good to go.&lt;br /&gt;
&lt;br /&gt;
==Description of the files and functions==&lt;br /&gt;
&lt;br /&gt;
===global_vars(.c/.h)===&lt;br /&gt;
* .c/.h: declare and define global variables and macros&lt;br /&gt;
====Packet Length Constants====&lt;br /&gt;
These variables determine the length of the XBee packets.  See [[Swarm_Robot_Project_Documentation#Data_Frame|Data Frame]] and the section on XBee API packets in the XBee manual for further clarification.&lt;br /&gt;
&lt;br /&gt;
Much of this is still sending integral consensus estimator data. This can be removed or replaces with data needed for decentralized color sensing. &lt;br /&gt;
&lt;br /&gt;
=====#define NUM_DATA_SETS 5 =====	&lt;br /&gt;
Number of statistics on which you are running the consensus estimator.  This this particular case, 5. (Ix, Iy, Ixx, Ixy, Iyy)&lt;br /&gt;
&lt;br /&gt;
=====#define NUMBERS_PER_SET 2=====&lt;br /&gt;
Number of variables in each data set (see above) that the consensus estimator needs to transmit to other agents.  In this case, 2 because there is &amp;lt;tt&amp;gt;x_i&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;w_i&amp;lt;/tt&amp;gt; for each statistic.&lt;br /&gt;
&lt;br /&gt;
=====#define DATATYPE_BYTELENGTH 4	=====&lt;br /&gt;
Number of bytes in the data type (used in the consensus estimator (float = 4 bytes long).  This is important because we need to split the numbers into individual bytes to be able to send them out the serial port.&lt;br /&gt;
&lt;br /&gt;
=====#define DATA_ARRAY_LENGTH (NUM_DATA_SETS*NUMBERS_PER_SET)=====&lt;br /&gt;
Total number of data variables needed for the consensus estimator.  In this case, it is 5*2=10.&lt;br /&gt;
&lt;br /&gt;
=====#define ADDITIONAL_NUMS 8=====&lt;br /&gt;
Additional number of data to be appended to data array.  It is 5 in this case, so that we can append &lt;br /&gt;
# Robot X coordinate&lt;br /&gt;
# Robot Y coordinate&lt;br /&gt;
# Robot Theta orientation&lt;br /&gt;
# Robot left wheel speed&lt;br /&gt;
# Robot right wheel speed&lt;br /&gt;
# Sensor Red Value&lt;br /&gt;
# Sensor Green Value&lt;br /&gt;
# Sensor Blue Value&lt;br /&gt;
&lt;br /&gt;
===main(.c/.h)===&lt;br /&gt;
* .c: This contains the entry point of the code and contains the initialization routines, main loop, and interrupt service routines. &lt;br /&gt;
* .h: Contains variables, function prototypes, and delay function needed for main.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _T1Interrupt(void)=====&lt;br /&gt;
Timer1 ISR. Sets T1_INT_FLAG which provides timing for the main loop.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void)=====&lt;br /&gt;
UART2 receive ISR. Runs with the XBee receives packets. The switch/case structure handles the packets.&lt;br /&gt;
&lt;br /&gt;
The current handling of coordinate data from the vision system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
case 0: //coordinate data&lt;br /&gt;
					e_set_configuration(&lt;br /&gt;
					InPacket.data[1].dataFloat,&lt;br /&gt;
					InPacket.data[2].dataFloat, &lt;br /&gt;
					InPacket.data[3].dataFloat);&lt;br /&gt;
					break;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====TO DO=====&lt;br /&gt;
Needs to be improved. Suggested new function:&lt;br /&gt;
* Get vision system data&lt;br /&gt;
* Check if it&#039;s wildly off from current puck estimate&lt;br /&gt;
** If not, update, clear log of rejected packets&lt;br /&gt;
** If so, reject and log&lt;br /&gt;
*** If we have rejected enough packets (some threshold) and they&#039;ve all been in similar place (within tolerance), we can assume the puck is wrong and vision system is right. In this case, update with vision system data and clear rejected data log.&lt;br /&gt;
&lt;br /&gt;
=====int main(void)=====&lt;br /&gt;
Setup functions and main loop.&lt;br /&gt;
&lt;br /&gt;
===color_cal(.c/.h)===&lt;br /&gt;
* .c: Contains void calibrate_color(void) function to run the calibration routine.&lt;br /&gt;
* .h: Contains function prototype and constant definitions for calibrate_color.&lt;br /&gt;
&lt;br /&gt;
=====void calibrate_color(void)=====&lt;br /&gt;
This function runs the color calibration routine. Eventually this should be turned into a separate e-puck command from the vision system. Currently it just runs the puck through a zig zag pattern on the floor and sends packets. You can collect these with the data logger and process them in matlab. From this, you should be able to get a calibration function.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To do:&#039;&#039;&#039;&lt;br /&gt;
* Add to the pattern. Need to collect more data.&lt;br /&gt;
* Possibly have the puck store data, find a best fit, and create the calibration function on board.&lt;br /&gt;
* Store the calibration function in the EEPROM (flash memory) so it&#039;s non-volatile. The coefficients of function will be specific to each puck, so it would be nice to not have to program each puck, each time you change the battery.&lt;br /&gt;
&lt;br /&gt;
===dsPIC_XBeePackets(.c/.h)===&lt;br /&gt;
* .c/.h: Contains functions and data structures for assembling and receiving XBee packets.&lt;br /&gt;
&lt;br /&gt;
=====int readPacket( void)=====&lt;br /&gt;
Parses XBee data from UART2. Makes it accessable in the &#039;&#039;InPacket&#039;&#039; struct.&lt;br /&gt;
&lt;br /&gt;
The UART2 receive ISR takes error codes from this function and flashes the corresponding puck LED (absolute value of the error code).&lt;br /&gt;
&lt;br /&gt;
Error codes are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	//////////////ERROR CODES/////////////////&lt;br /&gt;
	// &lt;br /&gt;
	// -1: Timeout waiting for UART2&lt;br /&gt;
	// -2: Start delimiter wrong&lt;br /&gt;
	// -3: Checksum Error&lt;br /&gt;
	// -4: UART2 not ready at beginning&lt;br /&gt;
	// -5: API_ID unidentified&lt;br /&gt;
	// -6: Send Packet CCA failuue&lt;br /&gt;
	// -7: Modem Status packet failure&lt;br /&gt;
	//////////////////////////////////////////&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===send_packet(.c/.h)===&lt;br /&gt;
* .c: Contains the void send_packet(void) function which fills an array with data and calls the needed XBee functions to send a packet.&lt;br /&gt;
* .h: Contains function prototype.&lt;br /&gt;
&lt;br /&gt;
=====void send_packet(void)=====&lt;br /&gt;
* Creates &#039;&#039;packet&#039;&#039; array.&lt;br /&gt;
* Adds consensus estimator data to the array.&lt;br /&gt;
* Adds robot statistics to the array.&lt;br /&gt;
* Adds color sensor values to the array.&lt;br /&gt;
* Asserts flow control line to stop XBee from sending&lt;br /&gt;
* Calls assemblePacket to send the packet.&lt;br /&gt;
* Deasserts flow control; Xbee can send again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function e_get_acc_filtered returns a running average of the acc specified. Syntax is:&lt;br /&gt;
&lt;br /&gt;
return value = e_get_acc_filtered(acc_channel, number of samples to average)&lt;br /&gt;
&lt;br /&gt;
The number of samples averaged must be less than ACC_SAMP_NB as defined in e_ad_conv.h.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
packet[i]=e_get_acc_filtered(2, 136); // red&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(1, 136); // green&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(0, 136); // blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PI_consensus_estimator(.h)===&lt;br /&gt;
* .h: Contains functions and data structures for the PI consensus estimator. &lt;br /&gt;
* This will probably be replaced by the algorithm for sensor consensus. &lt;br /&gt;
&lt;br /&gt;
===wheel_speed_coordinator(.c/.h)===&lt;br /&gt;
* .c: Contains functions for robot motion control&lt;br /&gt;
* .h: Function prototypes and variabls.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeed(int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speeds for the inertial consensus estimator based on the group goal.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeedSingleBot(float gotox, float gotoy, int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speed to get this individual bot to (gotox, gotoy). It&#039;s a hacked fix. Should be replaced with the 3 step motion controller from NUtest.c.&lt;br /&gt;
&lt;br /&gt;
===e_acc(.c/.h)===&lt;br /&gt;
* .c: Functions for reading the accelerometers (which is the color sensor).&lt;br /&gt;
* .h: Function prototypes.&lt;br /&gt;
&lt;br /&gt;
This is original e-puck library code with the following modifications:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
//changed by Sam, July 10, default offset is 2000. we want 0 for RGB sensor.&lt;br /&gt;
static int centre_z = 0;			//zero value for z axe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====int e_get_acc_filtered(unsigned int captor, unsigned int filter_size)=====&lt;br /&gt;
&lt;br /&gt;
===e_ad_conv(.c/.h)===&lt;br /&gt;
Set up the ADCs on the puck. Original e-puck library code, with the following modifications&lt;br /&gt;
* .h: Define constants and functional prototypes&lt;br /&gt;
&lt;br /&gt;
MIC_SAMP_FREQ sets the baseline sampling frequency for the ADC, everything else must be a fraction of this. 16384 Hz is the highest possible.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MIC_SAMP_FREQ 16384.0	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_PROX_SAMP_FREQ sets the sampling frequency for the accelerometers (color sensor). We found in testing that the puck become non-responsive with this set to 8192 Hz or 16384 Hz.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// sampling frequency for the accelerometres and proximetres&lt;br /&gt;
//#define ACC_PROX_SAMP_FREQ 256.0	// WARNING: should be a fraction of MIC_SAMP_FREQ&lt;br /&gt;
#define ACC_PROX_SAMP_FREQ 4096	//			to ensure a good timing precision&lt;br /&gt;
									// So your options are: 1  2  4  8  16  32  64  128  &lt;br /&gt;
									//  256  512  1024  2048  4096  8192  16384&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_SAMP_NB is the number of samples to store. We can do an average of &#039;&#039;up to&#039;&#039; this many samples. This is set to 140 so we can average 136 samples, which is 4 projector periods.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ACC_SAMP_NB  140	// number of accelerometer samples to store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* .c: Functions and interrupt service routines for ADCs. Original e-puck library, no modifications.&lt;br /&gt;
&lt;br /&gt;
=====e_init_ad_scan(ALL_ADC)=====&lt;br /&gt;
Call to setup ADC and have it work in the background. Use e_acc functions to access data.&lt;br /&gt;
&lt;br /&gt;
===e_init_port(.c/.h)===&lt;br /&gt;
* .c/.h: Initializes the ports on the e-puck. File is from the standard e-puck library. &lt;br /&gt;
&lt;br /&gt;
=====e_init_ports(void)=====&lt;br /&gt;
This function sets up ports on the e-puck. Call before using any ports.&lt;br /&gt;
&lt;br /&gt;
===e_led(.c/.h)===&lt;br /&gt;
* .c/.h: This is a standard e-puck library file that contains functions for manipulating LEDs.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_led(unsigned int led_number, unsigned int value)=====&lt;br /&gt;
Set led_number (0-7) to value (0=off 1=on higher=inverse).&lt;br /&gt;
&lt;br /&gt;
[[Image:e-puck_LED_numbering.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&#039;all&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===e_motors_swarm(.c/.h)===&lt;br /&gt;
* .c/.h: This file is a modified version of the e_motors.h e-puck library file.  This version keeps track of the robot&#039;s position and orientation, and the motor stepping function contains code to update the robot&#039;s position when the wheels turn. &lt;br /&gt;
* The functions like e_rotate and e_translate have been removed and this version is not dependent on e_agenda. &lt;br /&gt;
&lt;br /&gt;
=====#define POINT_OFFSET -31.75 =====&lt;br /&gt;
In addition to constants like wheel radius and wheel base, the offset between the center point of the bot and the point we&#039;re driving is set in e_motors_swarm.h. -31.75 mm is the distance betwene the center and the color sensor. So technically, we&#039;re driving backwards.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T5Interrupt(void)=====&lt;br /&gt;
Timer5 ISR, interrupt for left motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
    xpos = xpos + cval*LINSTEP;&lt;br /&gt;
    ypos = ypos + sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T4Interrupt(void)=====&lt;br /&gt;
Timer4 ISR, interrupt for right motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
	xpos = xpos - cval*LINSTEP;&lt;br /&gt;
    ypos = ypos - sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void e_init_motors(void)=====&lt;br /&gt;
Call this function before other motor functions to initialize the motors.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_speed_left(int motor_speed)/void e_set_speed_right(int motor_speed)=====&lt;br /&gt;
Set the motor speed in steps/second.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the center reference point.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_configuration(float x, float y, float theta)=====&lt;br /&gt;
Sets x, y, theta to values. This is used to overwrite the puck position/orientation estimates with data from the vision system.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration_front(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the front reference point (used for motor control).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;br /&gt;
[[Category:e-puck]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14403</id>
		<title>RGB Swarm Robot Project E-puck Code (outdated)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14403"/>
		<updated>2009-09-10T21:00:50Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Possible improvements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the e-puck code for the RGB Sensing Swarm Robotics project. The code on the e-puck was written in C and compiled using Microchip&#039;s MPLAB C Compiler for dsPIC DSCs (student version). &lt;br /&gt;
&lt;br /&gt;
This code is a branch of the [[Swarm Project E-puck Code]].&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===Complete===&lt;br /&gt;
* Got ADC working for color sensor&lt;br /&gt;
** Set up filtering to address projector PWM&lt;br /&gt;
* Restructured code to make more modular.&lt;br /&gt;
** Split dsPIC_XBeePackets and wheel_speed_coordinator into h and c files&lt;br /&gt;
** Pulled packet assembling code out of main and created send_packet() function in send_packet.h/c.&lt;br /&gt;
** Pulled a bunch of variables and defines (&#039;&#039;NUM_DATA_SETS, NUMBERS_PER_SET, DATATYPE_BYTELENGTH , DATA_ARRAY_LENGTH , ADDITIONAL_NUMS, notRTS, T1_INT_FLAG, x_i, u_i, w_i, x_sum, w_sum, MAX_WHEEL_V_TICKS, deadband, COMMR, SAFEDIST, MINDIST, u_x_ideal, u_y_ideal, x_motion_integral, y_motion_integral, SQUARE&#039;&#039;) that were scattered across h files into global_vars.h/c. Makes it easy to include them in a particular file with the &#039;&#039;extern&#039;&#039; keyword.&lt;br /&gt;
* Added color_cal() function in color_cal.h/c&lt;br /&gt;
* Added wheelSpeedSingleBot to wheel_speed_coordinator&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
* Finish color calibration (color_cal) program, to facilitate simple calibration for each e-puck that does not require large amount of data collected for each run, and with minimal user input/control (desire automation and simplification)&lt;br /&gt;
* Improve the vision system position information updater&lt;br /&gt;
** So that the e-puck does not automatically assume every packet from the Vision System is true, rather &#039;checks&#039; for accuracy&lt;br /&gt;
* Replace wheelSpeedSingleBot with the three step move controller from NUtest.c&lt;br /&gt;
**Implement this so that the e-puck can be moved with position and orientation (this is ideal so that data from every orientation of the e-puck can be recorded while calibrating or collecting data&lt;br /&gt;
* Implement new algorithm from paper&lt;br /&gt;
&lt;br /&gt;
==Project Package==&lt;br /&gt;
The source code for the project is available here: [[Media:RGB_Swarm_Puck_Code_working_version.zip]]. Open swarm_epucks.mcw and you should be good to go.&lt;br /&gt;
&lt;br /&gt;
==Description of the files and functions==&lt;br /&gt;
&lt;br /&gt;
===global_vars(.c/.h)===&lt;br /&gt;
* .c/.h: declare and define global variables and macros&lt;br /&gt;
====Packet Length Constants====&lt;br /&gt;
These variables determine the length of the XBee packets.  See [[Swarm_Robot_Project_Documentation#Data_Frame|Data Frame]] and the section on XBee API packets in the XBee manual for further clarification.&lt;br /&gt;
&lt;br /&gt;
Much of this is still sending integral consensus estimator data. This can be removed or replaces with data needed for decentralized color sensing. &lt;br /&gt;
&lt;br /&gt;
=====#define NUM_DATA_SETS 5 =====	&lt;br /&gt;
Number of statistics on which you are running the consensus estimator.  This this particular case, 5. (Ix, Iy, Ixx, Ixy, Iyy)&lt;br /&gt;
&lt;br /&gt;
=====#define NUMBERS_PER_SET 2=====&lt;br /&gt;
Number of variables in each data set (see above) that the consensus estimator needs to transmit to other agents.  In this case, 2 because there is &amp;lt;tt&amp;gt;x_i&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;w_i&amp;lt;/tt&amp;gt; for each statistic.&lt;br /&gt;
&lt;br /&gt;
=====#define DATATYPE_BYTELENGTH 4	=====&lt;br /&gt;
Number of bytes in the data type (used in the consensus estimator (float = 4 bytes long).  This is important because we need to split the numbers into individual bytes to be able to send them out the serial port.&lt;br /&gt;
&lt;br /&gt;
=====#define DATA_ARRAY_LENGTH (NUM_DATA_SETS*NUMBERS_PER_SET)=====&lt;br /&gt;
Total number of data variables needed for the consensus estimator.  In this case, it is 5*2=10.&lt;br /&gt;
&lt;br /&gt;
=====#define ADDITIONAL_NUMS 8=====&lt;br /&gt;
Additional number of data to be appended to data array.  It is 5 in this case, so that we can append &lt;br /&gt;
# Robot X coordinate&lt;br /&gt;
# Robot Y coordinate&lt;br /&gt;
# Robot Theta orientation&lt;br /&gt;
# Robot left wheel speed&lt;br /&gt;
# Robot right wheel speed&lt;br /&gt;
# Sensor Red Value&lt;br /&gt;
# Sensor Green Value&lt;br /&gt;
# Sensor Blue Value&lt;br /&gt;
&lt;br /&gt;
===main(.c/.h)===&lt;br /&gt;
* .c: This contains the entry point of the code and contains the initialization routines, main loop, and interrupt service routines. &lt;br /&gt;
* .h: Contains variables, function prototypes, and delay function needed for main.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _T1Interrupt(void)=====&lt;br /&gt;
Timer1 ISR. Sets T1_INT_FLAG which provides timing for the main loop.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void)=====&lt;br /&gt;
UART2 receive ISR. Runs with the XBee receives packets. The switch/case structure handles the packets.&lt;br /&gt;
&lt;br /&gt;
The current handling of coordinate data from the vision system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
case 0: //coordinate data&lt;br /&gt;
					e_set_configuration(&lt;br /&gt;
					InPacket.data[1].dataFloat,&lt;br /&gt;
					InPacket.data[2].dataFloat, &lt;br /&gt;
					InPacket.data[3].dataFloat);&lt;br /&gt;
					break;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====To Do=====&lt;br /&gt;
Needs to be improved. Suggested new function:&lt;br /&gt;
* Get vision system data&lt;br /&gt;
* Check if it&#039;s wildly off from current puck estimate&lt;br /&gt;
** If not, update, clear log of rejected packets&lt;br /&gt;
** If so, reject and log&lt;br /&gt;
*** If we have rejected enough packets (some threshold) and they&#039;ve all been in similar place (within tolerance), we can assume the puck is wrong and vision system is right. In this case, update with vision system data and clear rejected data log.&lt;br /&gt;
&lt;br /&gt;
=====int main(void)=====&lt;br /&gt;
Setup functions and main loop.&lt;br /&gt;
&lt;br /&gt;
===color_cal(.c/.h)===&lt;br /&gt;
* .c: Contains void calibrate_color(void) function to run the calibration routine.&lt;br /&gt;
* .h: Contains function prototype and constant definitions for calibrate_color.&lt;br /&gt;
&lt;br /&gt;
=====void calibrate_color(void)=====&lt;br /&gt;
This function runs the color calibration routine. Eventually this should be turned into a separate e-puck command from the vision system. Currently it just runs the puck through a zig zag pattern on the floor and sends packets. You can collect these with the data logger and process them in matlab. From this, you should be able to get a calibration function.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To do:&#039;&#039;&#039;&lt;br /&gt;
* Add to the pattern. Need to collect more data.&lt;br /&gt;
* Possibly have the puck store data, find a best fit, and create the calibration function on board.&lt;br /&gt;
* Store the calibration function in the EEPROM (flash memory) so it&#039;s non-volatile. The coefficients of function will be specific to each puck, so it would be nice to not have to program each puck, each time you change the battery.&lt;br /&gt;
&lt;br /&gt;
===dsPIC_XBeePackets(.c/.h)===&lt;br /&gt;
* .c/.h: Contains functions and data structures for assembling and receiving XBee packets.&lt;br /&gt;
&lt;br /&gt;
=====int readPacket( void)=====&lt;br /&gt;
Parses XBee data from UART2. Makes it accessable in the &#039;&#039;InPacket&#039;&#039; struct.&lt;br /&gt;
&lt;br /&gt;
The UART2 receive ISR takes error codes from this function and flashes the corresponding puck LED (absolute value of the error code).&lt;br /&gt;
&lt;br /&gt;
Error codes are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	//////////////ERROR CODES/////////////////&lt;br /&gt;
	// &lt;br /&gt;
	// -1: Timeout waiting for UART2&lt;br /&gt;
	// -2: Start delimiter wrong&lt;br /&gt;
	// -3: Checksum Error&lt;br /&gt;
	// -4: UART2 not ready at beginning&lt;br /&gt;
	// -5: API_ID unidentified&lt;br /&gt;
	// -6: Send Packet CCA failuue&lt;br /&gt;
	// -7: Modem Status packet failure&lt;br /&gt;
	//////////////////////////////////////////&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===send_packet(.c/.h)===&lt;br /&gt;
* .c: Contains the void send_packet(void) function which fills an array with data and calls the needed XBee functions to send a packet.&lt;br /&gt;
* .h: Contains function prototype.&lt;br /&gt;
&lt;br /&gt;
=====void send_packet(void)=====&lt;br /&gt;
* Creates &#039;&#039;packet&#039;&#039; array.&lt;br /&gt;
* Adds consensus estimator data to the array.&lt;br /&gt;
* Adds robot statistics to the array.&lt;br /&gt;
* Adds color sensor values to the array.&lt;br /&gt;
* Asserts flow control line to stop XBee from sending&lt;br /&gt;
* Calls assemblePacket to send the packet.&lt;br /&gt;
* Deasserts flow control; Xbee can send again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function e_get_acc_filtered returns a running average of the acc specified. Syntax is:&lt;br /&gt;
&lt;br /&gt;
return value = e_get_acc_filtered(acc_channel, number of samples to average)&lt;br /&gt;
&lt;br /&gt;
The number of samples averaged must be less than ACC_SAMP_NB as defined in e_ad_conv.h.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
packet[i]=e_get_acc_filtered(2, 136); // red&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(1, 136); // green&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(0, 136); // blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PI_consensus_estimator(.h)===&lt;br /&gt;
* .h: Contains functions and data structures for the PI consensus estimator. &lt;br /&gt;
* This will probably be replaced by the algorithm for sensor consensus. &lt;br /&gt;
&lt;br /&gt;
===wheel_speed_coordinator(.c/.h)===&lt;br /&gt;
* .c: Contains functions for robot motion control&lt;br /&gt;
* .h: Function prototypes and variabls.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeed(int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speeds for the inertial consensus estimator based on the group goal.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeedSingleBot(float gotox, float gotoy, int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speed to get this individual bot to (gotox, gotoy). It&#039;s a hacked fix. Should be replaced with the 3 step motion controller from NUtest.c.&lt;br /&gt;
&lt;br /&gt;
===e_acc(.c/.h)===&lt;br /&gt;
* .c: Functions for reading the accelerometers (which is the color sensor).&lt;br /&gt;
* .h: Function prototypes.&lt;br /&gt;
&lt;br /&gt;
This is original e-puck library code with the following modifications:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
//changed by Sam, July 10, default offset is 2000. we want 0 for RGB sensor.&lt;br /&gt;
static int centre_z = 0;			//zero value for z axe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====int e_get_acc_filtered(unsigned int captor, unsigned int filter_size)=====&lt;br /&gt;
&lt;br /&gt;
===e_ad_conv(.c/.h)===&lt;br /&gt;
Set up the ADCs on the puck. Original e-puck library code, with the following modifications&lt;br /&gt;
* .h: Define constants and functional prototypes&lt;br /&gt;
&lt;br /&gt;
MIC_SAMP_FREQ sets the baseline sampling frequency for the ADC, everything else must be a fraction of this. 16384 Hz is the highest possible.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MIC_SAMP_FREQ 16384.0	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_PROX_SAMP_FREQ sets the sampling frequency for the accelerometers (color sensor). We found in testing that the puck become non-responsive with this set to 8192 Hz or 16384 Hz.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// sampling frequency for the accelerometres and proximetres&lt;br /&gt;
//#define ACC_PROX_SAMP_FREQ 256.0	// WARNING: should be a fraction of MIC_SAMP_FREQ&lt;br /&gt;
#define ACC_PROX_SAMP_FREQ 4096	//			to ensure a good timing precision&lt;br /&gt;
									// So your options are: 1  2  4  8  16  32  64  128  &lt;br /&gt;
									//  256  512  1024  2048  4096  8192  16384&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_SAMP_NB is the number of samples to store. We can do an average of &#039;&#039;up to&#039;&#039; this many samples. This is set to 140 so we can average 136 samples, which is 4 projector periods.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ACC_SAMP_NB  140	// number of accelerometer samples to store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* .c: Functions and interrupt service routines for ADCs. Original e-puck library, no modifications.&lt;br /&gt;
&lt;br /&gt;
=====e_init_ad_scan(ALL_ADC)=====&lt;br /&gt;
Call to setup ADC and have it work in the background. Use e_acc functions to access data.&lt;br /&gt;
&lt;br /&gt;
===e_init_port(.c/.h)===&lt;br /&gt;
* .c/.h: Initializes the ports on the e-puck. File is from the standard e-puck library. &lt;br /&gt;
&lt;br /&gt;
=====e_init_ports(void)=====&lt;br /&gt;
This function sets up ports on the e-puck. Call before using any ports.&lt;br /&gt;
&lt;br /&gt;
===e_led(.c/.h)===&lt;br /&gt;
* .c/.h: This is a standard e-puck library file that contains functions for manipulating LEDs.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_led(unsigned int led_number, unsigned int value)=====&lt;br /&gt;
Set led_number (0-7) to value (0=off 1=on higher=inverse).&lt;br /&gt;
&lt;br /&gt;
[[Image:e-puck_LED_numbering.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&#039;all&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===e_motors_swarm(.c/.h)===&lt;br /&gt;
* .c/.h: This file is a modified version of the e_motors.h e-puck library file.  This version keeps track of the robot&#039;s position and orientation, and the motor stepping function contains code to update the robot&#039;s position when the wheels turn. &lt;br /&gt;
* The functions like e_rotate and e_translate have been removed and this version is not dependent on e_agenda. &lt;br /&gt;
&lt;br /&gt;
=====#define POINT_OFFSET -31.75 =====&lt;br /&gt;
In addition to constants like wheel radius and wheel base, the offset between the center point of the bot and the point we&#039;re driving is set in e_motors_swarm.h. -31.75 mm is the distance betwene the center and the color sensor. So technically, we&#039;re driving backwards.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T5Interrupt(void)=====&lt;br /&gt;
Timer5 ISR, interrupt for left motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
    xpos = xpos + cval*LINSTEP;&lt;br /&gt;
    ypos = ypos + sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T4Interrupt(void)=====&lt;br /&gt;
Timer4 ISR, interrupt for right motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
	xpos = xpos - cval*LINSTEP;&lt;br /&gt;
    ypos = ypos - sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void e_init_motors(void)=====&lt;br /&gt;
Call this function before other motor functions to initialize the motors.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_speed_left(int motor_speed)/void e_set_speed_right(int motor_speed)=====&lt;br /&gt;
Set the motor speed in steps/second.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the center reference point.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_configuration(float x, float y, float theta)=====&lt;br /&gt;
Sets x, y, theta to values. This is used to overwrite the puck position/orientation estimates with data from the vision system.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration_front(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the front reference point (used for motor control).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;br /&gt;
[[Category:e-puck]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14402</id>
		<title>RGB Swarm Robot Project E-puck Code (outdated)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14402"/>
		<updated>2009-09-10T21:00:16Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* main(.c/.h) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the e-puck code for the RGB Sensing Swarm Robotics project. The code on the e-puck was written in C and compiled using Microchip&#039;s MPLAB C Compiler for dsPIC DSCs (student version). &lt;br /&gt;
&lt;br /&gt;
This code is a branch of the [[Swarm Project E-puck Code]].&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===Complete===&lt;br /&gt;
* Got ADC working for color sensor&lt;br /&gt;
** Set up filtering to address projector PWM&lt;br /&gt;
* Restructured code to make more modular.&lt;br /&gt;
** Split dsPIC_XBeePackets and wheel_speed_coordinator into h and c files&lt;br /&gt;
** Pulled packet assembling code out of main and created send_packet() function in send_packet.h/c.&lt;br /&gt;
** Pulled a bunch of variables and defines (&#039;&#039;NUM_DATA_SETS, NUMBERS_PER_SET, DATATYPE_BYTELENGTH , DATA_ARRAY_LENGTH , ADDITIONAL_NUMS, notRTS, T1_INT_FLAG, x_i, u_i, w_i, x_sum, w_sum, MAX_WHEEL_V_TICKS, deadband, COMMR, SAFEDIST, MINDIST, u_x_ideal, u_y_ideal, x_motion_integral, y_motion_integral, SQUARE&#039;&#039;) that were scattered across h files into global_vars.h/c. Makes it easy to include them in a particular file with the &#039;&#039;extern&#039;&#039; keyword.&lt;br /&gt;
* Added color_cal() function in color_cal.h/c&lt;br /&gt;
* Added wheelSpeedSingleBot to wheel_speed_coordinator&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
* Finish color calibration (color_cal) program, to facilitate simple calibration for each e-puck that does not require large amount of data collected for each run, and with minimal user input/control (desire automation and simplification)&lt;br /&gt;
* Improve the vision system position information updater&lt;br /&gt;
** So that the e-puck does not automatically assume every packet from the Vision System is true, rather &#039;checks&#039; for accuracy&lt;br /&gt;
* Replace wheelSpeedSingleBot with the three step move controller from NUtest.c&lt;br /&gt;
**Implement this so that the e-puck can be moved with position and orientation (this is ideal so that data from every orientation of the e-puck can be recorded while calibrating or collecting data&lt;br /&gt;
* Implement new algorithm from paper&lt;br /&gt;
&lt;br /&gt;
==Project Package==&lt;br /&gt;
The source code for the project is available here: [[Media:RGB_Swarm_Puck_Code_working_version.zip]]. Open swarm_epucks.mcw and you should be good to go.&lt;br /&gt;
&lt;br /&gt;
==Description of the files and functions==&lt;br /&gt;
&lt;br /&gt;
===global_vars(.c/.h)===&lt;br /&gt;
* .c/.h: declare and define global variables and macros&lt;br /&gt;
====Packet Length Constants====&lt;br /&gt;
These variables determine the length of the XBee packets.  See [[Swarm_Robot_Project_Documentation#Data_Frame|Data Frame]] and the section on XBee API packets in the XBee manual for further clarification.&lt;br /&gt;
&lt;br /&gt;
Much of this is still sending integral consensus estimator data. This can be removed or replaces with data needed for decentralized color sensing. &lt;br /&gt;
&lt;br /&gt;
=====#define NUM_DATA_SETS 5 =====	&lt;br /&gt;
Number of statistics on which you are running the consensus estimator.  This this particular case, 5. (Ix, Iy, Ixx, Ixy, Iyy)&lt;br /&gt;
&lt;br /&gt;
=====#define NUMBERS_PER_SET 2=====&lt;br /&gt;
Number of variables in each data set (see above) that the consensus estimator needs to transmit to other agents.  In this case, 2 because there is &amp;lt;tt&amp;gt;x_i&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;w_i&amp;lt;/tt&amp;gt; for each statistic.&lt;br /&gt;
&lt;br /&gt;
=====#define DATATYPE_BYTELENGTH 4	=====&lt;br /&gt;
Number of bytes in the data type (used in the consensus estimator (float = 4 bytes long).  This is important because we need to split the numbers into individual bytes to be able to send them out the serial port.&lt;br /&gt;
&lt;br /&gt;
=====#define DATA_ARRAY_LENGTH (NUM_DATA_SETS*NUMBERS_PER_SET)=====&lt;br /&gt;
Total number of data variables needed for the consensus estimator.  In this case, it is 5*2=10.&lt;br /&gt;
&lt;br /&gt;
=====#define ADDITIONAL_NUMS 8=====&lt;br /&gt;
Additional number of data to be appended to data array.  It is 5 in this case, so that we can append &lt;br /&gt;
# Robot X coordinate&lt;br /&gt;
# Robot Y coordinate&lt;br /&gt;
# Robot Theta orientation&lt;br /&gt;
# Robot left wheel speed&lt;br /&gt;
# Robot right wheel speed&lt;br /&gt;
# Sensor Red Value&lt;br /&gt;
# Sensor Green Value&lt;br /&gt;
# Sensor Blue Value&lt;br /&gt;
&lt;br /&gt;
===main(.c/.h)===&lt;br /&gt;
* .c: This contains the entry point of the code and contains the initialization routines, main loop, and interrupt service routines. &lt;br /&gt;
* .h: Contains variables, function prototypes, and delay function needed for main.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _T1Interrupt(void)=====&lt;br /&gt;
Timer1 ISR. Sets T1_INT_FLAG which provides timing for the main loop.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void)=====&lt;br /&gt;
UART2 receive ISR. Runs with the XBee receives packets. The switch/case structure handles the packets.&lt;br /&gt;
&lt;br /&gt;
The current handling of coordinate data from the vision system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
case 0: //coordinate data&lt;br /&gt;
					e_set_configuration(&lt;br /&gt;
					InPacket.data[1].dataFloat,&lt;br /&gt;
					InPacket.data[2].dataFloat, &lt;br /&gt;
					InPacket.data[3].dataFloat);&lt;br /&gt;
					break;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
======Possible improvements======&lt;br /&gt;
Needs to be improved. Suggested new function:&lt;br /&gt;
* Get vision system data&lt;br /&gt;
* Check if it&#039;s wildly off from current puck estimate&lt;br /&gt;
** If not, update, clear log of rejected packets&lt;br /&gt;
** If so, reject and log&lt;br /&gt;
*** If we have rejected enough packets (some threshold) and they&#039;ve all been in similar place (within tolerance), we can assume the puck is wrong and vision system is right. In this case, update with vision system data and clear rejected data log.&lt;br /&gt;
&lt;br /&gt;
=====int main(void)=====&lt;br /&gt;
Setup functions and main loop.&lt;br /&gt;
&lt;br /&gt;
===color_cal(.c/.h)===&lt;br /&gt;
* .c: Contains void calibrate_color(void) function to run the calibration routine.&lt;br /&gt;
* .h: Contains function prototype and constant definitions for calibrate_color.&lt;br /&gt;
&lt;br /&gt;
=====void calibrate_color(void)=====&lt;br /&gt;
This function runs the color calibration routine. Eventually this should be turned into a separate e-puck command from the vision system. Currently it just runs the puck through a zig zag pattern on the floor and sends packets. You can collect these with the data logger and process them in matlab. From this, you should be able to get a calibration function.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To do:&#039;&#039;&#039;&lt;br /&gt;
* Add to the pattern. Need to collect more data.&lt;br /&gt;
* Possibly have the puck store data, find a best fit, and create the calibration function on board.&lt;br /&gt;
* Store the calibration function in the EEPROM (flash memory) so it&#039;s non-volatile. The coefficients of function will be specific to each puck, so it would be nice to not have to program each puck, each time you change the battery.&lt;br /&gt;
&lt;br /&gt;
===dsPIC_XBeePackets(.c/.h)===&lt;br /&gt;
* .c/.h: Contains functions and data structures for assembling and receiving XBee packets.&lt;br /&gt;
&lt;br /&gt;
=====int readPacket( void)=====&lt;br /&gt;
Parses XBee data from UART2. Makes it accessable in the &#039;&#039;InPacket&#039;&#039; struct.&lt;br /&gt;
&lt;br /&gt;
The UART2 receive ISR takes error codes from this function and flashes the corresponding puck LED (absolute value of the error code).&lt;br /&gt;
&lt;br /&gt;
Error codes are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	//////////////ERROR CODES/////////////////&lt;br /&gt;
	// &lt;br /&gt;
	// -1: Timeout waiting for UART2&lt;br /&gt;
	// -2: Start delimiter wrong&lt;br /&gt;
	// -3: Checksum Error&lt;br /&gt;
	// -4: UART2 not ready at beginning&lt;br /&gt;
	// -5: API_ID unidentified&lt;br /&gt;
	// -6: Send Packet CCA failuue&lt;br /&gt;
	// -7: Modem Status packet failure&lt;br /&gt;
	//////////////////////////////////////////&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===send_packet(.c/.h)===&lt;br /&gt;
* .c: Contains the void send_packet(void) function which fills an array with data and calls the needed XBee functions to send a packet.&lt;br /&gt;
* .h: Contains function prototype.&lt;br /&gt;
&lt;br /&gt;
=====void send_packet(void)=====&lt;br /&gt;
* Creates &#039;&#039;packet&#039;&#039; array.&lt;br /&gt;
* Adds consensus estimator data to the array.&lt;br /&gt;
* Adds robot statistics to the array.&lt;br /&gt;
* Adds color sensor values to the array.&lt;br /&gt;
* Asserts flow control line to stop XBee from sending&lt;br /&gt;
* Calls assemblePacket to send the packet.&lt;br /&gt;
* Deasserts flow control; Xbee can send again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function e_get_acc_filtered returns a running average of the acc specified. Syntax is:&lt;br /&gt;
&lt;br /&gt;
return value = e_get_acc_filtered(acc_channel, number of samples to average)&lt;br /&gt;
&lt;br /&gt;
The number of samples averaged must be less than ACC_SAMP_NB as defined in e_ad_conv.h.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
packet[i]=e_get_acc_filtered(2, 136); // red&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(1, 136); // green&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(0, 136); // blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PI_consensus_estimator(.h)===&lt;br /&gt;
* .h: Contains functions and data structures for the PI consensus estimator. &lt;br /&gt;
* This will probably be replaced by the algorithm for sensor consensus. &lt;br /&gt;
&lt;br /&gt;
===wheel_speed_coordinator(.c/.h)===&lt;br /&gt;
* .c: Contains functions for robot motion control&lt;br /&gt;
* .h: Function prototypes and variabls.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeed(int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speeds for the inertial consensus estimator based on the group goal.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeedSingleBot(float gotox, float gotoy, int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speed to get this individual bot to (gotox, gotoy). It&#039;s a hacked fix. Should be replaced with the 3 step motion controller from NUtest.c.&lt;br /&gt;
&lt;br /&gt;
===e_acc(.c/.h)===&lt;br /&gt;
* .c: Functions for reading the accelerometers (which is the color sensor).&lt;br /&gt;
* .h: Function prototypes.&lt;br /&gt;
&lt;br /&gt;
This is original e-puck library code with the following modifications:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
//changed by Sam, July 10, default offset is 2000. we want 0 for RGB sensor.&lt;br /&gt;
static int centre_z = 0;			//zero value for z axe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====int e_get_acc_filtered(unsigned int captor, unsigned int filter_size)=====&lt;br /&gt;
&lt;br /&gt;
===e_ad_conv(.c/.h)===&lt;br /&gt;
Set up the ADCs on the puck. Original e-puck library code, with the following modifications&lt;br /&gt;
* .h: Define constants and functional prototypes&lt;br /&gt;
&lt;br /&gt;
MIC_SAMP_FREQ sets the baseline sampling frequency for the ADC, everything else must be a fraction of this. 16384 Hz is the highest possible.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MIC_SAMP_FREQ 16384.0	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_PROX_SAMP_FREQ sets the sampling frequency for the accelerometers (color sensor). We found in testing that the puck become non-responsive with this set to 8192 Hz or 16384 Hz.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// sampling frequency for the accelerometres and proximetres&lt;br /&gt;
//#define ACC_PROX_SAMP_FREQ 256.0	// WARNING: should be a fraction of MIC_SAMP_FREQ&lt;br /&gt;
#define ACC_PROX_SAMP_FREQ 4096	//			to ensure a good timing precision&lt;br /&gt;
									// So your options are: 1  2  4  8  16  32  64  128  &lt;br /&gt;
									//  256  512  1024  2048  4096  8192  16384&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_SAMP_NB is the number of samples to store. We can do an average of &#039;&#039;up to&#039;&#039; this many samples. This is set to 140 so we can average 136 samples, which is 4 projector periods.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ACC_SAMP_NB  140	// number of accelerometer samples to store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* .c: Functions and interrupt service routines for ADCs. Original e-puck library, no modifications.&lt;br /&gt;
&lt;br /&gt;
=====e_init_ad_scan(ALL_ADC)=====&lt;br /&gt;
Call to setup ADC and have it work in the background. Use e_acc functions to access data.&lt;br /&gt;
&lt;br /&gt;
===e_init_port(.c/.h)===&lt;br /&gt;
* .c/.h: Initializes the ports on the e-puck. File is from the standard e-puck library. &lt;br /&gt;
&lt;br /&gt;
=====e_init_ports(void)=====&lt;br /&gt;
This function sets up ports on the e-puck. Call before using any ports.&lt;br /&gt;
&lt;br /&gt;
===e_led(.c/.h)===&lt;br /&gt;
* .c/.h: This is a standard e-puck library file that contains functions for manipulating LEDs.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_led(unsigned int led_number, unsigned int value)=====&lt;br /&gt;
Set led_number (0-7) to value (0=off 1=on higher=inverse).&lt;br /&gt;
&lt;br /&gt;
[[Image:e-puck_LED_numbering.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&#039;all&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===e_motors_swarm(.c/.h)===&lt;br /&gt;
* .c/.h: This file is a modified version of the e_motors.h e-puck library file.  This version keeps track of the robot&#039;s position and orientation, and the motor stepping function contains code to update the robot&#039;s position when the wheels turn. &lt;br /&gt;
* The functions like e_rotate and e_translate have been removed and this version is not dependent on e_agenda. &lt;br /&gt;
&lt;br /&gt;
=====#define POINT_OFFSET -31.75 =====&lt;br /&gt;
In addition to constants like wheel radius and wheel base, the offset between the center point of the bot and the point we&#039;re driving is set in e_motors_swarm.h. -31.75 mm is the distance betwene the center and the color sensor. So technically, we&#039;re driving backwards.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T5Interrupt(void)=====&lt;br /&gt;
Timer5 ISR, interrupt for left motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
    xpos = xpos + cval*LINSTEP;&lt;br /&gt;
    ypos = ypos + sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T4Interrupt(void)=====&lt;br /&gt;
Timer4 ISR, interrupt for right motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
	xpos = xpos - cval*LINSTEP;&lt;br /&gt;
    ypos = ypos - sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void e_init_motors(void)=====&lt;br /&gt;
Call this function before other motor functions to initialize the motors.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_speed_left(int motor_speed)/void e_set_speed_right(int motor_speed)=====&lt;br /&gt;
Set the motor speed in steps/second.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the center reference point.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_configuration(float x, float y, float theta)=====&lt;br /&gt;
Sets x, y, theta to values. This is used to overwrite the puck position/orientation estimates with data from the vision system.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration_front(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the front reference point (used for motor control).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;br /&gt;
[[Category:e-puck]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14401</id>
		<title>RGB Swarm Robot Project E-puck Code (outdated)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14401"/>
		<updated>2009-09-10T20:59:48Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the e-puck code for the RGB Sensing Swarm Robotics project. The code on the e-puck was written in C and compiled using Microchip&#039;s MPLAB C Compiler for dsPIC DSCs (student version). &lt;br /&gt;
&lt;br /&gt;
This code is a branch of the [[Swarm Project E-puck Code]].&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===Complete===&lt;br /&gt;
* Got ADC working for color sensor&lt;br /&gt;
** Set up filtering to address projector PWM&lt;br /&gt;
* Restructured code to make more modular.&lt;br /&gt;
** Split dsPIC_XBeePackets and wheel_speed_coordinator into h and c files&lt;br /&gt;
** Pulled packet assembling code out of main and created send_packet() function in send_packet.h/c.&lt;br /&gt;
** Pulled a bunch of variables and defines (&#039;&#039;NUM_DATA_SETS, NUMBERS_PER_SET, DATATYPE_BYTELENGTH , DATA_ARRAY_LENGTH , ADDITIONAL_NUMS, notRTS, T1_INT_FLAG, x_i, u_i, w_i, x_sum, w_sum, MAX_WHEEL_V_TICKS, deadband, COMMR, SAFEDIST, MINDIST, u_x_ideal, u_y_ideal, x_motion_integral, y_motion_integral, SQUARE&#039;&#039;) that were scattered across h files into global_vars.h/c. Makes it easy to include them in a particular file with the &#039;&#039;extern&#039;&#039; keyword.&lt;br /&gt;
* Added color_cal() function in color_cal.h/c&lt;br /&gt;
* Added wheelSpeedSingleBot to wheel_speed_coordinator&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
* Finish color calibration (color_cal) program, to facilitate simple calibration for each e-puck that does not require large amount of data collected for each run, and with minimal user input/control (desire automation and simplification)&lt;br /&gt;
* Improve the vision system position information updater&lt;br /&gt;
** So that the e-puck does not automatically assume every packet from the Vision System is true, rather &#039;checks&#039; for accuracy&lt;br /&gt;
* Replace wheelSpeedSingleBot with the three step move controller from NUtest.c&lt;br /&gt;
**Implement this so that the e-puck can be moved with position and orientation (this is ideal so that data from every orientation of the e-puck can be recorded while calibrating or collecting data&lt;br /&gt;
* Implement new algorithm from paper&lt;br /&gt;
&lt;br /&gt;
==Project Package==&lt;br /&gt;
The source code for the project is available here: [[Media:RGB_Swarm_Puck_Code_working_version.zip]]. Open swarm_epucks.mcw and you should be good to go.&lt;br /&gt;
&lt;br /&gt;
==Description of the files and functions==&lt;br /&gt;
&lt;br /&gt;
===global_vars(.c/.h)===&lt;br /&gt;
* .c/.h: declare and define global variables and macros&lt;br /&gt;
====Packet Length Constants====&lt;br /&gt;
These variables determine the length of the XBee packets.  See [[Swarm_Robot_Project_Documentation#Data_Frame|Data Frame]] and the section on XBee API packets in the XBee manual for further clarification.&lt;br /&gt;
&lt;br /&gt;
Much of this is still sending integral consensus estimator data. This can be removed or replaces with data needed for decentralized color sensing. &lt;br /&gt;
&lt;br /&gt;
=====#define NUM_DATA_SETS 5 =====	&lt;br /&gt;
Number of statistics on which you are running the consensus estimator.  This this particular case, 5. (Ix, Iy, Ixx, Ixy, Iyy)&lt;br /&gt;
&lt;br /&gt;
=====#define NUMBERS_PER_SET 2=====&lt;br /&gt;
Number of variables in each data set (see above) that the consensus estimator needs to transmit to other agents.  In this case, 2 because there is &amp;lt;tt&amp;gt;x_i&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;w_i&amp;lt;/tt&amp;gt; for each statistic.&lt;br /&gt;
&lt;br /&gt;
=====#define DATATYPE_BYTELENGTH 4	=====&lt;br /&gt;
Number of bytes in the data type (used in the consensus estimator (float = 4 bytes long).  This is important because we need to split the numbers into individual bytes to be able to send them out the serial port.&lt;br /&gt;
&lt;br /&gt;
=====#define DATA_ARRAY_LENGTH (NUM_DATA_SETS*NUMBERS_PER_SET)=====&lt;br /&gt;
Total number of data variables needed for the consensus estimator.  In this case, it is 5*2=10.&lt;br /&gt;
&lt;br /&gt;
=====#define ADDITIONAL_NUMS 8=====&lt;br /&gt;
Additional number of data to be appended to data array.  It is 5 in this case, so that we can append &lt;br /&gt;
# Robot X coordinate&lt;br /&gt;
# Robot Y coordinate&lt;br /&gt;
# Robot Theta orientation&lt;br /&gt;
# Robot left wheel speed&lt;br /&gt;
# Robot right wheel speed&lt;br /&gt;
# Sensor Red Value&lt;br /&gt;
# Sensor Green Value&lt;br /&gt;
# Sensor Blue Value&lt;br /&gt;
&lt;br /&gt;
===main(.c/.h)===&lt;br /&gt;
* .c: This contains the entry point of the code and contains the initialization routines, main loop, and interrupt service routines. &lt;br /&gt;
* .h: Contains variables, function prototypes, and delay function needed for main.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _T1Interrupt(void)=====&lt;br /&gt;
Timer1 ISR. Sets T1_INT_FLAG which provides timing for the main loop.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void)=====&lt;br /&gt;
UART2 receive ISR. Runs with the XBee receives packets. The switch/case structure handles the packets.&lt;br /&gt;
&lt;br /&gt;
The current handling of coordinate data from the vision system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
case 0: //coordinate data&lt;br /&gt;
					e_set_configuration(&lt;br /&gt;
					InPacket.data[1].dataFloat,&lt;br /&gt;
					InPacket.data[2].dataFloat, &lt;br /&gt;
					InPacket.data[3].dataFloat);&lt;br /&gt;
					break;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Possible improvements=====&lt;br /&gt;
Needs to be improved. Suggested new function:&lt;br /&gt;
* Get vision system data&lt;br /&gt;
* Check if it&#039;s wildly off from current puck estimate&lt;br /&gt;
** If not, update, clear log of rejected packets&lt;br /&gt;
** If so, reject and log&lt;br /&gt;
*** If we have rejected enough packets (some threshold) and they&#039;ve all been in similar place (within tolerance), we can assume the puck is wrong and vision system is right. In this case, update with vision system data and clear rejected data log.&lt;br /&gt;
&lt;br /&gt;
=====int main(void)=====&lt;br /&gt;
Setup functions and main loop.&lt;br /&gt;
&lt;br /&gt;
===color_cal(.c/.h)===&lt;br /&gt;
* .c: Contains void calibrate_color(void) function to run the calibration routine.&lt;br /&gt;
* .h: Contains function prototype and constant definitions for calibrate_color.&lt;br /&gt;
&lt;br /&gt;
=====void calibrate_color(void)=====&lt;br /&gt;
This function runs the color calibration routine. Eventually this should be turned into a separate e-puck command from the vision system. Currently it just runs the puck through a zig zag pattern on the floor and sends packets. You can collect these with the data logger and process them in matlab. From this, you should be able to get a calibration function.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To do:&#039;&#039;&#039;&lt;br /&gt;
* Add to the pattern. Need to collect more data.&lt;br /&gt;
* Possibly have the puck store data, find a best fit, and create the calibration function on board.&lt;br /&gt;
* Store the calibration function in the EEPROM (flash memory) so it&#039;s non-volatile. The coefficients of function will be specific to each puck, so it would be nice to not have to program each puck, each time you change the battery.&lt;br /&gt;
&lt;br /&gt;
===dsPIC_XBeePackets(.c/.h)===&lt;br /&gt;
* .c/.h: Contains functions and data structures for assembling and receiving XBee packets.&lt;br /&gt;
&lt;br /&gt;
=====int readPacket( void)=====&lt;br /&gt;
Parses XBee data from UART2. Makes it accessable in the &#039;&#039;InPacket&#039;&#039; struct.&lt;br /&gt;
&lt;br /&gt;
The UART2 receive ISR takes error codes from this function and flashes the corresponding puck LED (absolute value of the error code).&lt;br /&gt;
&lt;br /&gt;
Error codes are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	//////////////ERROR CODES/////////////////&lt;br /&gt;
	// &lt;br /&gt;
	// -1: Timeout waiting for UART2&lt;br /&gt;
	// -2: Start delimiter wrong&lt;br /&gt;
	// -3: Checksum Error&lt;br /&gt;
	// -4: UART2 not ready at beginning&lt;br /&gt;
	// -5: API_ID unidentified&lt;br /&gt;
	// -6: Send Packet CCA failuue&lt;br /&gt;
	// -7: Modem Status packet failure&lt;br /&gt;
	//////////////////////////////////////////&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===send_packet(.c/.h)===&lt;br /&gt;
* .c: Contains the void send_packet(void) function which fills an array with data and calls the needed XBee functions to send a packet.&lt;br /&gt;
* .h: Contains function prototype.&lt;br /&gt;
&lt;br /&gt;
=====void send_packet(void)=====&lt;br /&gt;
* Creates &#039;&#039;packet&#039;&#039; array.&lt;br /&gt;
* Adds consensus estimator data to the array.&lt;br /&gt;
* Adds robot statistics to the array.&lt;br /&gt;
* Adds color sensor values to the array.&lt;br /&gt;
* Asserts flow control line to stop XBee from sending&lt;br /&gt;
* Calls assemblePacket to send the packet.&lt;br /&gt;
* Deasserts flow control; Xbee can send again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function e_get_acc_filtered returns a running average of the acc specified. Syntax is:&lt;br /&gt;
&lt;br /&gt;
return value = e_get_acc_filtered(acc_channel, number of samples to average)&lt;br /&gt;
&lt;br /&gt;
The number of samples averaged must be less than ACC_SAMP_NB as defined in e_ad_conv.h.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
packet[i]=e_get_acc_filtered(2, 136); // red&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(1, 136); // green&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(0, 136); // blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PI_consensus_estimator(.h)===&lt;br /&gt;
* .h: Contains functions and data structures for the PI consensus estimator. &lt;br /&gt;
* This will probably be replaced by the algorithm for sensor consensus. &lt;br /&gt;
&lt;br /&gt;
===wheel_speed_coordinator(.c/.h)===&lt;br /&gt;
* .c: Contains functions for robot motion control&lt;br /&gt;
* .h: Function prototypes and variabls.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeed(int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speeds for the inertial consensus estimator based on the group goal.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeedSingleBot(float gotox, float gotoy, int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speed to get this individual bot to (gotox, gotoy). It&#039;s a hacked fix. Should be replaced with the 3 step motion controller from NUtest.c.&lt;br /&gt;
&lt;br /&gt;
===e_acc(.c/.h)===&lt;br /&gt;
* .c: Functions for reading the accelerometers (which is the color sensor).&lt;br /&gt;
* .h: Function prototypes.&lt;br /&gt;
&lt;br /&gt;
This is original e-puck library code with the following modifications:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
//changed by Sam, July 10, default offset is 2000. we want 0 for RGB sensor.&lt;br /&gt;
static int centre_z = 0;			//zero value for z axe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====int e_get_acc_filtered(unsigned int captor, unsigned int filter_size)=====&lt;br /&gt;
&lt;br /&gt;
===e_ad_conv(.c/.h)===&lt;br /&gt;
Set up the ADCs on the puck. Original e-puck library code, with the following modifications&lt;br /&gt;
* .h: Define constants and functional prototypes&lt;br /&gt;
&lt;br /&gt;
MIC_SAMP_FREQ sets the baseline sampling frequency for the ADC, everything else must be a fraction of this. 16384 Hz is the highest possible.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MIC_SAMP_FREQ 16384.0	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_PROX_SAMP_FREQ sets the sampling frequency for the accelerometers (color sensor). We found in testing that the puck become non-responsive with this set to 8192 Hz or 16384 Hz.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// sampling frequency for the accelerometres and proximetres&lt;br /&gt;
//#define ACC_PROX_SAMP_FREQ 256.0	// WARNING: should be a fraction of MIC_SAMP_FREQ&lt;br /&gt;
#define ACC_PROX_SAMP_FREQ 4096	//			to ensure a good timing precision&lt;br /&gt;
									// So your options are: 1  2  4  8  16  32  64  128  &lt;br /&gt;
									//  256  512  1024  2048  4096  8192  16384&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_SAMP_NB is the number of samples to store. We can do an average of &#039;&#039;up to&#039;&#039; this many samples. This is set to 140 so we can average 136 samples, which is 4 projector periods.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ACC_SAMP_NB  140	// number of accelerometer samples to store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* .c: Functions and interrupt service routines for ADCs. Original e-puck library, no modifications.&lt;br /&gt;
&lt;br /&gt;
=====e_init_ad_scan(ALL_ADC)=====&lt;br /&gt;
Call to setup ADC and have it work in the background. Use e_acc functions to access data.&lt;br /&gt;
&lt;br /&gt;
===e_init_port(.c/.h)===&lt;br /&gt;
* .c/.h: Initializes the ports on the e-puck. File is from the standard e-puck library. &lt;br /&gt;
&lt;br /&gt;
=====e_init_ports(void)=====&lt;br /&gt;
This function sets up ports on the e-puck. Call before using any ports.&lt;br /&gt;
&lt;br /&gt;
===e_led(.c/.h)===&lt;br /&gt;
* .c/.h: This is a standard e-puck library file that contains functions for manipulating LEDs.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_led(unsigned int led_number, unsigned int value)=====&lt;br /&gt;
Set led_number (0-7) to value (0=off 1=on higher=inverse).&lt;br /&gt;
&lt;br /&gt;
[[Image:e-puck_LED_numbering.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&#039;all&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===e_motors_swarm(.c/.h)===&lt;br /&gt;
* .c/.h: This file is a modified version of the e_motors.h e-puck library file.  This version keeps track of the robot&#039;s position and orientation, and the motor stepping function contains code to update the robot&#039;s position when the wheels turn. &lt;br /&gt;
* The functions like e_rotate and e_translate have been removed and this version is not dependent on e_agenda. &lt;br /&gt;
&lt;br /&gt;
=====#define POINT_OFFSET -31.75 =====&lt;br /&gt;
In addition to constants like wheel radius and wheel base, the offset between the center point of the bot and the point we&#039;re driving is set in e_motors_swarm.h. -31.75 mm is the distance betwene the center and the color sensor. So technically, we&#039;re driving backwards.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T5Interrupt(void)=====&lt;br /&gt;
Timer5 ISR, interrupt for left motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
    xpos = xpos + cval*LINSTEP;&lt;br /&gt;
    ypos = ypos + sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T4Interrupt(void)=====&lt;br /&gt;
Timer4 ISR, interrupt for right motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
	xpos = xpos - cval*LINSTEP;&lt;br /&gt;
    ypos = ypos - sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void e_init_motors(void)=====&lt;br /&gt;
Call this function before other motor functions to initialize the motors.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_speed_left(int motor_speed)/void e_set_speed_right(int motor_speed)=====&lt;br /&gt;
Set the motor speed in steps/second.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the center reference point.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_configuration(float x, float y, float theta)=====&lt;br /&gt;
Sets x, y, theta to values. This is used to overwrite the puck position/orientation estimates with data from the vision system.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration_front(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the front reference point (used for motor control).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;br /&gt;
[[Category:e-puck]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14400</id>
		<title>RGB Swarm Robot Project E-puck Code (outdated)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14400"/>
		<updated>2009-09-10T20:58:39Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* To Do */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the e-puck code for the RGB Sensing Swarm Robotics project. The code on the e-puck was written in C and compiled using Microchip&#039;s MPLAB C Compiler for dsPIC DSCs (student version). &lt;br /&gt;
&lt;br /&gt;
This code is a branch of the [[Swarm Project E-puck Code]].&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===Complete===&lt;br /&gt;
* Got ADC working for color sensor&lt;br /&gt;
** Set up filtering to address projector PWM&lt;br /&gt;
* Restructured code to make more modular.&lt;br /&gt;
** Split dsPIC_XBeePackets and wheel_speed_coordinator into h and c files&lt;br /&gt;
** Pulled packet assembling code out of main and created send_packet() function in send_packet.h/c.&lt;br /&gt;
** Pulled a bunch of variables and defines (&#039;&#039;NUM_DATA_SETS, NUMBERS_PER_SET, DATATYPE_BYTELENGTH , DATA_ARRAY_LENGTH , ADDITIONAL_NUMS, notRTS, T1_INT_FLAG, x_i, u_i, w_i, x_sum, w_sum, MAX_WHEEL_V_TICKS, deadband, COMMR, SAFEDIST, MINDIST, u_x_ideal, u_y_ideal, x_motion_integral, y_motion_integral, SQUARE&#039;&#039;) that were scattered across h files into global_vars.h/c. Makes it easy to include them in a particular file with the &#039;&#039;extern&#039;&#039; keyword.&lt;br /&gt;
* Added color_cal() function in color_cal.h/c&lt;br /&gt;
* Added wheelSpeedSingleBot to wheel_speed_coordinator&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
* Finish color calibration (color_cal) program, to facilitate simple calibration for each e-puck that does not require large amount of data collected for each run, and with minimal user input/control (desire automation and simplification)&lt;br /&gt;
* Improve the vision system position information updater&lt;br /&gt;
** So that the e-puck does not automatically assume every packet from the Vision System is true, rather &#039;checks&#039; for accuracy&lt;br /&gt;
* Replace wheelSpeedSingleBot with the three step move controller from NUtest.c&lt;br /&gt;
**Implement this so that the e-puck can be moved with position and orientation (this is ideal so that data from every orientation of the e-puck can be recorded while calibrating or collecting data&lt;br /&gt;
* Implement new algorithm from paper&lt;br /&gt;
&lt;br /&gt;
==Project Package==&lt;br /&gt;
The source code for the project is available here: [[Media:RGB_Swarm_Puck_Code_working_version.zip]]. Open swarm_epucks.mcw and you should be good to go.&lt;br /&gt;
&lt;br /&gt;
==Description of the files and functions==&lt;br /&gt;
&lt;br /&gt;
===global_vars(.c/.h)===&lt;br /&gt;
* .c/.h: declare and define global variables and macros&lt;br /&gt;
====Packet Length Constants====&lt;br /&gt;
These variables determine the length of the XBee packets.  See [[Swarm_Robot_Project_Documentation#Data_Frame|Data Frame]] and the section on XBee API packets in the XBee manual for further clarification.&lt;br /&gt;
&lt;br /&gt;
Much of this is still sending integral consensus estimator data. This can be removed or replaces with data needed for decentralized color sensing. &lt;br /&gt;
&lt;br /&gt;
=====#define NUM_DATA_SETS 5 =====	&lt;br /&gt;
Number of statistics on which you are running the consensus estimator.  This this particular case, 5. (Ix, Iy, Ixx, Ixy, Iyy)&lt;br /&gt;
&lt;br /&gt;
=====#define NUMBERS_PER_SET 2=====&lt;br /&gt;
Number of variables in each data set (see above) that the consensus estimator needs to transmit to other agents.  In this case, 2 because there is &amp;lt;tt&amp;gt;x_i&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;w_i&amp;lt;/tt&amp;gt; for each statistic.&lt;br /&gt;
&lt;br /&gt;
=====#define DATATYPE_BYTELENGTH 4	=====&lt;br /&gt;
Number of bytes in the data type (used in the consensus estimator (float = 4 bytes long).  This is important because we need to split the numbers into individual bytes to be able to send them out the serial port.&lt;br /&gt;
&lt;br /&gt;
=====#define DATA_ARRAY_LENGTH (NUM_DATA_SETS*NUMBERS_PER_SET)=====&lt;br /&gt;
Total number of data variables needed for the consensus estimator.  In this case, it is 5*2=10.&lt;br /&gt;
&lt;br /&gt;
=====#define ADDITIONAL_NUMS 8=====&lt;br /&gt;
Additional number of data to be appended to data array.  It is 5 in this case, so that we can append &lt;br /&gt;
# Robot X coordinate&lt;br /&gt;
# Robot Y coordinate&lt;br /&gt;
# Robot Theta orientation&lt;br /&gt;
# Robot left wheel speed&lt;br /&gt;
# Robot right wheel speed&lt;br /&gt;
# Sensor Red Value&lt;br /&gt;
# Sensor Green Value&lt;br /&gt;
# Sensor Blue Value&lt;br /&gt;
&lt;br /&gt;
===main(.c/.h)===&lt;br /&gt;
* .c: This contains the entry point of the code and contains the initialization routines, main loop, and interrupt service routines. &lt;br /&gt;
* .h: Contains variables, function prototypes, and delay function needed for main.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _T1Interrupt(void)=====&lt;br /&gt;
Timer1 ISR. Sets T1_INT_FLAG which provides timing for the main loop.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void)=====&lt;br /&gt;
UART2 receive ISR. Runs with the XBee receives packets. The switch/case structure handles the packets.&lt;br /&gt;
&lt;br /&gt;
The current handling of coordinate data from the vision system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
case 0: //coordinate data&lt;br /&gt;
					e_set_configuration(&lt;br /&gt;
					InPacket.data[1].dataFloat,&lt;br /&gt;
					InPacket.data[2].dataFloat, &lt;br /&gt;
					InPacket.data[3].dataFloat);&lt;br /&gt;
					break;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Needs to be improved. Suggested new function:&lt;br /&gt;
&lt;br /&gt;
* Get vision system data&lt;br /&gt;
* Check if it&#039;s wildly off from current puck estimate&lt;br /&gt;
** If not, update, clear log of rejected packets&lt;br /&gt;
** If so, reject and log&lt;br /&gt;
*** If we have rejected enough packets (some threshold) and they&#039;ve all been in similar place (within tolerance), we can assume the puck is wrong and vision system is right. In this case, update with vision system data and clear rejected data log.&lt;br /&gt;
&lt;br /&gt;
=====int main(void)=====&lt;br /&gt;
Setup functions and main loop.&lt;br /&gt;
&lt;br /&gt;
===color_cal(.c/.h)===&lt;br /&gt;
* .c: Contains void calibrate_color(void) function to run the calibration routine.&lt;br /&gt;
* .h: Contains function prototype and constant definitions for calibrate_color.&lt;br /&gt;
&lt;br /&gt;
=====void calibrate_color(void)=====&lt;br /&gt;
This function runs the color calibration routine. Eventually this should be turned into a separate e-puck command from the vision system. Currently it just runs the puck through a zig zag pattern on the floor and sends packets. You can collect these with the data logger and process them in matlab. From this, you should be able to get a calibration function.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To do:&#039;&#039;&#039;&lt;br /&gt;
* Add to the pattern. Need to collect more data.&lt;br /&gt;
* Possibly have the puck store data, find a best fit, and create the calibration function on board.&lt;br /&gt;
* Store the calibration function in the EEPROM (flash memory) so it&#039;s non-volatile. The coefficients of function will be specific to each puck, so it would be nice to not have to program each puck, each time you change the battery.&lt;br /&gt;
&lt;br /&gt;
===dsPIC_XBeePackets(.c/.h)===&lt;br /&gt;
* .c/.h: Contains functions and data structures for assembling and receiving XBee packets.&lt;br /&gt;
&lt;br /&gt;
=====int readPacket( void)=====&lt;br /&gt;
Parses XBee data from UART2. Makes it accessable in the &#039;&#039;InPacket&#039;&#039; struct.&lt;br /&gt;
&lt;br /&gt;
The UART2 receive ISR takes error codes from this function and flashes the corresponding puck LED (absolute value of the error code).&lt;br /&gt;
&lt;br /&gt;
Error codes are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	//////////////ERROR CODES/////////////////&lt;br /&gt;
	// &lt;br /&gt;
	// -1: Timeout waiting for UART2&lt;br /&gt;
	// -2: Start delimiter wrong&lt;br /&gt;
	// -3: Checksum Error&lt;br /&gt;
	// -4: UART2 not ready at beginning&lt;br /&gt;
	// -5: API_ID unidentified&lt;br /&gt;
	// -6: Send Packet CCA failuue&lt;br /&gt;
	// -7: Modem Status packet failure&lt;br /&gt;
	//////////////////////////////////////////&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===send_packet(.c/.h)===&lt;br /&gt;
* .c: Contains the void send_packet(void) function which fills an array with data and calls the needed XBee functions to send a packet.&lt;br /&gt;
* .h: Contains function prototype.&lt;br /&gt;
&lt;br /&gt;
=====void send_packet(void)=====&lt;br /&gt;
* Creates &#039;&#039;packet&#039;&#039; array.&lt;br /&gt;
* Adds consensus estimator data to the array.&lt;br /&gt;
* Adds robot statistics to the array.&lt;br /&gt;
* Adds color sensor values to the array.&lt;br /&gt;
* Asserts flow control line to stop XBee from sending&lt;br /&gt;
* Calls assemblePacket to send the packet.&lt;br /&gt;
* Deasserts flow control; Xbee can send again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function e_get_acc_filtered returns a running average of the acc specified. Syntax is:&lt;br /&gt;
&lt;br /&gt;
return value = e_get_acc_filtered(acc_channel, number of samples to average)&lt;br /&gt;
&lt;br /&gt;
The number of samples averaged must be less than ACC_SAMP_NB as defined in e_ad_conv.h.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
packet[i]=e_get_acc_filtered(2, 136); // red&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(1, 136); // green&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(0, 136); // blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PI_consensus_estimator(.h)===&lt;br /&gt;
* .h: Contains functions and data structures for the PI consensus estimator. &lt;br /&gt;
* This will probably be replaced by the algorithm for sensor consensus. &lt;br /&gt;
&lt;br /&gt;
===wheel_speed_coordinator(.c/.h)===&lt;br /&gt;
* .c: Contains functions for robot motion control&lt;br /&gt;
* .h: Function prototypes and variabls.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeed(int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speeds for the inertial consensus estimator based on the group goal.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeedSingleBot(float gotox, float gotoy, int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speed to get this individual bot to (gotox, gotoy). It&#039;s a hacked fix. Should be replaced with the 3 step motion controller from NUtest.c.&lt;br /&gt;
&lt;br /&gt;
===e_acc(.c/.h)===&lt;br /&gt;
* .c: Functions for reading the accelerometers (which is the color sensor).&lt;br /&gt;
* .h: Function prototypes.&lt;br /&gt;
&lt;br /&gt;
This is original e-puck library code with the following modifications:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
//changed by Sam, July 10, default offset is 2000. we want 0 for RGB sensor.&lt;br /&gt;
static int centre_z = 0;			//zero value for z axe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====int e_get_acc_filtered(unsigned int captor, unsigned int filter_size)=====&lt;br /&gt;
&lt;br /&gt;
===e_ad_conv(.c/.h)===&lt;br /&gt;
Set up the ADCs on the puck. Original e-puck library code, with the following modifications&lt;br /&gt;
* .h: Define constants and functional prototypes&lt;br /&gt;
&lt;br /&gt;
MIC_SAMP_FREQ sets the baseline sampling frequency for the ADC, everything else must be a fraction of this. 16384 Hz is the highest possible.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MIC_SAMP_FREQ 16384.0	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_PROX_SAMP_FREQ sets the sampling frequency for the accelerometers (color sensor). We found in testing that the puck become non-responsive with this set to 8192 Hz or 16384 Hz.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// sampling frequency for the accelerometres and proximetres&lt;br /&gt;
//#define ACC_PROX_SAMP_FREQ 256.0	// WARNING: should be a fraction of MIC_SAMP_FREQ&lt;br /&gt;
#define ACC_PROX_SAMP_FREQ 4096	//			to ensure a good timing precision&lt;br /&gt;
									// So your options are: 1  2  4  8  16  32  64  128  &lt;br /&gt;
									//  256  512  1024  2048  4096  8192  16384&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_SAMP_NB is the number of samples to store. We can do an average of &#039;&#039;up to&#039;&#039; this many samples. This is set to 140 so we can average 136 samples, which is 4 projector periods.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ACC_SAMP_NB  140	// number of accelerometer samples to store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* .c: Functions and interrupt service routines for ADCs. Original e-puck library, no modifications.&lt;br /&gt;
&lt;br /&gt;
=====e_init_ad_scan(ALL_ADC)=====&lt;br /&gt;
Call to setup ADC and have it work in the background. Use e_acc functions to access data.&lt;br /&gt;
&lt;br /&gt;
===e_init_port(.c/.h)===&lt;br /&gt;
* .c/.h: Initializes the ports on the e-puck. File is from the standard e-puck library. &lt;br /&gt;
&lt;br /&gt;
=====e_init_ports(void)=====&lt;br /&gt;
This function sets up ports on the e-puck. Call before using any ports.&lt;br /&gt;
&lt;br /&gt;
===e_led(.c/.h)===&lt;br /&gt;
* .c/.h: This is a standard e-puck library file that contains functions for manipulating LEDs.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_led(unsigned int led_number, unsigned int value)=====&lt;br /&gt;
Set led_number (0-7) to value (0=off 1=on higher=inverse).&lt;br /&gt;
&lt;br /&gt;
[[Image:e-puck_LED_numbering.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&#039;all&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===e_motors_swarm(.c/.h)===&lt;br /&gt;
* .c/.h: This file is a modified version of the e_motors.h e-puck library file.  This version keeps track of the robot&#039;s position and orientation, and the motor stepping function contains code to update the robot&#039;s position when the wheels turn. &lt;br /&gt;
* The functions like e_rotate and e_translate have been removed and this version is not dependent on e_agenda. &lt;br /&gt;
&lt;br /&gt;
=====#define POINT_OFFSET -31.75 =====&lt;br /&gt;
In addition to constants like wheel radius and wheel base, the offset between the center point of the bot and the point we&#039;re driving is set in e_motors_swarm.h. -31.75 mm is the distance betwene the center and the color sensor. So technically, we&#039;re driving backwards.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T5Interrupt(void)=====&lt;br /&gt;
Timer5 ISR, interrupt for left motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
    xpos = xpos + cval*LINSTEP;&lt;br /&gt;
    ypos = ypos + sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T4Interrupt(void)=====&lt;br /&gt;
Timer4 ISR, interrupt for right motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
	xpos = xpos - cval*LINSTEP;&lt;br /&gt;
    ypos = ypos - sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void e_init_motors(void)=====&lt;br /&gt;
Call this function before other motor functions to initialize the motors.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_speed_left(int motor_speed)/void e_set_speed_right(int motor_speed)=====&lt;br /&gt;
Set the motor speed in steps/second.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the center reference point.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_configuration(float x, float y, float theta)=====&lt;br /&gt;
Sets x, y, theta to values. This is used to overwrite the puck position/orientation estimates with data from the vision system.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration_front(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the front reference point (used for motor control).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;br /&gt;
[[Category:e-puck]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14399</id>
		<title>RGB Swarm Robot Project E-puck Code (outdated)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Project_E-puck_Code_(outdated)&amp;diff=14399"/>
		<updated>2009-09-10T20:58:26Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* To Do */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the e-puck code for the RGB Sensing Swarm Robotics project. The code on the e-puck was written in C and compiled using Microchip&#039;s MPLAB C Compiler for dsPIC DSCs (student version). &lt;br /&gt;
&lt;br /&gt;
This code is a branch of the [[Swarm Project E-puck Code]].&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===Complete===&lt;br /&gt;
* Got ADC working for color sensor&lt;br /&gt;
** Set up filtering to address projector PWM&lt;br /&gt;
* Restructured code to make more modular.&lt;br /&gt;
** Split dsPIC_XBeePackets and wheel_speed_coordinator into h and c files&lt;br /&gt;
** Pulled packet assembling code out of main and created send_packet() function in send_packet.h/c.&lt;br /&gt;
** Pulled a bunch of variables and defines (&#039;&#039;NUM_DATA_SETS, NUMBERS_PER_SET, DATATYPE_BYTELENGTH , DATA_ARRAY_LENGTH , ADDITIONAL_NUMS, notRTS, T1_INT_FLAG, x_i, u_i, w_i, x_sum, w_sum, MAX_WHEEL_V_TICKS, deadband, COMMR, SAFEDIST, MINDIST, u_x_ideal, u_y_ideal, x_motion_integral, y_motion_integral, SQUARE&#039;&#039;) that were scattered across h files into global_vars.h/c. Makes it easy to include them in a particular file with the &#039;&#039;extern&#039;&#039; keyword.&lt;br /&gt;
* Added color_cal() function in color_cal.h/c&lt;br /&gt;
* Added wheelSpeedSingleBot to wheel_speed_coordinator&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
* Finish color calibration (color_cal) algorithm, to facilitate simple calibration for each e-puck that does not require large amount of data collected for each run, and with minimal user input/control (desire automation and simplification)&lt;br /&gt;
* Improve the vision system position information updater&lt;br /&gt;
** So that the e-puck does not automatically assume every packet from the Vision System is true, rather &#039;checks&#039; for accuracy&lt;br /&gt;
* Replace wheelSpeedSingleBot with the three step move controller from NUtest.c&lt;br /&gt;
**Implement this so that the e-puck can be moved with position and orientation (this is ideal so that data from every orientation of the e-puck can be recorded while calibrating or collecting data&lt;br /&gt;
* Implement new algorithm from paper&lt;br /&gt;
&lt;br /&gt;
==Project Package==&lt;br /&gt;
The source code for the project is available here: [[Media:RGB_Swarm_Puck_Code_working_version.zip]]. Open swarm_epucks.mcw and you should be good to go.&lt;br /&gt;
&lt;br /&gt;
==Description of the files and functions==&lt;br /&gt;
&lt;br /&gt;
===global_vars(.c/.h)===&lt;br /&gt;
* .c/.h: declare and define global variables and macros&lt;br /&gt;
====Packet Length Constants====&lt;br /&gt;
These variables determine the length of the XBee packets.  See [[Swarm_Robot_Project_Documentation#Data_Frame|Data Frame]] and the section on XBee API packets in the XBee manual for further clarification.&lt;br /&gt;
&lt;br /&gt;
Much of this is still sending integral consensus estimator data. This can be removed or replaces with data needed for decentralized color sensing. &lt;br /&gt;
&lt;br /&gt;
=====#define NUM_DATA_SETS 5 =====	&lt;br /&gt;
Number of statistics on which you are running the consensus estimator.  This this particular case, 5. (Ix, Iy, Ixx, Ixy, Iyy)&lt;br /&gt;
&lt;br /&gt;
=====#define NUMBERS_PER_SET 2=====&lt;br /&gt;
Number of variables in each data set (see above) that the consensus estimator needs to transmit to other agents.  In this case, 2 because there is &amp;lt;tt&amp;gt;x_i&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;w_i&amp;lt;/tt&amp;gt; for each statistic.&lt;br /&gt;
&lt;br /&gt;
=====#define DATATYPE_BYTELENGTH 4	=====&lt;br /&gt;
Number of bytes in the data type (used in the consensus estimator (float = 4 bytes long).  This is important because we need to split the numbers into individual bytes to be able to send them out the serial port.&lt;br /&gt;
&lt;br /&gt;
=====#define DATA_ARRAY_LENGTH (NUM_DATA_SETS*NUMBERS_PER_SET)=====&lt;br /&gt;
Total number of data variables needed for the consensus estimator.  In this case, it is 5*2=10.&lt;br /&gt;
&lt;br /&gt;
=====#define ADDITIONAL_NUMS 8=====&lt;br /&gt;
Additional number of data to be appended to data array.  It is 5 in this case, so that we can append &lt;br /&gt;
# Robot X coordinate&lt;br /&gt;
# Robot Y coordinate&lt;br /&gt;
# Robot Theta orientation&lt;br /&gt;
# Robot left wheel speed&lt;br /&gt;
# Robot right wheel speed&lt;br /&gt;
# Sensor Red Value&lt;br /&gt;
# Sensor Green Value&lt;br /&gt;
# Sensor Blue Value&lt;br /&gt;
&lt;br /&gt;
===main(.c/.h)===&lt;br /&gt;
* .c: This contains the entry point of the code and contains the initialization routines, main loop, and interrupt service routines. &lt;br /&gt;
* .h: Contains variables, function prototypes, and delay function needed for main.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _T1Interrupt(void)=====&lt;br /&gt;
Timer1 ISR. Sets T1_INT_FLAG which provides timing for the main loop.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void)=====&lt;br /&gt;
UART2 receive ISR. Runs with the XBee receives packets. The switch/case structure handles the packets.&lt;br /&gt;
&lt;br /&gt;
The current handling of coordinate data from the vision system: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
case 0: //coordinate data&lt;br /&gt;
					e_set_configuration(&lt;br /&gt;
					InPacket.data[1].dataFloat,&lt;br /&gt;
					InPacket.data[2].dataFloat, &lt;br /&gt;
					InPacket.data[3].dataFloat);&lt;br /&gt;
					break;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Needs to be improved. Suggested new function:&lt;br /&gt;
&lt;br /&gt;
* Get vision system data&lt;br /&gt;
* Check if it&#039;s wildly off from current puck estimate&lt;br /&gt;
** If not, update, clear log of rejected packets&lt;br /&gt;
** If so, reject and log&lt;br /&gt;
*** If we have rejected enough packets (some threshold) and they&#039;ve all been in similar place (within tolerance), we can assume the puck is wrong and vision system is right. In this case, update with vision system data and clear rejected data log.&lt;br /&gt;
&lt;br /&gt;
=====int main(void)=====&lt;br /&gt;
Setup functions and main loop.&lt;br /&gt;
&lt;br /&gt;
===color_cal(.c/.h)===&lt;br /&gt;
* .c: Contains void calibrate_color(void) function to run the calibration routine.&lt;br /&gt;
* .h: Contains function prototype and constant definitions for calibrate_color.&lt;br /&gt;
&lt;br /&gt;
=====void calibrate_color(void)=====&lt;br /&gt;
This function runs the color calibration routine. Eventually this should be turned into a separate e-puck command from the vision system. Currently it just runs the puck through a zig zag pattern on the floor and sends packets. You can collect these with the data logger and process them in matlab. From this, you should be able to get a calibration function.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To do:&#039;&#039;&#039;&lt;br /&gt;
* Add to the pattern. Need to collect more data.&lt;br /&gt;
* Possibly have the puck store data, find a best fit, and create the calibration function on board.&lt;br /&gt;
* Store the calibration function in the EEPROM (flash memory) so it&#039;s non-volatile. The coefficients of function will be specific to each puck, so it would be nice to not have to program each puck, each time you change the battery.&lt;br /&gt;
&lt;br /&gt;
===dsPIC_XBeePackets(.c/.h)===&lt;br /&gt;
* .c/.h: Contains functions and data structures for assembling and receiving XBee packets.&lt;br /&gt;
&lt;br /&gt;
=====int readPacket( void)=====&lt;br /&gt;
Parses XBee data from UART2. Makes it accessable in the &#039;&#039;InPacket&#039;&#039; struct.&lt;br /&gt;
&lt;br /&gt;
The UART2 receive ISR takes error codes from this function and flashes the corresponding puck LED (absolute value of the error code).&lt;br /&gt;
&lt;br /&gt;
Error codes are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	//////////////ERROR CODES/////////////////&lt;br /&gt;
	// &lt;br /&gt;
	// -1: Timeout waiting for UART2&lt;br /&gt;
	// -2: Start delimiter wrong&lt;br /&gt;
	// -3: Checksum Error&lt;br /&gt;
	// -4: UART2 not ready at beginning&lt;br /&gt;
	// -5: API_ID unidentified&lt;br /&gt;
	// -6: Send Packet CCA failuue&lt;br /&gt;
	// -7: Modem Status packet failure&lt;br /&gt;
	//////////////////////////////////////////&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===send_packet(.c/.h)===&lt;br /&gt;
* .c: Contains the void send_packet(void) function which fills an array with data and calls the needed XBee functions to send a packet.&lt;br /&gt;
* .h: Contains function prototype.&lt;br /&gt;
&lt;br /&gt;
=====void send_packet(void)=====&lt;br /&gt;
* Creates &#039;&#039;packet&#039;&#039; array.&lt;br /&gt;
* Adds consensus estimator data to the array.&lt;br /&gt;
* Adds robot statistics to the array.&lt;br /&gt;
* Adds color sensor values to the array.&lt;br /&gt;
* Asserts flow control line to stop XBee from sending&lt;br /&gt;
* Calls assemblePacket to send the packet.&lt;br /&gt;
* Deasserts flow control; Xbee can send again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function e_get_acc_filtered returns a running average of the acc specified. Syntax is:&lt;br /&gt;
&lt;br /&gt;
return value = e_get_acc_filtered(acc_channel, number of samples to average)&lt;br /&gt;
&lt;br /&gt;
The number of samples averaged must be less than ACC_SAMP_NB as defined in e_ad_conv.h.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
packet[i]=e_get_acc_filtered(2, 136); // red&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(1, 136); // green&lt;br /&gt;
	i++;&lt;br /&gt;
	packet[i]=e_get_acc_filtered(0, 136); // blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PI_consensus_estimator(.h)===&lt;br /&gt;
* .h: Contains functions and data structures for the PI consensus estimator. &lt;br /&gt;
* This will probably be replaced by the algorithm for sensor consensus. &lt;br /&gt;
&lt;br /&gt;
===wheel_speed_coordinator(.c/.h)===&lt;br /&gt;
* .c: Contains functions for robot motion control&lt;br /&gt;
* .h: Function prototypes and variabls.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeed(int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speeds for the inertial consensus estimator based on the group goal.&lt;br /&gt;
&lt;br /&gt;
=====void wheelSpeedSingleBot(float gotox, float gotoy, int *vL, int *vR)=====&lt;br /&gt;
Return needed wheel speed to get this individual bot to (gotox, gotoy). It&#039;s a hacked fix. Should be replaced with the 3 step motion controller from NUtest.c.&lt;br /&gt;
&lt;br /&gt;
===e_acc(.c/.h)===&lt;br /&gt;
* .c: Functions for reading the accelerometers (which is the color sensor).&lt;br /&gt;
* .h: Function prototypes.&lt;br /&gt;
&lt;br /&gt;
This is original e-puck library code with the following modifications:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
//changed by Sam, July 10, default offset is 2000. we want 0 for RGB sensor.&lt;br /&gt;
static int centre_z = 0;			//zero value for z axe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====int e_get_acc_filtered(unsigned int captor, unsigned int filter_size)=====&lt;br /&gt;
&lt;br /&gt;
===e_ad_conv(.c/.h)===&lt;br /&gt;
Set up the ADCs on the puck. Original e-puck library code, with the following modifications&lt;br /&gt;
* .h: Define constants and functional prototypes&lt;br /&gt;
&lt;br /&gt;
MIC_SAMP_FREQ sets the baseline sampling frequency for the ADC, everything else must be a fraction of this. 16384 Hz is the highest possible.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define MIC_SAMP_FREQ 16384.0	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_PROX_SAMP_FREQ sets the sampling frequency for the accelerometers (color sensor). We found in testing that the puck become non-responsive with this set to 8192 Hz or 16384 Hz.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// sampling frequency for the accelerometres and proximetres&lt;br /&gt;
//#define ACC_PROX_SAMP_FREQ 256.0	// WARNING: should be a fraction of MIC_SAMP_FREQ&lt;br /&gt;
#define ACC_PROX_SAMP_FREQ 4096	//			to ensure a good timing precision&lt;br /&gt;
									// So your options are: 1  2  4  8  16  32  64  128  &lt;br /&gt;
									//  256  512  1024  2048  4096  8192  16384&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACC_SAMP_NB is the number of samples to store. We can do an average of &#039;&#039;up to&#039;&#039; this many samples. This is set to 140 so we can average 136 samples, which is 4 projector periods.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ACC_SAMP_NB  140	// number of accelerometer samples to store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* .c: Functions and interrupt service routines for ADCs. Original e-puck library, no modifications.&lt;br /&gt;
&lt;br /&gt;
=====e_init_ad_scan(ALL_ADC)=====&lt;br /&gt;
Call to setup ADC and have it work in the background. Use e_acc functions to access data.&lt;br /&gt;
&lt;br /&gt;
===e_init_port(.c/.h)===&lt;br /&gt;
* .c/.h: Initializes the ports on the e-puck. File is from the standard e-puck library. &lt;br /&gt;
&lt;br /&gt;
=====e_init_ports(void)=====&lt;br /&gt;
This function sets up ports on the e-puck. Call before using any ports.&lt;br /&gt;
&lt;br /&gt;
===e_led(.c/.h)===&lt;br /&gt;
* .c/.h: This is a standard e-puck library file that contains functions for manipulating LEDs.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_led(unsigned int led_number, unsigned int value)=====&lt;br /&gt;
Set led_number (0-7) to value (0=off 1=on higher=inverse).&lt;br /&gt;
&lt;br /&gt;
[[Image:e-puck_LED_numbering.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&#039;all&#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===e_motors_swarm(.c/.h)===&lt;br /&gt;
* .c/.h: This file is a modified version of the e_motors.h e-puck library file.  This version keeps track of the robot&#039;s position and orientation, and the motor stepping function contains code to update the robot&#039;s position when the wheels turn. &lt;br /&gt;
* The functions like e_rotate and e_translate have been removed and this version is not dependent on e_agenda. &lt;br /&gt;
&lt;br /&gt;
=====#define POINT_OFFSET -31.75 =====&lt;br /&gt;
In addition to constants like wheel radius and wheel base, the offset between the center point of the bot and the point we&#039;re driving is set in e_motors_swarm.h. -31.75 mm is the distance betwene the center and the color sensor. So technically, we&#039;re driving backwards.&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T5Interrupt(void)=====&lt;br /&gt;
Timer5 ISR, interrupt for left motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
    xpos = xpos + cval*LINSTEP;&lt;br /&gt;
    ypos = ypos + sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void __attribute__((interrupt, auto_psv, shadow)) _T4Interrupt(void)=====&lt;br /&gt;
Timer4 ISR, interrupt for right motor. Controls the stepper motors.&lt;br /&gt;
&lt;br /&gt;
Updates the pucks x, y, theta estimate here: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
	// update robot&#039;s configuration estimate&lt;br /&gt;
	thetapos = thetapos - ANGSTEP;&lt;br /&gt;
    if (thetapos&amp;lt;-PI) thetapos += 2*PI;&lt;br /&gt;
	xpos = xpos - cval*LINSTEP;&lt;br /&gt;
    ypos = ypos - sval*LINSTEP;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====void e_init_motors(void)=====&lt;br /&gt;
Call this function before other motor functions to initialize the motors.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_speed_left(int motor_speed)/void e_set_speed_right(int motor_speed)=====&lt;br /&gt;
Set the motor speed in steps/second.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the center reference point.&lt;br /&gt;
&lt;br /&gt;
=====void e_set_configuration(float x, float y, float theta)=====&lt;br /&gt;
Sets x, y, theta to values. This is used to overwrite the puck position/orientation estimates with data from the vision system.&lt;br /&gt;
&lt;br /&gt;
=====void e_get_configuration_front(float *xptr, float *yptr, float *thetaptr)=====&lt;br /&gt;
Updates variables with current x, t, and theta (position and orientation) of the front reference point (used for motor control).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;br /&gt;
[[Category:e-puck]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14398</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14398"/>
		<updated>2009-09-10T20:50:00Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Programming the XBee Radio */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|RGB Swarm Robot Project]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the blue is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Additional Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14397</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14397"/>
		<updated>2009-09-10T20:49:20Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* e-puck and e-puck Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|RGB Swarm Robot Project]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check for the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039; line at the end of the dialog box, save and close the workspace, and then look for the new .hex file in the folder that the .mcw file is in&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the blue is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Additional Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14396</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14396"/>
		<updated>2009-09-10T20:47:53Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: /* Checklist */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|RGB Swarm Robot Project]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (2005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check to make sure that the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039;, and then look for the new .hex file in the same folder where the .mcw file was&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the blue is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Additional Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14395</id>
		<title>RGB Swarm Robot Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=RGB_Swarm_Robot_Quickstart_Guide&amp;diff=14395"/>
		<updated>2009-09-10T20:47:38Z</updated>

		<summary type="html">&lt;p&gt;Jonathan Lee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
This guide was written as a quickstart guide for the [[RGB_Swarm_Robot_Project|RGB Swarm Robot Project]], but contains general information about programming e-pucks and using the vision system.&lt;br /&gt;
==Checklist==&lt;br /&gt;
*Physical Set Up&lt;br /&gt;
**Follow the setup as described in [[RGB_Swarm_Robot_Project#Physical_Setup|&#039;&#039;&#039;RGB Swarm Robot Project: Physical Setup&#039;&#039;&#039;]]&lt;br /&gt;
**In addition, there needs to be a computer connected to the vision system webcams, as well as to a computer to act as a data logger (this can be the same computer)&lt;br /&gt;
***Each analytical program run will need its own XBee radio, more information on this below&lt;br /&gt;
*Equipment Needed&lt;br /&gt;
**e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards&lt;br /&gt;
**XBee radio serial adapter boards with radios&lt;br /&gt;
***Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program&lt;br /&gt;
***A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program&lt;br /&gt;
**A bluetooth adapter, internal or external&lt;br /&gt;
*Computer Programs Needed&lt;br /&gt;
**X-CTU, download at the [http://www.digi.com/support/productdetl.jsp?pid=3352&amp;amp;osvid=57&amp;amp;tp=5&amp;amp;s=316 &#039;&#039;&#039;Digi X-CTU Download&#039;&#039;&#039;]&lt;br /&gt;
**Tiny Bootloader, download at [http://www.etc.ugal.ro/cchiculita/software/tinyblddownload.htm &#039;&#039;&#039;Tiny Bootloader 1.9.8&#039;&#039;&#039;]&lt;br /&gt;
**Visual Studio (23005 or 2008)&lt;br /&gt;
**These are needed to edit and build the code&lt;br /&gt;
***Microchip MPLAB&lt;br /&gt;
***Microchip MPLAB dsPIC C compiler&lt;br /&gt;
&lt;br /&gt;
==Computer Setup==&lt;br /&gt;
*Download this&lt;br /&gt;
*Set up that&lt;br /&gt;
==e-puck and e-puck Code==&lt;br /&gt;
*[[media:RGB_Swarm_Puck_Code_working_version.zip‎|&#039;&#039;&#039;RGB_Swarm_Puck_Code_working_version.zip‎‎&#039;&#039;&#039;]] This is the RGB Swarm code for the e-puck; install via directions below&lt;br /&gt;
===Preparing the e-puck code===&lt;br /&gt;
*The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to [[RGB_Swarm_Quickstart_Guide#Connecting_the_e-puck|&#039;&#039;&#039;Connecting the e-puck&#039;&#039;&#039;]]&lt;br /&gt;
**&#039;&#039;&#039;Note:&#039;&#039;&#039; if you cannot find this .hex file, or you have changed the code, follow the steps below&lt;br /&gt;
*To compile the code follow these steps&lt;br /&gt;
#Open the workspace file (extension .mcw) of your project/code&lt;br /&gt;
#Click the &#039;&#039;&#039;Build All&#039;&#039;&#039; button  (looks like a stack of papers getting pushed down by two arrows)&lt;br /&gt;
#Check to make sure that the &#039;&#039;&#039;BUILD SUCCEEDED&#039;&#039;&#039;, and then look for the new .hex file in the same folder where the .mcw file was&lt;br /&gt;
#*This will be the .hex file you use for programming and uploading onto the e-puck&lt;br /&gt;
&lt;br /&gt;
===Connecting the e-puck===&lt;br /&gt;
#Go to start menu &amp;gt;&amp;gt; control panel &amp;gt;&amp;gt; Bluetooth Devices&lt;br /&gt;
#Click the &#039;&#039;&#039;&#039;Add...&#039;&#039;&#039;&#039; button in the lower left of the dialog window&lt;br /&gt;
#*Turn on the e-puck that you wish to configure/connect to the computer&lt;br /&gt;
#*Check the box next to &#039;&#039;&#039;&#039;My device is set up and ready to be found.&#039;&#039;&#039;&#039;&lt;br /&gt;
#*Continue with the &#039;&#039;&#039;Next&#039;&#039;&#039; button, and the computer will search for your e-puck&lt;br /&gt;
#Once the computer finds your e-puck, select the appropriate e-puck (should be ID&#039;d by the 4 digit ID number), and assign the 4 digit ID number as the &#039;passkey&#039; for that e-puck&lt;br /&gt;
#*This process reserves a pair of COM(serial) port for that specific e-puck, one as &#039;&#039;&#039;Incoming&#039;&#039;&#039; and the other as &#039;&#039;&#039;Outgoing&#039;&#039;&#039;; each e-puck will have a different pair of ports&lt;br /&gt;
#Return to the Bluetooth Devices Dialog screen, and click on the &#039;&#039;&#039;COM Ports&#039;&#039;&#039; tab&lt;br /&gt;
#Check which COM ports are assigned to your e-puck, specifically the &#039;&#039;&#039;Outgoing&#039;&#039;&#039; COM port; this COM port will be used when programming this e-puck with the TinyBootloader program&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; if using a USB Bluetooth dongle, when the dongle is unplugged and replugged it into a different USB port, or a different dongle altogether is used, it may be necessary to repeat these steps for each e-puck that you wish to use&lt;br /&gt;
*&#039;&#039;&#039;Note:&#039;&#039;&#039; these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS&lt;br /&gt;
&lt;br /&gt;
===Programming the e-puck===&lt;br /&gt;
:&#039;&#039;Refer to:&#039;&#039; [[Swarm_E-puck_Quickstart_Guide#Programming_the_e-puck|&#039;&#039;Swarm E-puck Quickstart Guide: Programming the e-puck&#039;&#039;]]&lt;br /&gt;
Programming the e-puck requires a specific program, called a &#039;&#039;bootloader&#039;&#039;, in order to (re)program the microcontroller. The bootloader makes use of the bluetooth/serial port connection, allowing for wireless programming, as opposed to connecting a specific serial port connector directly to the microcontroller. This expedites the reprogramming process. The bootloader is comprised of two parts, one which operates on the e-puck, writing code to the e-puck microcontroller, and the other, which operates on the computer as user interface. On the e-puck side, the bootloader quickly checks to see if something is trying to re-program the PIC. If so, the bootloader will simply write the new software over the old, and then run the new software. If not, the bootloader simply allows the PIC to run the program currently loaded. The computer side allows a user to select which COM port to program over (allowing one to select which e-puck to program), and selecting what HEX file to program to the e-puck.&lt;br /&gt;
&lt;br /&gt;
To program the e-puck with a bootloader, follow these instructions:&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: you will have to compile and build the C code from the Microchip C compiler, as the .hex file is needed to install onto the e-puck&lt;br /&gt;
#Start the Tiny Bootloader program on your computer&lt;br /&gt;
#Click the &#039;&#039;&#039;Browse&#039;&#039;&#039; button and select the .hex file that corresponds to the e-puck code that you want to program&lt;br /&gt;
#Set &#039;&#039;&#039;115200&#039;&#039;&#039; under the &#039;&#039;&#039;Comm&#039;&#039;&#039; dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck&lt;br /&gt;
#Click the &#039;&#039;&#039;Write Flash&#039;&#039;&#039; button&lt;br /&gt;
#Immediately click the blue reset button on the e-puck&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.&lt;br /&gt;
#Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made&lt;br /&gt;
&lt;br /&gt;
====e-puck Troubleshooting====&lt;br /&gt;
* If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you&#039;ve selected the correct COM port assigned to the e-puck (the ID of the e-puck is on a sticker on top of the bluetooth chip on the e-puck&#039;s PCB.&lt;br /&gt;
* If Tiny Bootloader can connect to the e-puck but cannot find the PIC, it may be that someone has overwritten the bootloader with another program. If this is the case, you will need to reload the bootloader.&lt;br /&gt;
#MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck&lt;br /&gt;
#Go to [http://www.e-puck.org http://www.e-puck.org], goto &#039;&#039;&#039;Download &amp;gt;&amp;gt; Software &amp;gt;&amp;gt; Library&#039;&#039;&#039;, download the zip file, and extract the archive&lt;br /&gt;
#Navigate to &#039;&#039;&#039;e-puck-lib\tool\bootloader\epuck_side&#039;&#039;&#039;, look for &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; hex file.&lt;br /&gt;
#Open MPLAB&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Select Programmer &amp;gt;&amp;gt; MPLAB ICD 2&#039;&#039;&#039;&lt;br /&gt;
#Go to &#039;&#039;&#039;File &amp;gt;&amp;gt; Import&#039;&#039;&#039;&lt;br /&gt;
#Select the &amp;lt;tt&amp;gt;tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex&amp;lt;/tt&amp;gt; file&lt;br /&gt;
#Go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Connect&#039;&#039;&#039;, and when connected, go to &#039;&#039;&#039;Programmer &amp;gt;&amp;gt; Program&#039;&#039;&#039;&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient&lt;br /&gt;
&lt;br /&gt;
==XBee Radio==&lt;br /&gt;
===Programming the XBee Radio===&lt;br /&gt;
:&#039;&#039;Refer to: [[Swarm_Robot_Project_Documentation#Configuration_for_e-puck_XBee_radios|Configuration for e-puck XBee radios]]&#039;&#039;&lt;br /&gt;
These steps are for programming the Xbee Radio, whether for the e-puck or the data logging or vision computers. Certain steps may be skipped however for each kind of radio.&lt;br /&gt;
*&#039;&#039;&#039;Note&#039;&#039;&#039;: In order to program the e-puck radio, it will be necessary to remove the XBee radio from the e-puck and place it in one of the Serial Port Adapters connected to the computer&lt;br /&gt;
#Start the X-CTU program&lt;br /&gt;
#Under the &#039;&#039;&#039;PC Settings&#039;&#039;&#039; tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left&lt;br /&gt;
#Set the &#039;&#039;&#039;Baud&#039;&#039;&#039; to &#039;&#039;&#039;115200&#039;&#039;&#039;, and leave the other settings alone/standard&lt;br /&gt;
#Hit the &#039;&#039;&#039;Test/Query&#039;&#039;&#039; button to ensure that X-CTU can see/hear your radio&lt;br /&gt;
#*&#039;&#039;&#039;Note&#039;&#039;&#039;: If there is difficulty connecting, or the XBee radio cannot be found, it may be necessary to try every frequency listed. X-CTU does not automatically detect what the Baud on the radio is, and while the radios currently used are all set to have a Baud of 115200, they may be reset, and it will be necessary to manually test each Baud freqency via X-CTU.&lt;br /&gt;
#Upon success, a dialog box should display &#039;Communication with modem.. OK&#039;, &#039;Modem Type = &amp;lt;something&amp;gt;&#039;, and Modem firmware vision = &amp;lt;other thing&amp;gt;&#039;; click &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
#If there are no problems connecting, switch the X-CTU program to the &#039;&#039;&#039;Terminal&#039;&#039;&#039; tab&lt;br /&gt;
#In the blank terminal screen, type the following commands below&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;+++&#039;&#039;&#039;&#039;, and press &amp;lt;enter&amp;gt;. this signals to the XBee radio that you wish to program it. &lt;br /&gt;
##*Wait until the radio responds with &#039;&#039;&#039;OK&#039;&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atre&#039;&#039;&#039;&#039;. This command resets the settings of the XBee radio.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atmy&#039;&#039;&#039;&#039;, followed with the ID number, e.g. your command would be &#039;&#039;&#039;&#039;atmy 3&#039;&#039;&#039;&#039;. This command sets the XBee radio ID.&lt;br /&gt;
##*Note, that e-puck ID&#039;s are from &#039;&#039;&#039;1-31&#039;&#039;&#039;, whereas all the computer radios have an ID of &#039;&#039;&#039;0&#039;&#039;&#039;.&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atap 2&#039;&#039;&#039;&#039;. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atd6 1&#039;&#039;&#039;&#039;. This is related to the RTS pin, and allows the radio to hold packets in buffer&lt;br /&gt;
##*&#039;&#039;&#039;Note: SKIP THIS STEP&#039;&#039;&#039; if you are programming a &#039;&#039;computer Xbee radio&#039;&#039;, such as for the &#039;&#039;vision system&#039;&#039; or &#039;&#039;data logger.&#039;&#039;&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atbd 7&#039;&#039;&#039;&#039;. This sets the Baud to 115200, the frequency used for radios in this project&lt;br /&gt;
##Type &#039;&#039;&#039;&#039;atwr&#039;&#039;&#039;&#039;. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.&lt;br /&gt;
===Troubleshooting the XBee Radios===&lt;br /&gt;
*XBee radios can only be used by one program at a time, and if an XBee radio is being called by two different programs, this may lead to problems. This is due to the fact that each XBee radio is connected to one &#039;virtual&#039; COM port, and said COM port can be used by only one program &#039;&#039;at a time&#039;&#039;.&lt;br /&gt;
**For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems&lt;br /&gt;
**If running multiple RGB Swarm programs on one computer, such as the Vision System and the Matlab RGB Swarm Data Grabber program, two XBee radios with two serial port adapters will be needed&lt;br /&gt;
***However, both radios will and must be ID&#039;d as &#039;&#039;&#039;0&#039;&#039;&#039; even though they are to different programs&lt;br /&gt;
*Try some of these steps if your XBee radios do not seem to be working&lt;br /&gt;
**&#039;&#039;&#039;&#039;Not getting any signal from the e-puck XBee radios&#039;&#039;&#039;&#039; or &#039;&#039;&#039;&#039;E-pucks are not getting any signal from the computer radios&#039;&#039;&#039;&#039;&lt;br /&gt;
***&#039;&#039;&#039;Check the serial port adapter boards&#039;&#039;&#039;: towards the back of the board near where the blue is, there are two columns of three (3) LED lights. The left most column of lights should be blinking. The yellow light signifies that a packet is has been received, and a green light signifies that a packet is being sent.&lt;br /&gt;
***&#039;&#039;&#039;Check the e-pucks&#039;&#039;&#039;: the e-pucks should be blinking a red light at the back of the e-puck (where the 4 digit ID is) every time a packet is sent from the e-puck&lt;br /&gt;
***&#039;&#039;&#039;Check the XBee radio settings&#039;&#039;&#039;: occasionally, the Vision System or Matlab software can corrupt and reset the settings on their respective XBee radios. Make sure that these settings are correct. Do this also for the XBee radios on the e-pucks (just try one radio first to see if that fixes the problem; rather than doing them all and realizing the problem still exists)&lt;br /&gt;
&lt;br /&gt;
==Machine Vision Localization System==&lt;br /&gt;
*[[media:RGB_Machine_Vision_Localization_System.zip|&#039;&#039;&#039;RGB_Machine_Vision_Localization_System.zip&#039;&#039;&#039;]]&lt;br /&gt;
===Machine Vision Localization System Setup===&lt;br /&gt;
#Connect an Xbee Radio to the computer being used as the &#039;Vision PC&#039;&lt;br /&gt;
#Follow the directions in the [[Machine_Vision_Localization_System#Operation|&#039;&#039;&#039;Machine Vision Localization System: Operation&#039;&#039;&#039;]] entry; note the &#039;&#039;&#039;Computer Setup&#039;&#039;&#039; instructions&lt;br /&gt;
#*Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.&lt;br /&gt;
#Place robots into the field of view of the Vision System, and turn on the LED pattern boards&lt;br /&gt;
#Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly&lt;br /&gt;
#Click on the vision system GUI window, and hit the &#039;&#039;&#039;&#039;C&#039;&#039;&#039;&#039; key to enter the &#039;command&#039; mode.&lt;br /&gt;
#*Command the e-pucks following the command scheme as discussed in the [[Machine_Vision_Localization_System#Using_the_Command_Console|&#039;&#039;&#039;Machine Vision Localization System: Using the Command Console&#039;&#039;&#039;]] entry&lt;br /&gt;
#*It is necessary to set the speed of the e-pucks as well as wake the e-pucks before they will begin to move around&lt;br /&gt;
&lt;br /&gt;
===Vision System Troubleshooting===&lt;br /&gt;
*Getting failure window when trying to send out commands?&lt;br /&gt;
**Problems often arise if the COM port you instruct the Vision System to use in the very first dialog window that opens after starting the project is incorrect, being used by another program, or not set correctly&lt;br /&gt;
**#Make sure no other programs are using or connecting to your XBee Radio &amp;gt;&amp;gt; e.g. X-CTU  (remember to close X-CTU), Matlab, or another Visual Studio Program)&lt;br /&gt;
**#Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios&lt;br /&gt;
**#Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem&lt;br /&gt;
*Vision System not picking up or identifying e-pucks?&lt;br /&gt;
**With the dark tent set up, it can be difficult for the Vision System to discern individual lights due to automatically adjusting exposures, resulting in &#039;blobbier&#039; target masses&lt;br /&gt;
**#Try changing the threshold resolution, the stock setting is 240; changing it up reduces the amount of noise, changing it down increases the amount capture/targeted&lt;br /&gt;
**#If possible, increase the amount of ambient light projected onto the floor, this can reduce the web camera exposure and can clear up the targets&lt;br /&gt;
&lt;br /&gt;
==Additional Tools==&lt;br /&gt;
===Matlab Tools===&lt;br /&gt;
===Visual Studio Tools===&lt;br /&gt;
&lt;br /&gt;
[[Category:e-puck]]&lt;br /&gt;
[[Category:SwarmRobotProject]]&lt;/div&gt;</summary>
		<author><name>Jonathan Lee</name></author>
	</entry>
</feed>