RGB Swarm Robot Quickstart Guide

From Mech
(Difference between revisions)
Jump to: navigation, search
(Programming the XBee Radio)

Revision as of 14:36, 10 September 2009


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.


  • 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
    • Tiny Bootloader
    • Visual Studio
    • 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 Code

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
  1. Open the workspace file (extension .mcw) of your project/code
  2. Click the Build All button (looks like a stack of papers getting pushed down by two arrows)
  3. Check to make sure that the BUILD SUCCEEDED, and then look for the new .hex file in the same folder where the .mcw file was
    • This will be the .hex file you use for programming and uploading onto the e-puck

Connecting the e-puck

  1. Go to start menu >> control panel >> Bluetooth Devices
  2. 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
  3. 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
  4. Return to the Bluetooth Devices Dialog screen, and click on the COM Ports tab
  5. 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

Refer to: Swarm E-puck Quickstart Guide: 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
  1. Start the Tiny Bootloader program on your computer
  2. Click the Browse button and select the .hex file that corresponds to the e-puck code that you want to program
  3. Set 115200 under the Comm dropdown menu, and select the COM port that corresponds with the OUTGOING COM port of the e-puck
  4. Click the Write Flash button
  5. 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.
  6. 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.
  1. MPLAB and the ICD2 programmer are needed to reload the Tiny Bootloader software via the flash port of the e-puck
  2. Go to http://www.e-puck.org, goto Download >> Software >> Library, download the zip file, and extract the archive
  3. Navigate to e-puck-lib\tool\bootloader\epuck_side, look for tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex hex file.
  4. Open MPLAB
  5. Go to Programmer >> Select Programmer >> MPLAB ICD 2
  6. Go to File >> Import
  7. Select the tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex file
  8. 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
  1. Start the X-CTU program
  2. Under the PC Settings tab, Select the COM Port of the Serial Port Adapter you are using from the list on the left
  3. Set the Baud to 115200, and leave the other settings alone/standard
  4. 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.
  5. Upon success, a dialog box should display 'Communication with modem.. OK', 'Modem Type = <something>', and Modem firmware vision = <other thing>'; click OK
  6. If there are no problems connecting, switch the X-CTU program to the Terminal tab
  7. In the blank terminal screen, type the following commands below
    1. Type '+++', and press <enter>. this signals to the XBee radio that you wish to program it.
      • Wait until the radio responds with OK
    2. Type 'atre'. This command resets the settings of the XBee radio.
    3. 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.
    4. Type 'atap 2'. This sets the XBee radio to use the API language with interrupts (to ensure packet quality)
    5. 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.
    6. Type 'atbd 7'. This sets the Baud to 115200, the frequency used for radios in this project
    7. Type 'atwr'. This writes the settings to non-volatile memory, saving it even when the radio is powered on/off.

Troubleshooting the XBee Radios

Machine Vision Localization System

Machine Vision Localization System Setup

  1. Connect an Xbee Radio to the computer being used as the 'Vision PC'
  2. Follow the directions in the Machine Vision Localization System: Operation entry
    • Note that the directions for setting up the RGB Vision System and the Swarm Vision System are nearly identical save a few steps.
  3. Place robots into the field of view of the Vision System, and turn on the LED pattern boards
  4. Check that the vision system is running correctly, providing accurate positions and identifying each e-puck properly
  5. Click on the vision system GUI window, and hit the 'C' key to enter the 'command' mode.

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
      1. 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)
      2. Try resetting and reconfiguring the radio you are using as your Vision PC XBee radio, as occasionally the Vision System corrupts some radios
      3. Try a different XBee radio, a different serial port adapter board, or a different serial port if this is an ongoing problem
  • 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
      1. 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
      2. 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

Additional Tools

Matlab Tools

Visual Studio Tools

Personal tools