Quote:
Originally Posted by Tom Bottiglieri
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