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 :



ep.

340

podcast

NVIDIA and ROS Teaming Up To Accelerate Robotics Development, with Amit Goel

Amit Goel, Director of Product Management for Autonomous Machines at NVIDIA, discusses the new collaboration between Open Robotics and NVIDIA. The collaboration will dramatically improve the way ROS and NVIDIA's line of products such as Isaac SIM and the Jetson line of embedded boards operate together.
23 October 2021, by

One giant leap for the mini cheetah

A new control system, demonstrated using MIT’s robotic mini cheetah, enables four-legged robots to jump across uneven terrain in real-time.
23 October 2021, by

Robotics Today latest talks – Raia Hadsell (DeepMind), Koushil Sreenath (UC Berkeley) and Antonio Bicchi (Istituto Italiano di Tecnologia)

Robotics Today held three more online talks since we published the one from Amanda Prorok (Learning to Communicate in Multi-Agent Systems). In this post we bring you the last talks that Robotics Today...
21 October 2021, by and

Sense Think Act Pocast: Erik Schluntz

In this episode, Audrow Nash interviews Erik Schluntz, co-founder and CTO of Cobalt Robotics, which makes a security guard robot. Erik speaks about how their robot handles elevators, how they have hum...
19 October 2021, by and

A robot that finds lost items

Researchers at MIT have created RFusion, a robotic arm with a camera and radio frequency (RF) antenna attached to its gripper, that fuses signals from the antenna with visual input from the camera to locate and retrieve an item, even if the item is buried under a pile and completely out of view.
18 October 2021, by

Robohub gets a fresh look

If you visited Robohub this week, you may have spotted a big change: how this blog looks now! On Tuesday (coinciding with Ada Lovelace Day and our ‘50 women in robotics that you need to know about‘ by chance), Robohub got a massive modernisation on its look by our technical director Ioannis K. Erripis and his team.
17 October 2021, by





©2021 - ROBOTS Association


 












©2021 - ROBOTS Association