I've come back to this thread after about 3 weeks, and I think I see something here that I didn't realize before. Are you saying that SetServoTracking can control the camera servos connected to PWM1 and PWM2 and thereby cause the camera to track the green light, just like Kevin's MPLAB code does? If that is do, and I convert the values returned by CaptureTrackingData to degrees, I should be able to control the robot drive motors. Is that correct?
Quote:
Originally Posted by Kingofl337
The SetServoTracking command is the same as SetPWM but for the camera servos. If you want to have the camera auto target like it would if the servos were plugged into the camera then do this.
Code:
void Initialize ( void )
{
InitCamera ( 1 ) ; //Initialize camera for target color
SetServoTracking ( 1 , 1 ) ; // Sets camera servos to autotrack target
StartCamera ( ) ; // You need to restart the camera if you change camera servo settings
}
void OperatorControl ( void )
{
unsigned char ServoPan;
unsigned char ServoTilt;
SetServoTracking ( 1 , 1 ) ; // Sets camera servos to autotrack target
StartCamera ( ) ; // You need to restart the camera if you change camera servo settings
while ( 1 )
{
// Checks the where the camera wants the servos to be pointed.
CaptureTrackingData ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , &ServoPan , &ServoTilt ) ;
SetPWM ( 1 , ServoPan ) ; // Moves the servo for Pan
SetPWM ( 2 , ServoTilt ) ; // Moves the servo for Tilt
}
}
|