View Single Post
  Spotlight this post!  
Unread 12-02-2007, 14:17
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Camera Code Update

Quote:
Originally Posted by Tom Bottiglieri View Post
After I just finished porting your tracking software to work with WPILib...!!!!

Can't wait to test the new stuff out. I'm particularly excited about the increased servo resolution.
This is the new search code:
Code:
///////////////////
// //
// search code //
// //
///////////////////
 
// To provide a delay for the camera to lock onto the
// target between position changes, we only step the camera
// to a new position every SEARCH_DELAY times while we're 
// in search mode. SEARCH_DELAY is #define'd in tracking.h
loop_count++;
 
if(loop_count >= Tracking_Config_Data.Search_Delay)
{
// reset the loop counter
loop_count =0;
 
// If we're starting a new search, initialize the pan
// and tilt servos to the search starting point.
// Otherwise, just continue the search pattern from
// where we left off. The variable new_search is reset
// to one each time the tracking code (above) executes.
if(new_search ==1)
{
new_search =0;
temp_pan_servo = Tracking_Config_Data.Pan_Min_PWM;
temp_tilt_servo = Tracking_Config_Data.Tilt_Center_PWM; 
}
else
{
// calculate new pan position based upon the current pan servo position
temp_pan_servo = (int)pan_servo_position;
 
// step the pan servo to its next destination
temp_pan_servo += (int)Tracking_Config_Data.Pan_Search_Step_Size;
 
// is the new pan servo position beyond the end of its travel?
if(temp_pan_servo > (int)Tracking_Config_Data.Pan_Max_PWM)
{
// send the pan servo back to the starting position
temp_pan_servo = (int)Tracking_Config_Data.Pan_Min_PWM;
 
// calculate new tilt position based upon the current pan servo position
temp_tilt_servo = (int)tilt_servo_position;
 
// step the tilt servo to its next destination
temp_tilt_servo += (int)Tracking_Config_Data.Tilt_Search_Step_Size;
 
// is the new tilt servo position beyond the end of its travel?
if(temp_tilt_servo > (int)Tracking_Config_Data.Tilt_Max_PWM)
{
// send the tilt servo back to the starting position
temp_tilt_servo = (int)Tracking_Config_Data.Tilt_Min_PWM;
}
// update the local variable used to store the current tilt servo positions
tilt_servo_position = (unsignedchar)temp_tilt_servo;
}
// update the local variable used to store the current pan servo positions
pan_servo_position = (unsignedchar)temp_pan_servo;
}
 
// update the pan and tilt servo PWM value
Set_Pan_Servo_Position(pan_servo_position);
Set_Tilt_Servo_Position(tilt_servo_position);
}
The increased servo resolution was mentioned towards the end of this thread:

http://www.chiefdelphi.com/forums/sh...ad.php?t=51802

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org