Author Topic: Sharp IR Sensors  (Read 6267 times)

0 Members and 1 Guest are viewing this topic.

Offline CapnAhabTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Sharp IR Sensors
« on: July 07, 2006, 05:14:16 PM »
I have seen these on SoR pages and was wondering if anyone has experience regarding the sensitivity of these things.  I am looking for a sensor that can detect a golf ball passing at around 12 inches distance at no more than 30 mph. I am not too bothered about the distance sensing function - just accurately detecting that a ball has passed.  With 2 of these sensors a set distance apart, I figure I can time and hence calculate the speed of the passing ball.

If they are not suitable for this, could anyone recommend an alternate sensor/approach? (A broken beam approach is not possible for my situation)

Thanks in advance

CapnAhab

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: Sharp IR Sensors
« Reply #1 on: July 07, 2006, 08:05:53 PM »
from my experience any reflected IR solution wouldn't have the accuracy you are looking for. this technique is fine for telling if something is out there but not a precise reading of how far and which direction.
you could possibly get some level of accuracy if you made your measurements with exactly the same level of background light but changing light conditions would probably throw things off.

so if i was trying to measure flying golf balls that presumably could be following a variety of different trajectories i would be tempted to persue a very different solution.
this is going to sound very complicated if you have never played with PC TV capture cards but i am currently experimenting with everything i talk about here for a laser ranging experiment i'm working on at the moment and it's not as difficult as it sounds...
i'm presuming a few things....
1. that you don't need a particularly mobile solution.
2. that you have an old PC with a spare USB port.

get yourself a cheap usb webcam. the one i used cost me 15euro from amazon.
you are going to want an application running on your PC that can take still images from the webcam. i run Linux on all my computers so i used vidcat (http://www.penguin-soft.com/penguin/man/1/vidcat.html) but i'm sure there are windows programmes that can take lots of still images per second as well.
find a programming language you feel comfortable with that has an add on that lets you decode still images without too much bother. i used python (runs on windows/mac/linux) with the PIL (Python Imaging Library: http://effbot.org/zone/pil-index.htm) because personally i find python a very easy language to use. i know for a fact there are similar addons for C++ and probably lots of other programming languages as well but i never did have the patience to learn C++ and i can throughly recommend python to anyone who hasn't done any programming in a long time but needs to get something like this working quickly.

so it's going to work like this:
put a nice dark background behind where the golf ball will travel. illuminate the area well so the white golf ball stands out.
take a still image of the dark backround every few tens of milliseconds with your USB camera.
run the image through your python program. the PIL library will give you an array with a value for each pixel in the captured image to indicate color.
subtract the value of each pixel from each new image from the same on an image of the black back ground and any large cluster of different colored pixels will indicate a passing golf ball.
apply some maths to find the center of the cluster of different pixels to find the center of the golf ball.
do the same thing a few tens of milliseconds later and apply some maths to work out the speed of you ball.

depending on the PC and USB camera you use you should be able to capture at least 50 frames per second and store them on disk. do you think this would be fast enough? how fast do speeding golf balls move? (sorry, golf wouldn't be on my list of passtimes.)
from my experience python's PIL probably couldn't work out the speed in real time so the actual speed would have to be calculated after the golf ball had flown.
my python program that subtracted one image from another and ran enough filtering to ignore background noise took around 1/2 second per image but time was not the crucial factor for me. maybe i could have speeded things up if i had to work with that may frames per second....
if you were willing to use C or C++ instead of python i'm sure things would run much faster but i'm not sure if real time processing would be possible.

like i say, i have everything i'm talking about working using low power linux machine (a Linksys NSLU2) which will eventually live onboard my next robot for laser ranging when i finally get round to finishing it's chassis but i probably had quite a head start, allready having used most of the things i talk about here before. (linux, pyhton, USB cameras, etc.)
the Linksys NSLU2 wouldn't be fast enough for your purpose though hense my suggestion that you use a full blown PC.

anyway, hope i have at the very least given you some food for thought,

dunk.

Offline CapnAhabTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: Sharp IR Sensors
« Reply #2 on: July 08, 2006, 03:28:56 AM »
Dunk,  thanks for your response, I really appreciate the time you have taken in your reply.  Unfortunately, I DO NEED it to be portable, and...

Quote "from my experience any reflected IR solution wouldn't have the accuracy you are looking for. this technique is fine for telling if something is out there but not a precise reading of how far and which direction."

That's fine! I just want to know the golf ball has passed my device.  If I use 2 detectors, say 6 inches apart, I can record the time between detector A and then detector B seeing the ball and then work out the speed.  As long as they are consistent i.e. they detect the ball at the same spot every time - I think that would work.

Having said that - your camera idea has merit & I will look at that also.

Good luck with your endeavours!

Dave

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: Sharp IR Sensors
« Reply #3 on: July 08, 2006, 06:14:25 AM »
hehe. that's what i get for repling to forum posts after too much beer. off on a tangent again.

when using these IR sensors you have to accept that you will get a lot of false positive results.
you will have to look for a change in the number of positive results.
rather than going off on another rant i'll refer you to this online project that should do pretty much what you want with a bit of modification:
go to the "12C508 IR Obstruction Detector" section here: http://users.frii.com/dlc/robotics/projects/botproj.htm

you will need a PIC programmer to build this one but it's fairly easy to get working. (it made the sensor on my first robot project.)
mounted on a robot it was good at "seeing" light colored walls but not so good at dark so with a nice shiny white golf ball you should get reasonable results.

i'm honestly not sure if this approach will give you the accuracy you are looking for but it's defiantly worth trying.

good luck and let us know how you get on!

dunk.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Sharp IR Sensors
« Reply #4 on: July 08, 2006, 10:20:28 PM »
Two questions.

Do you need the sensor to be automated, meaning do you need realtime results?

And second, are you just trying to find ball velocity?

If you dont need realtime results, and just want the velocity, there is an easier method than dunks . . .

Get your everyday digital camera out and record the golf ball in video mode. Then in any video editing software (or just pause between two frames) get two frames captured from the video with the ball in it.

You should see the ball travel X distance from frame capture 1 to frame capture 2. Use a background with some known distance markers, or use a 2nd camera aiming top down to interpolate 3D coordinates.
Knowing the camera frame rate (Y frames/second) you can then calculate ball velocity:

X/Y = ball velocity

I use this method to calculate the launch velocity of homemade rockets  :P

Oh and as for the sharp IR . . . I just dont see it working as it requires the ball to pass exactly through the needle point beam for it to work . . .

 


Get Your Ad Here

data_list