Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Robot not turning with line followers (http://www.chiefdelphi.com/forums/showthread.php?t=91716)

normpearii 13-02-2011 14:51

Robot not turning with line followers
 
For some reason our robot refuses to turn when using autonomous with line followers

Declare:
Code:

DigitalInput *lightL;
DigitalInput *lightM;
DigitalInput *lightR;

Init:
Code:

lightL = new DigitalInput(7);
lightM = new DigitalInput(5);
lightR = new DigitalInput(3);

Autonomous Code:
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.


All times are GMT -5. The time now is 13:55.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi