Go to Post Sally Ride says role models are needed - that's you. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #14   Spotlight this post!  
Unread 11-02-2005, 18:43
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: AUTO TRACKING!!!!!!:(

Quote:
Originally Posted by russell
The problem is that when it finds a color and I tell it to try to track the color the servos reset to the center position...
I had this same problem. Rather then spend a long time fixing it, I just control the servos right off of the RC.

It's working fine, and is legal (I had thought it wasn't at one point, but there is a question in the Q&A thing that says otherwise, ID 1480)

Here's the code that we are using.. it should be easily changed to other configurations
Code:
//Pan and tilt servos
#define cam_pan pwm01
#define cam_tilt pwm02
//Internal posistion variables
unsigned char cam_p=128;
unsigned char cam_t=128;

if (cam.x == 0 && cam.y == 0) {
		//cam_pan and cam_tilt control the servo's on the mount
		//cam_p and cam_t are our local variables
		cam_pan = cam_p;
		cam_tilt = cam_t;
		//Tell the camera where the servos are,
		//so we get useful values when it finds a target
		camera_set_servos(cam_pan,cam_tilt);
		//What color do we want to track?
		camera_find_color(GREEN);
		//This does all the panning
		cam_p += 10;		//X pan
		if (cam_p > 210) { //if we hit the x limit
			cam_p = 46;		//start over
			cam_t += 10;	//but change the tilt
		}
		//if we've tilted too much
		if (cam_t > 117) cam_t = 97;
	}
	else { 
		//sometimes we get nonsense packets, this fixes them
		if (cam_pan > 0 && cam_tilt > 0) {
			//update the servo and our var with new servo values
			cam_p = cam_pan = cam.pan_servo;
			//update the tilt servo with new tilt value
			cam_tilt = cam.tilt_servo;
		}
	}
The trick here is we fool the servo into thinking the servos are connected to it. We do that with the camera_set_servo command. After it finds a target, we update the servos with where the camera thinks it is. The only thing I wanted to do with this code is get rid of the internal variables that hold the servo posistions.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Camera Auto Tracking? Ryan Cumings Programming 9 22-01-2005 02:20
IR Tracking & Navigation Tallman General Forum 3 20-01-2004 17:26
auto archiving of posts Joe Ross CD Forum Support 4 01-01-2004 02:04
My auto is better than yours.. lol randomperson Programming 25 07-04-2003 12:10
picking auto program Mike375 Programming 19 03-03-2003 15:47


All times are GMT -5. The time now is 19:19.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi