Let's Make Robots!

Smooth Object Tracking

head follows an object around the room
foureyes.bas1.89 KB

I was looking for a way to have a robots head follow something or someone around. The best results I found were the ones using a camera, but these are a bit expensive to my taste. I've seen some robots that have a servo with an IR-sensor on top that finds either the left or the right edge of anything you put in front of it. I toyed around with that, but I got frustrated with a few things.

If you follow the left edge of an object, the robot allways seem to look slightly left past the object instead of in the middle. Also:When the edge is detected, the servo goes from left to right and back between detecting the object and looking past it.  

 So I came up with the idea to have two IR sensors inside the head that can move (rotate) by themselves: independant of the head. The sensors detect the edges and provide information as to whether to turn the head left or right. The head doesn't need to move back and forth as much to detect the edges, giving it a much smoother object tracker.

 I wanted to do this with a picaxe 08M to make "smart eyes". The bots mainboard can than communicate with the 08M to obtain more info than just the range from the eyes. but of course I had to try it out first. Also: with the 08M hooked up to 2 servos and 2 analog sensors that leaves only 1 input pin and no outputs. Oh well.


This test setup was done "the Frits! way": i.e. with paintsticks and double sided tape and a few paperclips.

The top servo pushes the eyes outward and pulls them inward. The bottom servo rotates the "head".

The algorithm is simple.


  • Pull the eyes inwards and turn the head in the direction of the eye that detects an object.
  • If both eyes see an object start pushing outward
  • Turn the head in the direction of the eye that detects an edge (=no object in sight) 
  • If both eyes lost sight of the object, go back to pulling inward.


The servos are a bit jerky, but the same servos work fine in Edward, so it is probably due to lack of caps or underpowering of the servos. 

As you can see in the video (sorry for the poor quality) the eyes are moving back and forth, but the head is steady.

Future improvements


  • Make it smaller!
  • Put the eyes inside a head so you wont see them moving so much.
  • Expand the  program to determine object width or width of a possible escape route for the bot
  • Put everything in a small independent package. I want this to become an "intelligent" sensor you can just hook up to a bot using serial or I2C or something. 
  • Add vertical axis



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
I'm going to end up stealing all your ideas, I fear... I've been using single-sensor edge detection, and have also found the constant overscan-then-backtrack annoying, especially as I have a camera mounted too. I'd been trying to work out how to use two adjacent sensors so that I could keep the pan unit (and thus camera feed) steady until one lost signal, which I'd then interpret as motion and start tracking again, but this looks like it'd work a lot better!

Hahaha! THAT's not stealing. The stuff that folk post around here is FOR you to "steal"! The hope is that you will take it, better it and come up with something for ME to steal!!

It's your LMR, too!

I agree. Please make it work even better and post your ideas for us!

BTW as was commented at the original BLOG post: It should work better if you mount the sensors vertically because it has less interference trying to detect the edge. 

I read in your blog that you wanted a more accurate rangefinder but you thought my rangefinder was too big. This is the sensor head of the MkII Laser RF. I've kept at it because I also want a more precise rangefinder. (click on photo for full sized image).


As you can see it's only about 47mm wide (1 and 7/8 inches). I hope to have a video of it in action soon but am having a few technical difficulties. Once it's working I'll post all the information on it and you can decide if it suits your needs.

Wow, to put it short!
That's pretty small indeed. I'm going to look into that a bit more. You replaced the spinning mirror with a servo? no wait. let me check out your page first.
The MkII hasn't got a page yet.  I was waiting till everything was working. Well everything does work just not all at the same time thus the technical difficulties mentioned earlier.

Is that device just based on turning the angle of the laser and then recieving the light back? A few years back (about 2003 I think), the Buffalo State Robotics group had a really sweet AVR-based laser range finder. Unfortunately, it was based on a very difficult to find CCD linear array, and the company making that CCD device went under mid-2004. Being primarily a software and digital electronics guy, I never got around to hacking up a version (since every other CCD linear array I found required crazy analog filters and amplifiers). I would guess this might be an option...


Yep, check out my blog on homemade laser rangefinders, some one mentioned that project. The sharp sensors mintvelt is using also work in a simular way with the same non-linear response.

Hell yeah! -A repost! I get to re-respond!

Wait, what did I say in the first place? Something about this being great or something... Keep it simple, stupid? I dunno, something like that.