I'm not sure if this is the right place to post this but here goes.

So, as the title states, I'm planning on building a desk that doubles as an air hockey table which has a robot on the other side.

The robot would be mounted on a rail which should be able to go left and right using a linear actuator. It should be able to "attack" the puck using two servos.

The real problem is how should I detect the puck's location?

My idea:

Since the table would have tiny holes in the corners of a every square(0.5inx0.5in), I could fit in a laser on the bottom part of the table, a laser for ever 1in so a 1inx1in square, the same location would be reflected on the "ceiling" of the table but instead of laser diodes, they would be replaced by an ldr.

So I'm planning on doing a matrix and reading the signals of the ldr's columns and rows then performing some logic to locate the center of the puck.


While I don't see any performance flaws in my plan, I see tons of flaws when done imperfectly even to the tiniest bit.

  1. I have to be exactly accurate regarding the laser diode's position, it has to be on the center of the holes, right below the z-axis. This should be easy if I'm just going to place 4 or 5. But I'm not.
  2. According to my estimations, I'm going to have to use 300-700 laser diodes, depending on if I'm planning on putting the lasers only on the opponent's side or on the entire board. It would definitely be costly. Imagine 300...
  3. This isn't really a huge problem, more like a hassle. Wiring 300 of these. Forget the pcbs, the project area is just to large.

I have thought of numerous way to lessen these, like using a color sensor to get the x-axis location and a laser situated on a negative x-axis pointing to the positive x-axis to locate the puck's y location, but I'm still comparing ideas.


I could get a 3d-like graphical representation with 3d-like controls (3d-like in reality but technically 2d since the lasers are only plotted in the x and y axis though facing the z-axis).

Since this project is going to be my room desk, situated in an automated room, I was thinking of making "desk modes" which should toggle between a game that takes advantage of the lasers and their controls, A control desk for my room, ordinary desk mode, and an air hockey mode.

My question: (More like a request)

Does anyone have another idea regarding how I should be able to locate the puck's x and y location accurately in real time?

EDIT: The table is roll-able and stored underneath a loft bed which has an under-area height of 5'4". Which means I can't go grande on the a vertical solution.

EDIT #2: Thanks to the helpful people here, I have come to the conclusion of using a camera.

The camera will be that of a smartphone's, I'll create an app that tracks an object by color and a has fixed size comparison to identify the distance of the robot from the puck. The phone will then process this and send signals via bluetooth.

The phone is anchored at the end of the robot's moving part so the camera is reminiscent of those games with a first-person view.

Incoming problems: I'm looking forward to some delay, given the delay in processing.


2 Answers 2


A well lit, perfectly circular object on a contrasting background, like a puck on an air hockey table, is pretty much the ideal use for webcam object tracking.

A classic air hockey table has a light bar/score indicator across the middle of the table - just put the camera in there looking down.

Check out the OpenCV library and webcam tracking tutorials online.

  • $\begingroup$ I don't have much head room, the table will be underneath a loft bed(though roll-able). So if I placed a webcam, I have to make sure at least the robot's side is included in the cam's vision. Nice suggestion though. (I'm sorry I forgot to add in the problem that I don't have much head room, I'll edit it now.) $\endgroup$
    – kdyz
    Aug 31, 2015 at 4:17
  • $\begingroup$ I think, I might go with your idea but with a detachable or fold-able camera mount. I'll just wait for other ideas before choosing yours. $\endgroup$
    – kdyz
    Aug 31, 2015 at 4:51

In addition to Chuck's answer:
I recommend using opencv or any other Computer Vision library.
But you do not need to go the simple way. Do not place the camera directly above the table. You can place it everywhere you want, in any orientation you want. Because you do know your table, the cameras position and its attitude, you can use some easy trigonometrics to calculate the position of the puck. You know have a 3-Dimentional problem to solve, instead of the 2D Problem, which you have with a straight orientation, But it can be done easily by a computer. It is also possible to place multiple cameras, if they have a bad angle.

Another possibility (I will just mention this one, I do not recommend it) is using light barriers in the borders of your table, at all four. There are pretty long ones with multiple sensing points (resulotion is about 1 inch). At the end you still need some software which is estimating the current position and velocity of the puck from the information you get from light barrier. The disadvantage is that this light barriers cost a fortune. They easily cost more then a complete airhockey table. If you are interested in this solution look for light barriers used in automation industry for safety purposes in the handling area.

  • $\begingroup$ I agree that the camera can be anywhere, but every air hockey table I've ever played on looks pretty much like this, so the suggestion to mount the camera under the scoreboard was simply to point out that you could use a camera and mount it easily. $\endgroup$
    – Chuck
    Aug 31, 2015 at 12:15
  • $\begingroup$ Sure I totally agree with you, but the threadcreator seem to have problem with the height, therefore my additonal answer $\endgroup$
    – TobiasK
    Aug 31, 2015 at 12:17
  • $\begingroup$ The light barrier option is a nice approach, and it may be less expensive than it'd seem. Only 1 beam needs to be placed between the human and the robot, pointing from side to side, not human to robot or from robot to human; using 2 beams here will give direction: traveling to the robot or away. Then a few beams could be placed on the robot's baseline and within the goal. It's a nice, hardware-intense & camera-free approach. $\endgroup$ Aug 31, 2015 at 19:36
  • $\begingroup$ It is definetly a viable solution. The company I'm working for is placing them at all handling points of our tool and must follow some pretty strict safety rules, therefore they might be pretty expensive. I do not know if there are cheaper possibilities of such devices; you definetly dont need a light barrier with safety standards. But I suggest not "saving beams" this will reduce your resolution and accuracy dramatically. $\endgroup$
    – TobiasK
    Aug 31, 2015 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.