Example #1
0
        public static bool paralelParking(QueueEntry qe, EventArgs e)
        {
            double frontLeft  = RealFuncs.getSensorValue(Sensor.FrontLeft);
            double frontRight = RealFuncs.getSensorValue(Sensor.FrontRight);
            double sideLeft   = RealFuncs.getSensorValue(Sensor.SideLeft);
            double sideRight  = RealFuncs.getSensorValue(Sensor.SideRight);

            funcs.Log("stare :" + stare.ToString());
            switch (stare)
            {
            case -1:
                RealFuncs.goFront(60, 250);
                stare = 0;
                break;

            case 0:
                if (sideRight < 100)
                {
                    stare = 1;
                }
                break;

            case 1:
                if (sideRight > 200)
                {
                    RealFuncs.goFrontRight(60, 250);
                    stare = 2;
                }
                break;

            case 2:
                if (frontRight < 175)
                {
                    RealFuncs.goFront(60, 175);
                    stare = 3;
                }
                break;

            case 3:
                if (sideRight < 220)
                {
                    RealFuncs.rotirePeLoc(10, 175, Engines.RightEngines);
                    stare = 4;
                }
                break;

            case 4:
                if (sideRight < 80)
                {
                    stare = 5;
                }
                break;

            case 5:
                if (doRightParalel())
                {
                    stare = 6;
                    RealFuncs.goBackRight(10, 150);
                    distantaParcursa(true);
                }
                break;

            case 6:
                if (distantaParcursa() > 75)
                {
                    stare = 7;
                    distantaParcursa(true);
                    RealFuncs.goBackLeft(10, 150);
                }
                break;

            case 7:
                if (distantaParcursa() > 75)
                {
                    stare = 8;
                    distantaParcursa(true);
                    RealFuncs.goFrontRight(10, 150);
                }
                break;

            case 8:
                if (distantaParcursa() > 75)
                {
                    stare = 9;
                    distantaParcursa(true);
                    RealFuncs.goFrontLeft(10, 150);
                }
                break;

            case 9:
                if (distantaParcursa() > 75)
                {
                    stare = 10;
                    distantaParcursa(true);
                    RealFuncs.goFront(10, 50);
                }
                break;

            case 10:
                if (distantaParcursa() > 15)
                {
                    stare = 11;
                    RealFuncs.StopEngines();
                    return(true);
                }
                break;
            }
            return(false);
        }