For some reason our robot refuses to turn when using autonomous with line followers
Declare:
DigitalInput *lightL;
DigitalInput *lightM;
DigitalInput *lightR;
Init:
lightL = new DigitalInput(7);
lightM = new DigitalInput(5);
lightR = new DigitalInput(3);
Autonomous Code:
while(IsAutonomous())
{
ilightR=(lightR->Get()==1);
ilightL=(lightL->Get()==1);
ilightM=(lightM->Get()==1);
dsLCD->Printf(DriverStationLCD::kUser_Line2, 1, "%d", ilightL);
dsLCD->Printf(DriverStationLCD::kUser_Line3, 1, "%d", ilightM);
dsLCD->Printf(DriverStationLCD::kUser_Line4, 1, "%d", ilightR);
dsLCD->Printf(DriverStationLCD::kUser_Line5, 1, "%d", atFork);
dsLCD->UpdateLCD();
if(initialconditions)
{
if (ilightM == 1)
{
myRobot.Drive(.5,0);
}
}
if (initialconditions && (ilightL == 1) && (ilightR == 0))
{
myRobot.Drive(.5,-.5);
}
if (initialconditions &&(ilightR == 1) && (ilightL == 0))
{
myRobot.Drive(.5,.5);
}
if((ilightL == 1) && (ilightR == 1))
{
initialconditions=false;
atFork=true;
}
if (atFork&&(ilightM==0))
{
myRobot.Drive(.5,.5);
}
if(atFork&&ilightM==1)
{
atFork=false;pastFork=true;
encoderL.Reset();
encoderR.Reset();
encoderL.Stop();
encoderR.Stop();
encoderL.Start();
encoderR.Start();
}
if(pastFork)
{
s[2]->Set(true);
if ((encoderL.Get()>arbitrarynumbernumber1)&&(encoderR.Get()>arbitrarynumbernumber2))
{
IareFinished=true;
}
if (!IareFinished)
{
if (ilightM==1)
{
myRobot.Drive(.5,0);
}
if ((ilightL==1) && (ilightR==0))
{
myRobot.Drive(.5,.5);
}
if ((ilightR==1) && (ilightL==0))
{
myRobot.Drive(.5,-.5);
}
}
if (IareFinished==true)
{
myRobot.Drive(0,0);//quad erat demonstratum
}
}
}
We also tried the example code and get the same results. The Line trackers appear to be working based on the lights on them.