This is just our main function.
void fetch_cont()
{
moveFetch();
moveTurn (180.0, 8);
fetch_cont();
}
void main()
{
int swallow_pid, status, homeColor, enemyColor,
orientation, threshold, line_follow_pid, fetch_pid ;
float temptime;
long movefwd = 50L;
long movefwd1 = 1150L;
ir_transmit_off();
lineOnLED();
lineCalibrate();
lineOffLED();
start_machine2(ANALOG_CDS_START, 2);
ir_transmit_on();
lineOnLED();
enable_servos();
servo(1,0); /*keep yer damn arm down!*/
swallow_pid = start_process(lineBallDigital());
/*continuosly swallows anything that gets in the mouth*/
printf("Getting line orientation.\n");
orientation = lineOrientation();
homeColor = orientation % 4;
printf("Moving in orientation %d.", orientation);
status = moveInitial(orientation); /*moveInitial
should now get all orientations to face enemy side*/
if ((orientation == LEFT) || (orientation == (4+LEFT)))
{
printf ("Fetching our ball\n");
status = moveFetch();
beep();
printf ("Turning around\n");
moveTurnUnguarded(-90.0,8);
moveTurnUnguarded(-90.0,8);
/* moveTurnUnguarded (-180.0,8);
*/
printf ("Fetching enemy ball\n");
status = moveFetch();
beep();
printf ("Getting out of here!\n");
moveUnguardedTimed(-8,-8,5000L);
}
else if ((orientation == FORWARD) || (orientation
== (4+FORWARD)))
{
status = moveInitialSwing(FORWARD);
status = moveSweepSwing();
}
else if ((orientation == BACKWARDS) || (orientation
== (4+BACKWARDS)))
{
status = moveInitialSwing(BACKWARDS);
status = moveSweepSwing();
}
else{
printf ("Fetching enemy ball\n");
status = moveFetch();
beep();
printf ("Turning left\n");
moveTurnUnguarded(90.0, 8);
moveUnguardedTimed(-8,-8,960L);
printf ("Turning left towards hill\n");
moveTurnUnguarded(90.0, 8);
armExtend();
moveGuarded(8,8);
msleep(400L);
printf ("At hill\n");
beep();
while (seconds() <= 43.0)
{
}
printf ("RUN AWAY!\n");
armRetract();
moveUnguardedTimed(-8,-8,720L);
moveTurnUnguarded(-90.0,8);
moveUnguardedTimed(8,8,960L);
moveTurnUnguarded(90.0,8); /*fickle*/
move(8,8);
}
}
|