View Single Post
  #3   Spotlight this post!  
Unread 27-02-2005, 10:47
kokodabear's Avatar
kokodabear kokodabear is offline
HELP!
AKA: Brady
#0686 (Bovine Intervention)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Frederick, MD
Posts: 13
kokodabear is an unknown quantity at this point
Send a message via AIM to kokodabear
Re: Panning algorithm

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;