# Head Tracking using servo - Which sensor??



## redg8r (Oct 20, 2007)

Hi All,
Looking for advice on choosing a sensor for a prop....

*Background:*
I've had this hacked prop for a few years that's oddly popular in my haunt.
Its a simple standing reaper with an oscillating fan motor mounted to the neck axis. Acting as a normal oscillating fan, as the head turns back and forth it appears to be watching or following the TOT's as they approach my yard.

However after watching the prop for any given time, the motion becomes predictable.

*Plan: *
I've begun fiddling with the picaxe 08m/18m and arduino uno and plan to swap out the fan mech with a single servo to control the neck movement.

To control the servo, I'm looking for a sensor, or an array of such to detect the location/s of people and have the head of this prop turn to stare at them as they move across the front of our property.

It appears the degree of rotation on my servo/s are @ 180 degrees which is perfect.

So... any advice on sensors? PIR? sonic? etc?
I'd prefer to keep the sensor/s contained in the prop instead of running wire to various locations in the yard.

Thanks folks.


----------



## imax (May 22, 2006)

I think I understand what you are asking for... and there's a variety of ways that you *could* do it - with varying degrees of success. If you want it to be really perfect... something like a camera would be best (maybe the kinect could be cool...!), but expect to spend time writing the code to process the images. 

Otherwise, you could use a series of break sensors or floor mat switches that feed into the micro pins and you rotate to the most recently broken beam/switch. Install them across a 30 degree fan and you can get fairly decent results - if you can control the people in front of it. You could actually use any sensor technology for this. 

Other thoughts that immediately pop into mind for research would be an ultrasonic sensor that you would mount perpendicular to your viewing audience. Measure the amount of time it takes to get a response with people standing at different positions in front of it, and simply rotate to the proper direction the shorter the time is. The longer it becomes, have it rotate the other way.. Come to think of it, this sounds like the most reliable and fastest/cheapest solution. You will have to control how people enter/exit the area, but that's the easy part, right?

Good luck and I'd be very interested in knowing what you end up doing.

-- Ian


----------



## HomeyDaClown (Oct 3, 2009)

I have worked on the same idea for some time now and have actually developed a tracking system to do this for another company.

It requires a video camera, there are no simple sensors that have this ability without contructing an array of some type (expensive). Then after capturing video frames in real time, you have to have the processing power and speed to analyze the video frame by frame. This process is called Blob Tracking, tracking a moving object and returning it's location.

It is far beyond the capabilities of any simple microprcessor. I have worked with multiple PIR sensors but the best you will get is Left Right Middle positions so a servo would be swinging 90 degrees each position change.
It doesn't work well at all.

Currently this is being done with webcams and laptops and there is a big open source project called CV dedicated to this stuff.

This system is based on CV:

http://www.noob.us/miscellaneous/autonomous-paintball-sentry-gun/


----------



## fritz42_male (May 5, 2009)

I can think of a possible way it would work for a single person but that's about it.

An ultrasonic rangefinder circuit at one end of a passage linked to a Picaxe/Arduino controlling the servo. As the distance to the sensor changes, adjust the head position.

If you wanted to be clever, use a breakbeam at the start of the passage and get that to trigger an interrupt where the head swings round to see the 'straggler' and then goes back to monitoring the progress of the first individual.


----------



## redg8r (Oct 20, 2007)

imax said:


> Install them across a 30 degree fan and you can get fairly decent results - if you can control the people in front of it. You could actually use any sensor technology for this.


Thats probably the quickest approach huh?
I like it because I can likely house the sensors in/on the prop itself.
Maybe a set of blinders fanned out to separate each sensor's FOV?



HomeyDaClown said:


> This system is based on CV:
> 
> http://www.noob.us/miscellaneous/autonomous-paintball-sentry-gun/


Wow, forgot I've seen that video before,
So essentially its analyzing video frames and creating numerical coordinates from changes on a frame to frame basis right?
I know you've worked with arduino's have you any experience w/ Nootropic's Video Experimenter Shield?
This would be an interesting approach to yard haunting, imagine mounting it to your roof and using it to control ALL your props.

Are you using infrared camera/s? I've heard rumors that typical pinhole cams will pick up infrared pretty well.



fritz42_male said:


> An ultrasonic rangefinder circuit at one end of a passage linked to a Picaxe/Arduino controlling the servo. As the distance to the sensor changes, adjust the head position.


I love that concept too, because in theory, it could control multiple props also.
My issue is navigation, my yard haunt path is "L" shaped (sidewalk. then 90 degree turn up the driveway) and maybe even "U" shaped (I have 2 driveways)

I did a lil searching and found one chip that will read a 3 meter distance I need 2-3 times that, know of any others?


----------



## fritz42_male (May 5, 2009)

Sparkfun do one up to 6.45M that's quite cheap

http://www.sparkfun.com/products/8504

or you can go up to 7.65M with the more expensive ones. Above this I suspect you would need to use laser rangefinders.

http://www.sparkfun.com/products/9495

Accuracy is 1cm!!!!!!

You could probably use 2 sensors and have one take over where the other leaves off.


----------



## redg8r (Oct 20, 2007)

fritz42_male said:


> You could probably use 2 sensors and have one take over where the other leaves off.


Yeah that idea occurred to me after I replied... lol :googly: also a good way to change pathway angles.

Thanks fritz for the links and all your inspiration here.


----------



## fritz42_male (May 5, 2009)

You are more than welcome.


----------



## HomeyDaClown (Oct 3, 2009)

The Video Experimenter's Board is very limited at best. It has a hard time tracking anything but a white dot or circle on a black background. It still uses the Arduino to do some rather fast and very basic pixel comparisons, not enough resolution to really track a human unless you can get everyone to put a white sticker on their heads and face the camera all the time.

This guy combines a IR Thermal Array Position Sensor with a 
Servo controller in one package, made to track humans:










Devantech 8 Pixel Thermal Array Sensor

​


----------

