View Single Post
  #2   Spotlight this post!  
Unread 25-01-2007, 20:46
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: Camera for turning

Quote:
Originally Posted by DustinB_3 View Post
I am using a combination of the camera and a gyro to turn until the camera is lined up with the green light. With the code I'm using the robot just rotates back and forth and will never stop. Is there a better way to accomplish this. Here is the code:

Camera_Handler();
Servo_Track();

temp_gyro = Get_Gyro_Angle();
tracking_state = Get_Tracking_State();

printf("gyro_angle = %d\r\n", (int)temp_gyro);

if(capture == 0 && tracking_state == CAMERA_ON_TARGET )
{
goal_angle = ((((int)PAN_SERVO - 124) * 65)/124);
capture = 1;
}

milliradian_goal = ((goal_angle * 3.1415 * 1000)/180);

if(capture == 1)
{
if((milliradian_goal - 60) < temp_gyro)
{
pwm03 = pwm06 = 150; //Turns robot left
pwm04 = pwm05 = 150;
}
if(temp_gyro < milliradian_goal + 60)
{
pwm03 = pwm06 = 104; //Turns robot right
pwm04 = pwm05 = 104;
}
if(((milliradian_goal + 60) >= temp_gyro) && (temp_gyro >= (milliradian_goal - 60)))
{
pwm03 = pwm06 = 127;
pwm04 = pwm05 = 127;
capture = 2;
}
}
Why are you setting all four PWM outs to the same value? If you want to turn left, set your right motors forward and your left motors either stopped or reversed and opposite for turning right.
__________________