Let's Make Robots!

Problems with object tracking using a Dagu compound eye and pan tilt set up.

  Currently I am having problems with object tracking.  My current set up is a Dagu compound eye on a Dagu pan/tilt braket with 2 micro servos in it for turning.  All of that is hooked up to a picaxe 28x1 board correctly, but I run into my problem with my code.  My code kinda worked but was really jerky and will still move when there is nothing there.  Also sometimes it will go like it has a mind of its own.  I thought it was moving when there was nothing there because I made it read the two eyes on opposite sides and just turn to the one with higher value.  Next to try to eliminate this, I made it have to be over a certain value to turn but doing this just made it really hard to turn.  So after that I searched LMR to see what I could find and I came up with Oddbot's post on object tracking.(http://letsmakerobots.com/node/4428)  After reading that I tried his code.  I changed it for my set up but it just drove my servos one way...  After that I tried to see why it did that but his code was a little to much for me.

 

Any advice or comments will be great.

Joe

Comment viewing options

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

I would start with a basic program to turn the LED's on, read the ADC's and debug the results. Check your numbers and see if they make sense and also make sense in terms of the main code. Check just your servos --What are the min and max positions? What exact number gives you center? Find out and write these numbers down. Continue this process, testing each aspect of the task until they all work. When they do, put them together. Done.

CTC beat me to it. Test everything seperately before you try to get it all working at once. With a a value of 150 being sent to your servos (1500uS) your Pan / Tilt assembly should be centered.

Use debug to check that all 4 analog inputs from the eye give similar readings when a piece of white paper is placed directly in front of the eye.

With the IR LEDs on the readings should be higher than when the LEDs are off.

and I have it all written down.  Then I put them in the Mr. Basic and it still tried to keep my servos going like they were countinuos.  I went over it multiple times but still could not find a problem.  On the bright side though my code started working better but still has room for improvements. 

The original tracking code was written for the picaxe.

Read this tutorial on Mr. General since most of the code is the object tracking code. http://letsmakerobots.com/node/24348

There are several variables that may need adjusting depending on your servos. The LRscalefactor and UDscalefactor can be changed depending on the speed or your servos. If the value is too small then the head might track too slowly. If the value is too big then the servos will over correct.

If your head turns away from your hand instead of towards it then the easiest fix is simply to swap you left and right inputs from the eye. You might also need to swap up and down. This is because not all brands of servos rotate the same way.

 

I just tried that but it did not work.  I changed all the servos, IR leds, inputs, and a few other things in the code to fit my setup.  The results were that the servos would just keep going right and up no madder what I did.  Or it would do nothing at all.  I have the IR leds on pin 4, the pan servo on 1,  the tilt servo on 0, and the inputs were IRleft 0, IRright 2, IRup 1, IRdown 3.