Hacking a 3D printer to play air hockey


This DIY project is puckin’ awesome!


As a kid, there was always that one game — besides Mortal Kombat, NBA Jam and Street Fighter, of course — that seemed to captivate everyone’s attention while inside an arcade. Air hockey! Originally invented by a group of Brunswick Billiards engineers back in 1969, the two-player game features a puck, two goals and a frictionless surface.

5529604a-4c04-4a8f-bce5-41a50ab66c53

However, there was always those times when you couldn’t find anyone else around to compete against. Fortunately, Maker Jose Julio recently decided to take it upon himself to alleviate that problem by creating an air hockey-playing robot using some readily available RepRap 3D printer parts, including an Arduino Mega (ATmega2560) and RAMPS 1.4 board.

Additional key specs included a PS3 camera, NEMA17 stepper motors, motor drivers, belts, bearings and rods, along with some 3D-printed brackets, paddles and pucks, obviously. Meanwhile, the table itself was built from scratch with off-the-shelf wood and two standard 90mm PC fans to produce the necessary air pressure to lift the puck.

Julio used a three-motor design (two for the Y-axis, one for the X), and replaced the X-axis rods on the RepRap with carbon tubes, which seemed to work quite well on PLA-printed bushings and made the system lighter.

mesa

“I started studying the code of Marlin (typical RepRap firmware) software but I decided to start from scratch, first because I don’t need a G-code interpreter, and second, because the software of a 3D printer have a motion planning algorithm and this is not the way the Air Hockey robot must work,” the Maker explains. “3D printers plan movements for smooth paths through all the points. The Air Hockey Robot should move inmediately with every new command canceling the previous one, because what we need is that the robot moves as quickly as possible to the new position.”

How the robot works is fairly straightforward. fThe system employs a PS3 camera mounted above the table to monitor the puck, determine its trajectory and stop shots from an opponent. The PS3 Eye is also adjustable, which allows a user to determine the robot’s speed, acceleration and strategy algorithms. (That’s good news for sore losers, you can rig the game to guarantee the win…) This was made possible by connecting the camera to a PC running a vision system that he wrote using OpenCV libraries. This way, once the puck is detected, the location is sent to the Arduino by serial port.

trajecroty

Beyond that, Julio devised a trajectory prediction system and the robot’s air hockey strategy with the Arduino.

“Once we have detected the puck in two consecutive frames we can calculate the trajectory. The trajectory prediction takes into account that the puck can rebound against a side wall. All these calculations are accesible to the strategy subsystem that decides what the robot will do: defense, defense+attack, and preparing for a new attack,” he writes.

Ready to get your game on against your own Air Hockey Robot? You can head over to the Maker’s official page here, while its code, 3D designs and additional documentation can all be found on Github here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s