|
Re: Camera without servos
So you mean something like this?
Code:
if (swt_camera)
{
if (pan_error < 5 | pan_error > -5)
{
// Set drive motors to neutral
pwm_rightDrive_cim = pwm_rightDrive_cim = 127;
pwm_leftDrive_cim = pwm_leftDrive_fp = 127;
// Tell the controller that it is now on target
Tracking_State += STATE_PAN_ON_TARGET;
}
else
{
// If the image is not center, check with the allowable error range
if (pan_error > PAN_ALLOWABLE_ERROR_DEFAULT)
{
// Attempt to turn left
pwm_rightDrive_cim = pwm_rightDrive_cim = 200;
pwm_leftDrive_cim = pwm_leftDrive_fp = 120;
}
else if(pan_error < -1 * PAN_ALLOWABLE_ERROR_DEFAULT)
{
// Attempt to turn right
pwm_rightDrive_cim = pwm_rightDrive_cim = 120;
pwm_leftDrive_cim = pwm_leftDrive_fp = 200;
}
else
{
// Set drive motors to neutral
pwm_rightDrive_cim = pwm_rightDrive_cim = 127;
pwm_leftDrive_cim = pwm_leftDrive_fp = 127;
// Tell the controller that it is now on target
Tracking_State += STATE_PAN_ON_TARGET;
}
}
}
Sorry I can't really format it inside this little form :-/
Thanks for the help!
__________________
-Kiet Chau
2004-2008 - Software Developer/Driver on Team #968
2008-2011 - Software Developer/Coach/Mentor/"Engineer" on Team #968
2011-Present - Mentor & Engineer on Team #1538
www.team1538.com
Last edited by kiettyyyy : 09-04-2006 at 21:01.
|