Quote:
|
Originally Posted by jgannon
I'm working on a way to make the camera pan around until it finds green, because if the target is just out of its range of view, it continues looking straight ahead. The problem that I've run into is that when I manually set the servos, it disables the automatic tracking, and it's really inefficient to repeatedly switch between automatic and manual modes. Has anybody written an effective algorithm for panning to find a color?
|
Who needs default code anyway? Make your own auto tracking code so you dont have to switch modes. Remember that servos have to stay between 46 and 210, and use cam.x and cam.y to determine how to adjust them.
As for panning, try this: (haven't tested but should work)
Code:
// At top of file
int tempPan = 128; // Starting Position
char tInc = 4; // Rotate Speed
// In autonomous 26.2 ms loop
if (tempPan==210 || tempPan==46) {
tInc *= -1;
tempPan += tInc;
}
else if (tempPan + tInc > 210)
tempPan = 210;
else if (tempPan + tInc < 46)
tempPan = 46;
else
tempPan += tInc;