RGB Swarm Robot Quickstart Guide
This guide was written as a quickstart guide for the RGB Swarm Robot Project, but contains general information about programming e-pucks and using the vision system.
Checklist
- Physical Set Up
- Follow the setup as described in RGB Swarm Robot Project: Physical Setup
- 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)
- Each analytical program run will need its own XBee radio, more information on this below
- Equipment Needed
- e-pucks with XBee radios, XBee Interface Extension Boards Version 2, and LED Pattern Boards
- XBee radio serial adapter boards with radios
- Each analytical program run on the computer requires its own XBee radio, as a radio cannot be shared from program to program
- A simple set up may requires only two (2) radios, one for the Vision System program, and another for a data logging program
- A bluetooth adapter, internal or external
- Computer Programs Needed
- X-CTU, download at the Digi X-CTU Download
- Tiny Bootloader, download at Tiny Bootloader 1.9.8
- Visual Studio (2005 or 2008)
- These are needed to edit and build the code
- Microchip MPLAB
- Microchip MPLAB dsPIC C compiler
Computer Setup
- Download this
- Set up that
e-puck and e-puck Code
- RGB_Swarm_Puck_Code_working_version.zip This is the RGB Swarm code for the e-puck; install via directions below
Preparing the e-puck code
- The code above comes with with a compiled and built .hex file, which is ready to be uploaded onto the e-puck, skip to Connecting the e-puck
- Note: if you cannot find this .hex file, or you have changed the code, follow the steps below
- To compile the code follow these steps
- Open the workspace file (extension .mcw) of your project/code
- Click the Build All button (looks like a stack of papers getting pushed down by two arrows)
- Check for the BUILD SUCCEEDED 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
- This will be the .hex file you use for programming and uploading onto the e-puck
Connecting the e-puck
- Go to start menu >> control panel >> Bluetooth Devices
- Click the 'Add...' button in the lower left of the dialog window
- Turn on the e-puck that you wish to configure/connect to the computer
- Check the box next to 'My device is set up and ready to be found.'
- Continue with the Next button, and the computer will search for your e-puck
- Once the computer finds your e-puck, select the appropriate e-puck (should be ID'd by the 4 digit ID number), and assign the 4 digit ID number as the 'passkey' for that e-puck
- This process reserves a pair of COM(serial) port for that specific e-puck, one as Incoming and the other as Outgoing; each e-puck will have a different pair of ports
- Return to the Bluetooth Devices Dialog screen, and click on the COM Ports tab
- Check which COM ports are assigned to your e-puck, specifically the Outgoing COM port; this COM port will be used when programming this e-puck with the TinyBootloader program
- Note: 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
- Note: these instructions are for using Windows XP Professional Edition. The exact command paths and dialog boxes may differ from OS to OS
Programming the e-puck
Programming the e-puck requires a specific program, called a bootloader, 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.
To program the e-puck with a bootloader, follow these instructions:
- Note: 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
- Start the Tiny Bootloader program on your computer
- Click the Browse button and select the .hex file that corresponds to the e-puck code that you want to program
- Set 115200 under the Comm dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck
- Click the Write Flash button
- Immediately click the blue reset button on the e-puck
- Note: The reset button must be clicked before the blue status bar on the Tiny Bootloader dialog screen reaches zero, representing the program timing out.
- Once the bootloader starts writing software, the blue status bar will grow, representing code being uploaded and programmed
- Note: In addition to the blue status bar, a orange LED on the e-puck will light up, signaling that a connection has been made
e-puck Troubleshooting
- If Tiny Bootloader cannot connect to the COM port, make sure your e-puck is on, and that you'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's PCB.
- 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.
- MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck
- Go to http://www.e-puck.org, goto Download >> Software >> Library, download the zip file, and extract the archive
- Navigate to e-puck-lib\tool\bootloader\epuck_side, look for tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex hex file.
- Open MPLAB
- Go to Programmer >> Select Programmer >> MPLAB ICD 2
- Go to File >> Import
- Select the tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex file
- Go to Programmer >> Connect, and when connected, go to Programmer >> Program
- Note: flash programming the e-puck takes significantly more time that programming via the bluetooth port, so please be patient
XBee Radio
Programming the XBee Radio
- Refer to: Configuration for e-puck XBee radios
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.
- Note: 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
- Start the X-CTU program
- Under the PC Settings tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left
- Set the Baud to 115200, and leave the other settings alone/standard
- Hit the Test/Query button to ensure that X-CTU can see/hear your radio
- Note: 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.
- Upon success, a dialog box should display 'Communication with modem.. OK', 'Modem Type = <something>', and Modem firmware vision = <other thing>'; click OK
- If there are no problems connecting, switch the X-CTU program to the Terminal tab
- In the blank terminal screen, type the following commands below
- Type '+++', and press <enter>. this signals to the XBee radio that you wish to program it.
- Wait until the radio responds with OK
- Type 'atre'. This command resets the settings of the XBee radio.
- Type 'atmy', followed with the ID number, e.g. your command would be 'atmy 3'. This command sets the XBee radio ID.
- Note, that e-puck ID's are from 1-31, whereas all the computer radios have an ID of 0.
- Type 'atap 2'. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)
- Type 'atd6 1'. This is related to the RTS pin, and allows the radio to hold packets in buffer
- Note: SKIP THIS STEP if you are programming a computer Xbee radio, such as for the vision system or data logger.
- Type 'atbd 7'. This sets the Baud to 115200, the frequency used for radios in this project
- Type 'atwr'. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.
- Type '+++', and press <enter>. this signals to the XBee radio that you wish to program it.
Troubleshooting the XBee Radios
- 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 'virtual' COM port, and said COM port can be used by only one program at a time.
- For instance, after configuring the XBee radios with the X-CTU terminal program, remember close that program to prevent further problems
- 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
- However, both radios will and must be ID'd as 0 even though they are to different programs
- Try some of these steps if your XBee radios do not seem to be working
- 'Not getting any signal from the e-puck XBee radios' or 'E-pucks are not getting any signal from the computer radios'
- Check the serial port adapter boards: 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.
- Check the e-pucks: 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
- Check the XBee radio settings: 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)
- 'Not getting any signal from the e-puck XBee radios' or 'E-pucks are not getting any signal from the computer radios'
Machine Vision Localization System
Machine Vision Localization System Setup
- Connect an Xbee Radio to the computer being used as the 'Vision PC'
- Follow the directions in the Machine Vision Localization System: Operation entry; note the Computer Setup instructions
- Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.
- Place robots into the field of view of the Vision System, and turn on the LED pattern boards
- Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly
- Click on the vision system GUI window, and hit the 'C' key to enter the 'command' mode.
- Command the e-pucks following the command scheme as discussed in the Machine Vision Localization System: Using the Command Console entry
- 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
Vision System Troubleshooting
- Getting failure window when trying to send out commands?
- 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
- Make sure no other programs are using or connecting to your XBee Radio >> e.g. X-CTU (remember to close X-CTU), Matlab, or another Visual Studio Program)
- Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios
- Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem
- 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
- Vision System not picking up or identifying e-pucks?
- 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 'blobbier' target masses
- 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
- 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
- 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 'blobbier' target masses