Panning algorithm

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?

We’ve tried time and time again, and we couldn’t find a way to do it. Now we just kinda hope it’ll be in our robots field of view.

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)

// 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;
	tempPan	+= tInc;

I found a really good way by accident…

just have it search for green and set the result in a variable called “cantfindgreen” 0 being it found it, 1 being it didnt, then put something like this in your code

if (cantfindgreen)

and on the top have it set the servos to the variable pan and tilt… No this does NOT break the servo… quite amazingly when it hits the end of it, it spins to the other side and continues…

For partlly that reason, we decided not to let the camera do its own pan, but hooked the pan servo to a PWM output on the RC. We start at one side and skip to the other until we get T packets that we like.

Lynn (D) - Team Voltage 386

For this reason we rewrote the camera code they gave us, basically from scratch.

It works a lot better now, but it was a lot of work.

Why wouldnt you want it to do that? Is there a flaw I am not seeing?