View Single Post
  #4   Spotlight this post!  
Unread 11-01-2007, 12:02
itsme itsme is offline
Registered User
FRC #2217 (FOMH)
Team Role: Programmer
 
Join Date: Dec 2006
Rookie Year: 2007
Location: Israel
Posts: 86
itsme is an unknown quantity at this point
Re: Question about CMUCAM servo output

Well, it's not really important for me knowing the degrees. From what I understood from you, the output is the current PWM of the tilt\pan servo?
If it is like that, please tell me if this code is ok:

Code:
//This program makes the robot drive after the target that is being targeted by
//the CMU camera.  When the robot is close enough, it stops.

#define CLOSE_TO (a range between 0-255 [PWM])
unsigned char tilt;
unsigned char pan;

while(1)
{
          CaptureTrackingData(0, 0, 0, 0, 0, 0, 0, 0, &pan, &tilt);
          while(tilt<127)//PWM #127 means center of servo in easyC
          {
                     Drive(40,255); //makes the robot turn left (function I made)
                     CaptureTrackingData(0, 0, 0, 0, 0, 0, 0, 0, &pan, &tilt);
          }
          while(tilt>127)//PWM #127 means center of servo in easyC
          {
                     Drive(255,40); //makes the robot turn right (function I made)
                     CaptureTrackingData(0, 0, 0, 0, 0, 0, 0, 0, &pan, &tilt);
          }
          if(tilt==0)
          {
                    Drive(0,255); //makes the robot drive forward
          }
          if(pan>=CLOSE_TO) //if the pan is close
          {
                    stop(); //a function I made that stops the robot
                    return; //gets out of the function
          }
}
Oh, and another question: in this year's FRC the robot could see multiple targets (seeing 2 green lights on the rack) so it can confuse the robot, so can you give me some ideas on how to make the robot ignore one of the lights?
Sorry for the multiple questions, I'm a rookie in a rookie team.

Last edited by itsme : 11-01-2007 at 12:25.