purple pimp hatSoftware

We played around with several designs, and consequently generated a lot of software. This describes only the final, cleaned code that we ran on game day.

Our software had two modes: setup mode and game mode. In setup mode, it checked the dip switches to see which side it was on and printed out "WHITE" or "BLACK" to ensure that our IR frequencies were set correctly (we didn't care what side we were on other than that). We also printed readouts from out start sensors, and most importantly, we printed whether each of our three IR sensors could see the other robot. Since we depended on the other robot to get its beacon working, we needed to ensure that it held up its end of the responsibilities.

Hitting choose caused the robot to wait for the start light. When it saw the light, it switched to game mode.

Game mode is simple: drive toward the other robot. That's it. It kept trying to do this until 60 seconds was up and it cut off.


Here are the implementation details of game mode:

Check the IR sensors every 40 milliseconds. If each sensor has seen 2 or more signals from the beacon, it is considered to be on.

If no IR beacon is detected, drive straight forward. It's better than nothing.

If the left and the right IR sensors don't match (either both on or both off), spend some amount of time turning toward the sensor that was off. Because of our six-wheeled design, the only effective method of turning that we had was to stop and turn in place, rotating one set of wheels forward and the other backward. The speed at which moved following the turn depended on whether the middle IR sensor was "on". If it was, we knew we weren't too far off course, so we blazed ahead at high speed. If the middle sensor was off, only one of our sensors was on, so we were farther off course and only moved forward at half speed so we could get a better reading next time and avoid overshooting the other robot while off to one side of it.

If the left and right sensors matched, we simply continued forward at full speed.

The final software turned out to be fairly simple, despite the long process of narrowing down the behavior we wanted. We went from semi-epileptic beacon tracking to the simple, final version which worked nearly flawlessly. We could take a "magic wand," consisting of an IR beacon on a pole hooked to a roboboard and a battery, and lead out robot around the halls like a puppy dog. A lethal, snarling, evisceration machine of a puppy dog, though. Pimps can't be too friendly.

To see the complete details of our code, check out the IC source of our final version.


Main | Plan | Hardware | Pictures