Sunday, June 13, 2010

Cheap and dirty laser range finding

One of the things that I want a telepresence 'bot to do is to be able to build up a 3D map of its environment pretty much autonomously.  From previous experience, ultrasonic rangefinders are just too unreliable.  That basically leaves me with either using a laser for direct measurement or offset trigonometric measurement.  Until very recently direct measurement was simply too expensive.  Recently, however, Stanly tools has put an inexpensive direct measurement unit on the market for a touch over US$80.

At that price, I'm a little hesitant about buying one of these and trying to hack it mostly because I'd hate breaking it.  I've looked and looked and have yet to find a DIY schematic for this sort of thing.  That leaves me wondering whether this unit uses very short pulses which would be eye-friendly or measures distance by overlaying the output pulse over the return and measuring the resultant offset.  If it uses the second method, it could take too long to settle on a distance for eye safety.

I'm suspecting, however, that I can pulse a laser pointer fast enough to keep it well within eye safety limits.  The design I slapped together places a web cam and a laser pointer pointed parallel to each other at a measured distance, in this case 29.4 cm.

As you can see, I placed a target 100 cm away from the camera lens.

The webcam that I am using grabs a 640x480 pixel RGB colour frame.  That means that I have 320 pixels of resolution to play with.

Having chosen 39.4 cm put the laser dot right at the edge of the frame when I calibrated it at 100 cm.  That left me with...

          634 - 320 = 314

pixels of displacement for a distance of 1 meter.

I then did another frame grab of the kitchen cabinets.  There I had

          389 - 320 = 69 pixels of displacement

The distance to the center of the picture there is calculated...

          314/69 = 4.55 meters

Physical measurement of the distance got me within about 2 cm of that. The difference is likely noise in my measurement and/or misalignment of my laser pointer.

I used a green laser pointer largely because for interior measurements green is easier to spot than red.


  1. So are you planning a Telepresence device like Star Trek Ones?

  2. Much less sophisticated, since mine actually has to work and be affordable. :-)

  3. Hey Forrest

    Found a web site where they were developing a data interface and now the unit has been discountinued.

  4. Wow! That's a great link, Freds! $150 for the whole shebang. It also gives the sampling frequency, viz, 20 Hz.

  5. what happens when the laser hits a surface on an angle? Will the laser disperse and create an oval that would be more pixels than it should be?

  6. I just scan for the centre of the oval. :-)

  7. Hi,

    Neat way of measuring, it will be featured in PCBheaven site under Hacks 'n Mods page.


    Nikos Vrouvakis