First Object Follow
Being quite inpired by Mintvelt's "FourEyes", I decided to give it a shot and try my own.
The mechanics were solid and the inital tests went well, however I tried to expand on Mintvelt's code and adapt it for my purposes and it all went downhill from there. It just goes to show, if you write your own code instead of cutting and pasting, it is just that much easier to change and debug. In addition, I found that it was quite a task indeed to try to get both servos, both sharp sensors and the motors all going at once! Staying with the KISS philosophy, I simplified...
This seemed to do the trick. Very simple, as each sensor catches an edge the head servo turns and the speed of one wheel is cut in half using the PWMOUT command.
To Do Soon:
I think I can have the best of both worlds here... I would like to reinstall the "four-eyes" assembly but eliminate the constant in and out movement. Here's what I mean: I think it would work well to have the robot start with "sizing-up" the target you intend to use at the begining of the run. The robot could do a quick in and out sweep as well as a little right/ left and get a very good idea of the size of the target and thus set the eyes to their best position at a given distance. From there, using just the R/L sweep the robot could follow it -speeding up and slowing down to keep the target at a given distance. I know, you are loosing some accuracy as the target moves closer and farther away but you are freeing up a lot of "thinking space"... Just a thought.
(Bear in mind the target was just about the width of the 2 sensors so you don't see a bunch of side-to-side stuff)
Start sensors in the middle
If one sensor catches an object (is closer than a given value) turn head that way
--Continue, as each sensor catches an edge, turn head that way (adding one to the servo command)
If the head is centered (+ or - 5 points either way), go forward
if the head is off to one side, slow down that wheel by 50% (PWMOUT command)