> Eight servo motors used to manipulate the handles of the foosball table
> A microcontroller to activate the servo motors and communicate with the computer
> An over-head mounted webcam to track the ball and players
> A computer to process the webcam images, implement artificial intelligence, and communicate with the microcontroller
Budget constraints for the prototype slowed the project some and kept its functionality to a minimum. Proper motors to move the players at a competitive speed were found to be very expensive, so lower-end servos had to be used.
While this particular implementation was limited by cost and time, a larger gear ratio would yield a faster playing robot, although doing so would cost more than the $500 base price (price without power supply & computer).
Step 1: Assembling the motor control board
When we implemented, the design, we split the motor controls into 2 circuits, though there is no advantage to doing so other than any particular cabling scheme used. The small blue board implements the PWM control circuitry, which is basically just a clocked PIC-12F with some specialized code.
Step 2: Servo Motor Assembly
The entire system is tied together with pieces of medium-density fiberboard (MDF) and high-density fiberboard (HDF). This was chosen for its low cost (~$5 for a 6'x4' sheet), ease of cutting, and ability to interface with virtually any surface. A more permanent solution would be to machine aluminum brackets to hold everything together. The screws holding the PWM servos in place are standard machine screws (#10s) with hex nuts holding them from the other side. 1mm metric machine screws, about 3/4" in length, hold the AX-12 into the MDF that connects the two servos together. A double-action drawer track holds the entire assembly down and in-line with the track.
Step 3: Software
> The code run on the image processing PC
> The code run on the PIC-18F microcontroller
> The code run on each of the PIC-12F microcontrollers
There are two prerequisites to install on the image processing PC. The image processing is done through the Java Media Framework (JMF), which is available through Sun here. Also available through Sun, the Java Communications API is used to communicate to the motor control board, across the serial port on the computer. The beauty of using Java is that it *should* run on any operating system, though we used Ubuntu, a linux distribution. Contrary to popular opinion, the processing speed in Java isn't too bad, especially in basic looping (which vision analysis uses quite a bit).
As seen in the screenshot, both the ball and the opponent players are tracked on each frame update. In addition, the outline of the table is located visually, which is why blue painters tape was used to create a visual outline. Goals are registered when the computer cannot locate the ball for 10 consecutive frames, typically indicating the ball fell into the goal, off the playing surface. When this happens, the software initiates a sound-byte to either cheer itself or boo the opponent, depending on the direction of the goal. A better system, though we did not have the time to implement it, would be to use a simple infrared emitter/sensor pair to detect the ball falling into the goal.
All of the software used in this project is available in a single zip file, here. To compile the Java code, use the javac command. The PIC-18F and PIC-12F code is distributed with Microchip's MPLAB software.
Step 4: Webcam mount
We measured the distance required by the webcam's focal length to fit the entire foosball table in the frame. For this camera model, that number turned out to be just over 5 feet. We used shelving racks available from any major hardware store to build a mount for the camera. The shelving racks extend upward from each of the four corners of the table and are cross-braced by angled aluminum brackets. It is very important that the camera is centered and has no angular rotation, since the software assumes the x- and y-axis are aligned to the table.
Step 5: Conclusion
I would like to thank
> Dr. James Hamblen, our section advisor, for his continuous help in technical strategies
> Dr. Jennifer Michaels, the lead professor, for not discouraging us from attempting a more ambitious project
> James Steinberg and Edgar Jones, the senior design lab administrators, for constant help in ordering parts, troubleshooting, and the finding the "cool stuff" to throw into the project at low cost and high functionality
> And of course, the other three members of my team, of which, none of this would have been possible: Michael Aeberhard, Evan Tarr, and Nardis Walker.