Hacker makes air hockey table from 3D printer parts
If you hated losing to the computer at Pong, then at least you could console yourself with the knowledge that the computer was on home turf; the contest took place in the computer's ethereal realm of ones and naughts. Now, a project by Spanish tinkerer Jose Julio has given rise to a competitive, merciless air hockey machine that will lay bare your mortal frailties and beat you into submission on your own physical terms. What's more, it's built largely with 3D printer parts.
Inspired by his daughter's love of air hockey and an interest in how 3D printer parts can be rearranged to create a new machine, Julio went about designing and building an air hockey robot. He based his design on the standard parts of a typical RepRap 3D printer, such as a NEMA 17 stepper motor, an Arduino Mega, RepRap Arduino MEGA Pololu Shield (RAMPS), belts, bearings, rods and engine parts. "The great advantage of using these pieces is that they are cheap and easily available," he explains on his website.
Julio opted to build a medium-sized air hockey table with dimensions of 100 x 60 cm (39.4 x 23.6 in). The playing surface is a wooden board on which he marked up and drilled the requisite air-holes. Airflow is created using two old PC fans. Using the printer parts, Julio rigged up the mechanism by which the robot could move its pusher. After some trial and error, he opted for a three-motor design, with two motors powering movement up and down the table and one motor powering movement across the table.
The code was designed from the ground up, as Julio found that the code for a 3D printer was not worth modifying. Specifically, he found that he needed fast, direct movement instead of the slow and smooth movement required by 3D printers. In short, he tells Gizmag, "The code on the PC reads the information from the camera, detects the position of the puck (using its color) and sends the information to the Arduino."
Julio explains that the code has three main parts. The motor control aspects dictate the position, speed and acceleration of the robot, sending the appropriate pulses to the stepper motors. For vision and trajectory prediction, the Arduino reads the data packets from the PC that contain the position of the puck. The coordinates of the puck and its trajectory are then calculated. Two consecutive frames are required in order to calculate the trajectory. Finally, the robot uses its current status, the puck position and the trajectory prediction to determine its strategy – either defense, defense and attack, or a new attack.
Drivers for the stepper motors were made using Arduino interrupts, which are useful for projects that need quick and precise reactions by sending a signal to "interrupt" the current operation. "I implemented position, velocity and acceleration control, using an acceleration ramp with a simplified S-profile," says Julio. "The interrupts can generate pulses up to 25Khz which is the maximum speed that I can achieve with the steppers. The position control works at 1 kHz."
In order for the system to recognize and track the puck, a Playstation 3 EYE camera was used in conjunction with a PC. "I developed the vision system in C language using OpenCV libraries for capturing, thresholding, filtering and segmentation," he explains. The camera captures video at 60Hz and at a resolution of 320 x 240. The video of the puck's location can also be recorded, which helps in the debugging process.
The difficulty level for playing against the robot can be changed by adjusting its acceleration and maximum speed. This is a feature that Julio thinks can be improved in future. He told Gizmag that he thinks the mechanics could be improved to minimize the loss of steps by the motors, and that functionality for detecting goals could easily be added. He is also toying with the idea of putting robot players at both ends of a table for an emotionless mechanized air hockey shootout, and suggests that a Robot Wars-style competition could be a possibility. "This would be a war of robot strategy algorithms," he enthuses. "This is really a code war!"
In total, Julio estimates that the table costs about €200 (US$273) to build. It took him 3-4 months, but those keen to emulate him will be aided by the documentation available on his website. "Although it can seems a complex project, it's affordable and doable," he says.
The video below shows the robot in action.
Source: Jose Julio