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 :



Unable to attend #ICRA2022 for accessibility issues? Or just curious to see robots?

There are many things that can make it difficult to attend an in person conference in the United States and so the ICRA Organizing Committee, the IEEE Robotics and Automation Society and OhmniLabs would like to help you attend ICRA virtually.
17 May 2022, by
ep.

350

podcast

Duckietown Competition Spotlight, with Dr Liam Paull

Dr. Liam Paull, cofounder of the Duckietown competition talks about the only robotics competition where Rubber Duckies are the passengers on an autonomous driving track.
17 May 2022, by

Designing societally beneficial Reinforcement Learning (RL) systems

In this post, we aim to illustrate the different modalities harms can take when augmented with the temporal axis of RL. To combat these novel societal risks, we also propose a new kind of documentation for dynamic Machine Learning systems which aims to assess and monitor these risks both before and after deployment.
15 May 2022, by

Innovative ‘smart socks’ could help millions living with dementia

‘Smart socks’ that track rising distress in the wearer could improve the wellbeing of millions of people with dementia, non-verbal autism and other conditions that affect communication.
13 May 2022, by

Swiss Robotics Day showcases innovations and collaborations between academia and industry

The 2021 Swiss Robotics Day marked the beginning of NCCR Robotics’s final year. The project, launched in 2010, is on track to meet all its scientific goals in the three areas of wearable, rescue and educational robotics, while continuing to focus on supporting spin-offs, advancing robotics education and improving equality of opportunities for all robotics researchers.
10 May 2022, by

Afreez Gan: Open Source Robot Dog, Kickstarter, and Home Robots | Sense Think Act Podcast #18

In this episode, Audrow Nash speaks to Afreez Gan, who is the founder and CEO of MangDang; MangDang is a Chinese startup that makes Minipupper, an open source robot dog that uses the Robot Operating S...





©2021 - ROBOTS Association


 












©2021 - ROBOTS Association