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 :



Open Robotics Launches the Open Source Robotics Alliance

The Open Source Robotics Foundation (OSRF) is pleased to announce the creation of the Open Source Robotics Alliance (OSRA), a new initiative to strengthen the governance of our open-source robotics so...

Robot Talk Episode 77 – Patricia Shaw

In the latest episode of the Robot Talk podcast, Claire chatted to Patricia Shaw from Aberystwyth University all about home assistance robots, and robot learning and development.
18 March 2024, by

Robot Talk Episode 64 – Rav Chunilal

In the latest episode of the Robot Talk podcast, Claire chatted to Rav Chunilal from Sellafield all about robotics and AI for nuclear decommissioning.
31 December 2023, by

AI holidays 2023

Thanks to those that sent and suggested AI and robotics-themed holiday videos, images, and stories. Here’s a sample to get you into the spirit this season....
31 December 2023, by and

Faced with dwindling bee colonies, scientists are arming queens with robots and smart hives

By Farshad Arvin, Martin Stefanec, and Tomas Krajnik Be it the news or the dwindling number of creatures hitting your windscreens, it will not have evaded you that the insect world in bad shape. ...
31 December 2023, by

Robot Talk Episode 63 – Ayse Kucukyilmaz

In the latest episode of the Robot Talk podcast, Claire chatted to Ayse Kucukyilmaz from the University of Nottingham about collaboration, conflict and failure in human-robot interactions.
31 December 2023, by





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


©2024 - Association for the Understanding of Artificial Intelligence


 












©2021 - ROBOTS Association