Swarm Robot Quickstart Guide

From Mech
(Difference between revisions)
Jump to: navigation, search
(Using the Real-Time Display)
(Using the Packet Parser with Timestamp)

Revision as of 19:33, 21 January 2009


This guide was written as a quickstart guide for the Swarm Robots Project, but contains general information about programming e-pucks.


In order to run the system, you will need:

  1. e-puck robots, with XBee extension boards and configured radios.
  2. Bluetooth adapter on your computer.
  3. Compiled .hex file found in e-puck code project
  4. Tiny Bootloader
  5. Compiled program for Machine Vision Localization System.
  6. You may also want to use one or more of the Analysis Tools such as the real-time display.

Items needed to edit the e-puck code

If you want to edit the e-puck code, you will need the following:

  1. Microchip MPLAB (for editing code, not needed to run)
  2. Microchip C compiler for dsPICs (for editing code, not needed to run)
  3. Code for e-pucks

Programming the e-pucks

You will need to get the compiled .hex file for the e-puck, and then load it onto the PIC with Tiny Bootloader over the bluetooth radio. The compiled .hex file can be found here: File:Swarm epucks code.zip.

Connecting to the e-puck

To program the e-puck, you first need to connect to the e-puck. Go to the Control Panel, and open Bluetooth Devices, and go to Devices>Add.... Turn on the e-puck, check My device is set up and ready to be found, then click next. When the computer has found the e-puck, select it (the ID of the epuck is a four-digit number found on a sticker on top of the bluetooth chip on the e-puck). When the prompt asks you for a passkey, enter the 4-digit ID number. The computer should then reserve a COM (serial) port to communicate with this particular e-puck. The computer will set up different COM ports for different e-pucks; this is normal. Go back to Bluetooth Devices in the Control Panel, and select the COM Ports tab, and see port is assigned Outgoing to the e-puck. This is the COM port you will use to program this particular e-puck when using Tiny Bootloader. If you're using a USB bluetooth dongle, if you unplug it and replug it into a different USB port, or use a different dongle, you may need to reconnect to the e-pucks.

BT COM ports.png

Programming the e-puck

A bootloader is a type of program that is loaded onto a microcontroller which allows one to re-program the microcontroller in the field without having to use an special flash programmer (the programmer is still needed to load the bootloader onto the microcontroller in the first place). The Bootloader has two components: a programmer that runs on your computer, and a program that runs on the e-puck's PIC. When the PIC is turned on, bootloader will check to see if someone is attempting to re-program the PIC; if yes, the bootloader will overwrite its old program with the new program; if not, or if it times out while waiting for the new data stream, it will simply run the current program.

To program the e-puck, start the Tiny Bootloader program on your computer. (Although you can also use a flash programmer such as the ICD2 to program the e-puck, it will take much longer and can't be done wirelessly.) Click on Browse and select the .hex file that you want to load. The .hex file is the compiled code from Microchip's C compiler. Under Comm, use 115200 for the baud rate, and type in the outgoing COM port assigned to this e-puck (e.g. COM10, COM11, etc.). Turn on the e-puck, and click on the Write Flash button. The blue bar underneath the button should start counting down. Now, hit the blue reset button on the e-puck, before the blue bar reaches zero and times out. If the e-puck is successfully connected, an orange LED on the e-puck will turn on, and the bootloader will start to program the PIC on the e-puck.


  • 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. See the section below Re-loading the Bootloader to see how to restore the bootloader with the ICD2 programmer and MPLAB.

Re-loading the Bootloader

The e-pucks require that a special bootloader program be loaded on it if you want to program the e-puck over a bluetooth radio.

You can download the .hex file you need at http://www.e-puck.org. On the website, go to Download>Software>Library and download the zip file. Extract the archive, and navigate to e-puck-lib\tool\bootloader\epuck_side. The file tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex is the one we will use.

You will need Microchip's MPLAB and ICD2 to program in the bootloader on the PIC. After opening MPLAB, select to Programmer>Select Programmer>ICD2. Then, go to File>Import> and navigate to tinybld_ds6014A_7.37Mhz_115200uart1_8xPLL_with_LEDs.hex. Then, connect to the ICD and program the PIC.

Starting the Vision System

The vision system is needed to track the position of the robots and send out commands. You can get the compiled program here (no source code): File:Vision localization.zip

  1. Connect an XBee radio with ID 0 to the computer. The ID must be 0 so that the robots can tell that the packet is from the computer and not another robot.
  2. Follow the directions on the Machine Vision Localization page to set up and calibrate the system.
  3. Make sure the robots are in the field of view of the vision system.
  4. Let the system run for a few seconds so that the robot's positions will be updated.
  5. Select the GUI window and hit 'c' to enter the command mode.
  6. Select the console window and enter the goal statistics that you want using the goal command. You can skip this step if you want to use the default [100 300 160000 40000 40000] goal statistics. Send the command 2 or three times in case one or more of the robots doesn't get the message.
  7. Use the wake command (wake 0) to start the robots.
  8. Exit the console by typing exit. The system should now be running.

Using the Real-Time Display

This is a real-time visualization system that displays the state of the system while it is running. It will draw the ellipse representing the target (the black ellipse)It is written in MATLAB. You can get the files here:File:Swarm RT display.zip.

  1. Connect a configured XBee radio to the computer. If you are running another program that uses a serial port, such as the vision system, you will have to use another port and XBee radio. Each serial port can only be accessed by one serial port at a time.
  2. Run the open_serial.m script after replacing the 'COM1' parameter in the initXBeeSerial function call with the serial that you are using.
  3. run the RT_Swarm_Plotter.m script. Hit 'q' to stop the logger. Run the script again if you want to resume.
  4. run the close_serial.m script to close the serial port when you are done.

Using the Packet Parser with Timestamp

This program connects to a configured XBee radio at the serial port, and reads and parses any XBee packets it receives. It will output two MATLAB files, main_log.m and run_me.m. The file main_log.m contains all of the information in the received packets with a timestamp added; run_me.m contains a short example on how to plot the data.

Personal tools