Let's Make Robots!

First Object Follow

Follows a solid object

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.


Psuedo Code:

(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)



--That's it!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I guess I had nothing to say!

At any rate, thanks mint, I have had problems with the whole servo/PWM thing and never noticed the fact they use the same internal timer! I re-read the manual. This was a great heads-up for me. As we speak, I am adding a 14m to Walter's board as a stand alone to take care of his main motors. --Good chance to get famillar with the serin and serout commands as well! Thanks, you guru, you.



You screamer!

Maybe, you could try this without the "neck" servo. Just the four-eyes and the wheels

Nice four-eyed setup. Too bad it didn't work out (yet). Your wide eyed setup seems to work pretty smoothly as well. I'd like to give your sizing-up and follow idea a try as soon I find the time and material to make an improvized mobile platform (Hmm... IMP : nice bot name) to put foureyes on...

How did you solve the problem of using PWMOUT and SERVO commands at the same time? Or do you just turn the servos of while tunring?

I know what you mean about the complexity thing. One more reason to give the eyes their own picaxe. I'm thinking about making a bot with every complex or moving part into an I2C slave. One slave for motors+encoders, one for the head and one for arms.

Nice project. I am assuming it does something like if left has a closer object than right it moves to try to get both sensors to read a similar distance object and move toward it. It would be fun to expand this so it follows an object, but if the object stops, it moves on to find something else to follow. Kind of like a dog. When you walk it follows, but when you sit down it stays at your feet for a while then wonders off...


Great project. Can you expand a bit on the overall way it achieves the object following?