Example #1
0
        public static bool mergiParalelPeStanga(QueueEntry qe, EventArgs e)
        {
            int pd;

            switch (state3)
            {
            case 0:
                RealFuncs.goFront(30, 230);
                state3 = 1;
                break;

            case 1:
                pd = (int)isLeftParalel();
                if (pd == 0)
                {
                    if (funcs.getSensorValue(Sensor.SideRight) < 12)
                    {
                        RealFuncs.goFrontRight(30, 200);
                    }
                    break;
                }
                if (pd == 1)
                {
                    RealFuncs.goFrontLeft(30, 220);
                    state3 = 2;
                }
                else
                {
                    RealFuncs.goFrontRight(30, 220);
                    state3 = 2;
                }
                break;

            case 2:
                pd = (int)isLeftParalel();
                if (pd == 0)
                {
                    RealFuncs.goFront(30, 230);
                    state3 = 1;
                }
                break;
            }

            return(false);
        }
Example #2
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);
        }
Example #3
0
        public static bool test1Entry(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);

            if (numaraIesiri)
            {
                if (eInDreptulUneiIesiri)
                {
                    if (sideRight < 300)
                    {
                        iesiriTrecute++;
                        funcs.Log("iesiriTrecute=" + iesiriTrecute.ToString());
                        eInDreptulUneiIesiri = false;
                    }
                }
                else
                {
                    if (sideRight > 300)
                    {
                        eInDreptulUneiIesiri = true;
                    }
                }
            }
            int ip;

            //funcs.Log("st=" + state5.ToString());
            switch (state5)
            {
            case 0:
                state5 = 1;
                RealFuncs.goFront(30, 250);
                break;

            case 1:
                if (frontLeft < 170 || frontRight < 170)
                {
                    RealFuncs.rotirePeLoc(30, 250, Engines.LeftEngines);
                    state5 = 2;
                }
                break;

            case 2:
                ip = (int)isLeftParalel();
                switch (ip)
                {
                case 0:
                    RealFuncs.goFront(30, 250);
                    state5 = 4;
                    break;

                case 1:
                    RealFuncs.rotirePeLoc(30, 50, Engines.RightEngines);
                    state5 = 3;
                    break;

                case 2:
                    RealFuncs.rotirePeLoc(30, 250, Engines.RightEngines);
                    state5 = 3;
                    break;

                default: break;
                }
                break;

            case 3:
                ip = (int)isLeftParalel();
                switch (ip)
                {
                case 0:
                    RealFuncs.goFront(30, 250);
                    state5 = 4;
                    break;

                case -1:
                    RealFuncs.rotirePeLoc(30, 50, Engines.LeftEngines);
                    state5 = 2;
                    break;

                case -2:
                    RealFuncs.rotirePeLoc(30, 250, Engines.LeftEngines);
                    state5 = 2;
                    break;

                default: break;
                }
                break;

            case 4:
                numaraIesiri = true;
                if (frontLeft < 200 || frontRight < 200)
                {
                    RealFuncs.rotirePeLoc(30, 250, Engines.RightEngines);
                    state5 = 6;
                }
                break;

            case 5:
                ip = (int)isRightParalel();
                switch (ip)
                {
                case 0:
                    RealFuncs.goFront(30, 250);
                    state5 = 4;
                    break;

                case -1:
                    RealFuncs.rotirePeLoc(30, 50, Engines.RightEngines);
                    state5 = 6;
                    break;

                case -2:
                    RealFuncs.rotirePeLoc(30, 250, Engines.RightEngines);
                    state5 = 6;
                    break;

                default: break;
                }
                break;

            case 6:
                ip = (int)isRightParalel();
                switch (ip)
                {
                case 0:
                    RealFuncs.goFront(30, 250);
                    state5 = 4;
                    break;

                case 1:
                    RealFuncs.rotirePeLoc(30, 50, Engines.LeftEngines);
                    state5 = 5;
                    break;

                case 2:
                    RealFuncs.rotirePeLoc(30, 250, Engines.LeftEngines);
                    state5 = 5;
                    break;

                default: break;
                }
                break;

            case 7:
                if (frontRight > 500)
                {
                    state5 = 8;
                }
                break;

            case 8:
                if (frontRight < 700)
                {
                    state5 = 9;
                }
                break;

            case 9:
                funcs.Log("lrd=" + lrd.ToString() + "\nfr=" + frontRight.ToString());
                if (lrd == -1)
                {
                    lrd = frontRight;
                    break;
                }
                if (lrd < frontRight)
                {
                    RealFuncs.goFrontRight(3, 250);
                    state5 = 10;
                }
                lrd = frontRight;
                break;
            }
            return(false);
        }
Example #4
0
        public static bool parcareLaterala(QueueEntry qe, EventArgs e)
        {
            funcs.Log("st=" + state2.ToString());

            switch (state2)
            {
            case 0:
                RealFuncs.goFront(30, 200);
                state2 = 1;
                break;

            case 1:
                tmp2 = funcs.getSensorValue(Sensor.SideRight);
                if (tmp2 < 50)
                {
                    state2 = 2;
                }
                break;

            case 2:
                tmp2 = funcs.getSensorValue(Sensor.SideRight);
                if (tmp2 > 50)
                {
                    state2 = 3;
                    RealFuncs.goFrontRight(30, 200);
                }
                break;

            case 3:
                tmp2 = funcs.getSensorValue(Sensor.FrontRight);
                if (tmp2 < 55)
                {
                    state2 = 4;
                    RealFuncs.goFrontLeft(30, 250);
                }

                break;

            case 4:
                if (isRightParalel(3) == 0)
                {
                    RealFuncs.goFront(30, 175);
                    state2 = 5;
                    return(false);
                }
                break;

            case 5:
                if (Math.Abs(funcs.getSensorValue(Sensor.FrontLeft) - funcs.getSensorValue(Sensor.FrontRight)) < 10)
                {
                    RealFuncs.StopEngines();
                    RealFuncs.goBack(1, 150);
                    return(true);
                }
                break;

            case 6:

                break;

            default:
                break;
            }

            return(false);
        }