Robohub.org
 

Hacking your 3D printer to make an air hockey robot


by
02 April 2015



share this:

carro_x_air_hockey_robot

I love hacking – i.e. modifying everyday items you already have at home or that can be purchased easily. And my daughter loves air hockey! This fun project combines standard RepRap 3D printer parts (NEMA17 stepper motors, drivers, Arduino Mega, RAMPS, belts, bearings, rods, printed pieces …) with video detection and motor control to make an air hockey robot that you can play against.

The main advantage to using these parts is that they are inexpensive and easily available. I wanted something easily transportable and comfortable to play, but at the same time, easy to replicate and open source.

After some weeks scratching my head and problem solving, I can proudly state: It’s air hockey time!

Developing the robot

In the end I decided to use a 3-motor design (2 for the Y axis and one for the X axis). After several design iterations, and some material changes to minimize the weight and inertia (and thus increase the accelerations of the robot), I got a fairly operational design. One of the most important changes is the replacement of the X-axis rods with carbon tubes (from kites), which works very well on PLA-printed bushings and saves a lot of weight.

3dparts_air_hockey_robot

The code

I started studying the code for Marlin (typical RepRap firmware) software, but in the end I decided to start from scratch. This was because I don’t need a gcode interpreter, and also because the software of a 3D printer has a motion planning algorithm and this is not the way an air hockey robot must work. 3D printers plan movements for smooth paths through all the points, but an air hockey robot should move immediately with every new command cancelling the previous one, because we want the robot to move as quickly as possible to the new position.

I began developing the driver for the stepper motors using Arduino interruptions and making the code as efficient as possible. I implemented position, velocity and acceleration control using an acceleration ramp with a simplified S-profile. 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.

profile_air_hockey_robot

Puck detection

For the puck detection problem I decided to use a computer vision system. Initially I planned to use the CMUCAM5 (Pixy) sensor, which fits very well in this project (and in near future I will prepare a version for this sensor), but the camera is not available yet, so instead I used the PS3 EYE camera with a PC to develop the vision system. I developed the vision system in C using OpenCV libraries for capturing, thresholding, filtering and segmentation.

The system detects the puck (it must have a special color) and the result is sent to the Arduino by serial port. The vision system sends information packets containing the position of the puck and the robot in pixels within the image. The camera is running at 60Hz at a resolution of 320×240. Fortunately the camera has very little distortion and I don´t need to implement a lens distortion correction. The software records a video on the PC – very useful for debugging.

puck_air_hockey_Robot

One of the main problems I’ve had is that the power of the NEMA17 motors are pretty fair for this project and the disadvantage of using stepper motors is that if we lose steps (which can easily happen, for example when the robot hits the puck against the wall) and we do not take into account the missing steps, we lose the position of the robot. In order to fix this, I use the vision system to detect the robot as well (with a different color) so we can detect when the robot has lost steps and fix it.

What remained was the implementation (in the Arduino) of the trajectory prediction system and the strategy of the robot. Once we have detected the puck in two consecutive frames we can calculate the trajectory (equation of the line through two points, this is college math!). The trajectory prediction takes into acount 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.

trajectory_air_hockey_Robot

A nice feature of this project is that the strategy subsystem is fully insulated and is very easy to modify and reprogram, so you can develop your own strategy algorithms from the complexities of motor control, vision system and prediction code.

Although it seems like a complex project on the surface, it’s a surprisingly affordable and “doable” project.



If you liked this article, you may also be interested in:

See all the latest robotics news on Robohub, or sign up for our weekly newsletter.



tags: ,


JJRobots is a new blog created by Jose Julio Rodriguez (Computer Science Engineer) and Juan Pedro Calderón (Electronic Engineer).
JJRobots is a new blog created by Jose Julio Rodriguez (Computer Science Engineer) and Juan Pedro Calderón (Electronic Engineer).





Related posts :



Congratulations to the #AAMAS2025 best paper, best demo, and distinguished dissertation award winners

  29 May 2025
Find out who won the awards presented at the International Conference on Autonomous Agents and Multiagent Systems last week.

Congratulations to the #ICRA2025 best paper award winners

  27 May 2025
The winners and finalists in the different categories have been announced.

#ICRA2025 social media round-up

  23 May 2025
Find out what the participants got up to at the International Conference on Robotics & Automation.

Robot Talk Episode 122 – Bio-inspired flying robots, with Jane Pauline Ramos Ramirez

  23 May 2025
In the latest episode of the Robot Talk podcast, Claire chatted to Jane Pauline Ramos Ramirez from Delft University of Technology about drones that can move on land and in the air.

Robot Talk Episode 121 – Adaptable robots for the home, with Lerrel Pinto

  16 May 2025
In the latest episode of the Robot Talk podcast, Claire chatted to Lerrel Pinto from New York University about using machine learning to train robots to adapt to new environments.

What’s coming up at #ICRA2025?

  16 May 2025
Find out what's in store at the IEEE International Conference on Robotics & Automation, which will take place from 19-23 May.

Robot see, robot do: System learns after watching how-tos

  14 May 2025
Researchers have developed a new robotic framework that allows robots to learn tasks by watching a how-to video

AI-powered robots help tackle Europe’s growing e-waste problem

  12 May 2025
EU-funded researchers have developed adaptable robots that could transform the way we recycle electronic waste, benefiting both the environment and the economy.



 

Robohub is supported by:




Would you like to learn how to tell impactful stories about your robot or AI system?


scicomm
training the next generation of science communicators in robotics & AI


©2025.05 - Association for the Understanding of Artificial Intelligence


 












©2025.05 - Association for the Understanding of Artificial Intelligence