Pocket Bot Example Programs

Overview

The Pocket Bot comes pre-flashed with 5 example programs:

  1. Line-Following: Classical line-following.
  2. Area-Keeping: Robot stays within a taped-in area.
  3. Barcode: Robot reads encoded commands on a line course, transmits them to other nearby robots, and they all execute the encoded commands at the same time.
  4. Rave: Robot displays a rainbow LED effect, while optionally spinning.
  5. Line Debug: Robot uses its LEDs to display reflectance sensor output, and optionally prints those values to serial.

You can find the source code for these programs here.

Program Selection and Running

Turn on your Pocket Bot using the power switch. The robot will boot with a quick rainbow LED effect, and you'll enter program selection mode, indicated by a blue LED in position 1.

The blue LED in position 1 means that the 1st program is selected. Press the Pocket Bot's pushbutton to select the 2nd program, and so on, for any of the 5 programs mentioned above.

Once you have selected the desired program you want to run, long-press the pushbutton until all blue LEDs flash, indicating your selection is ready and that the program will run.

The Pocket Bot will now flash a green "ready" LED in a position matching your selection, meaning that program is ready to run. Place the Pocket Bot on a surface, and press the pushbutton again to run the program.

For example, if you want to run Rave (program 4), you'd scroll through the programs until the 4th blue LED lights up, long-press the button, and then press again to confirm and run. This entire sequence, beginning from power-up, is shown below.

 See below for details on running each program and what to expect.

Program 1: Line-Following

Select Line-Following (program 1) using the instructions at the top of this guide. When the program is ready (green-flashing LED in position 1), place the Pocket Bot where you want it to start on the line course, and press the pushbutton again to begin. We've provided a figure-8 and rounded-rectangle line course for you to start with, and the robot was specifically tuned to work well with these courses.

After pressing the pushbutton, the Pocket Bot will perform an auto-calibration procedure by turning right and left to scan the nearby brightness values of the course, and then immediately begin driving through the line course.

Although we provide you with two example line courses, you can make your own using black electrical tape, printed sheets of paper, or even a thick marker. In our experience, lines between 18mm and 22mm thick work best.

The robot will continue running until you hold the pushbutton, at which point it will enter program selection mode again.

If the robot does not perform as expected, you may need to re-start the line-following program, since correct placement of the Pocket Bot and the quality of its auto-calibration will strongly influence how well it responds. You can also use Program 5 (Line Debug) to determine the quality of your calibration or if a sensor is blocked or malfunctioning. Based on our own testing during development, a re-calibration should be sufficient to correct any issues.

Program 2: Area-Keeping

Select Area-Keeping (program 2) using the instructions at the top of this guide. When the program is ready (green-flashing LED in position 2), place the Pocket Bot on the rounded rectangle course we've provided (or one you've made yourself) so that it is inside the area you want to maintain, but such that the sensors are fully inside of the area and not over any dark regions, as shown in the next image.

Press the pushbutton. The Pocket Bot will perform an auto-calibration procedure by turning right and left to scan the nearby brightness values, and then begin by moving forwards.

The Pocket Bot will back up and turn when it encounters the boundary set by the dark region.

The robot will continue running until you press and hold the pushbutton, at which point it will enter program selection mode again.

If the Pocket Bot immediately backs up upon starting, you need to re-position the robot more directly inside the area you want it to stay in, so that it doesn't immediately see the dark region and get repelled by it when it begins. If the robot still does not perform as expected, you may need to re-start the area-keeping program, since correct placement of the Pocket Bot and the quality of its auto-calibration will strongly influence how well it responds.

Program 3: Barcode

Lay out the pages of the barcode program. They are each labelled by page number, encoded value, and intended driving/scanning direction. See the guide on working with barcode courses for more details. A larger example barcode course is shown below.

Select Barcode (program 3) using the instructions at the top of this guide. When the program is ready (green-flashing LED in position 3), place the Pocket Bot at the very start of the barcode course. Initial placement is important so that while auto-calibrating, the Pocket Bot can sample both light and dark areas. Press the pushbutton again to begin auto-calibration.

After auto-calibration, the Pocket Bot will again wait in a ready mode (green-flashing LED in position 3) so you can re-center it properly at the beginning of the barcode course or run the calibration with more Pocket Bots (optional; see below).

Optional: If you have more than 1 Pocket Bot, and would like them to wirelessly receive and execute the instructions read by the first Pocket Bot after it completes the course, complete the auto-calibration step for those Pocket Bots as well. The Pocket Bot that you want to scan the course (the "scanning" robot) should be placed at the beginning of the barcode course, and the other Pocket Bots (the "receivers") should be placed near the end of the course, but on a light area with no lines or barcode. (A light surface indicates that the Pocket Bot should be a receiver instead of a scanner.) When you're ready, press the pushbutton on the receiver Pocket Bots so they'll listen for commands. Receiver robots will flash a red LED every 2 seconds to indicate that they're ready and waiting for commands.

Shown below is a receiver robot at the end of the course (right), waiting for commands from a scanning robot (left).

To run the scanning robot and have it read the course, press its pushbutton. It will begin driving along the barcode and scanning each page. A white LED will flash as each successive bit is read.

The first page of this example barcode course is an instruction for the Pocket Bot to spin and flash a rainbow pattern on its LEDs (similar to the Rave program). The second page contains a command analogous to EOF (end-of-file), indicating the end of the instructions. After scanning the EOF, the scanning robot will transmit all scanned commands to any nearby receiving Pocket Bots (optional), and they will all execute the same command togther.

The Pocket Bot(s) will exit to program selection mode after executing the scanned/received commands.

The Barcode program requires a higher sensor calibration quality, so ensure that this is done correctly, otherwise the Pocket Bot will not read the course properly. Paper is also slightly translucent, so the Pocket Bot's sensors will be sensitive to any non-uniformities in the surface underneath the course. If the Pocket Bot prematurely stops during scanning or doesn't execute the intended commands, make sure the Pocket Bot's sensors are clear, the surface underneath the paper is uniform, and that the calibration quality is good.

We've provided a command-line utility, course-encoder, that you can compile and use to generate your own custom line courses. It is the same one we used to render the 2-page example barcode course. You can read about how to use it here.

Program 4: Rave

Select Rave (program 4) using the instructions at the top of this guide. When the program is ready (green-flashing LED in position 4), place the Pocket Bot on a surface. Press the pushbutton. The robot will continually flash its LEDs in a rainbow pattern.

Pressing the pushbutton again will make the robot also spin in place while flashing its LEDs in a rainbow pattern.

Pressing the pushbutton again will terminate the program and put the Pocket Bot into program selection mode.

Program 5: Line Debug

Select Line Debug (program 5) using the instructions at the top of this guide. When the program is ready (green-flashing LED in position 5), press the pushbutton.

This is a debugging program that shows the quality of the most recently-run line calibration procedure (see Program 1, Program 2, or Program 3 for details on the auto-calibration). The robot will light up LEDs 1, 3, and 5 to indicate the darkness of the region underneath each of the 3 line-following/reflectance sensors. Manually slide the Pocket Bot over light or dark regions to see the sensor feedback.

Make sure the Pocket Bot's wheels are contacting the relevant surface when running this program. The robot's sensors are only designed to work properly at those distances.

If the LED feedback indicates a response too weak or too strong, it likely means the sensor is blocked, dirty, or most commonly, that the last auto-calibration was not of sufficient quality. A little bit of imperfection is okay: a key tenet of robotics is that sensors are noisy. In all cases that we've discovered during testing and development, a proper calibration can fix incorrect line-following, area-keeping, or barcode-reading behavior.