示例#1
0
    void Update()
    {
        //Read sensor values
        float leftSensor  = LeftLD.getLinearOutput();
        float rightSensor = RightLD.getLinearOutput();

        //Calculate target motor values
        m_LeftWheelSpeed  = (rightSensor * MaxSpeed) * 7;
        m_RightWheelSpeed = (leftSensor * MaxSpeed) * 7;
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        float leftSensor  = LeftLD.getLinearOutput();
        float rightSensor = RightLD.getLinearOutput();

        m_LeftWheelSpeed  = leftSensor * MaxSpeed;
        m_RightWheelSpeed = rightSensor * MaxSpeed;


        //Calculate target motor values
        //A velocidade das rodas é inversamente proporcional ao output dos sensores
    }
示例#3
0
    void Update()
    {
        //Read sensor values
        float leftSensor  = LeftLD.getLinearOutput();
        float rightSensor = RightLD.getLinearOutput();

        //Calculate target motor values
        //Sensor da direita influencia roda da esquerda e vice-versa
        m_LeftWheelSpeed  = rightSensor * MaxSpeed;
        m_RightWheelSpeed = leftSensor * MaxSpeed;

        float westObjectSensor = westOD.getOutput();
        float eastObjectSensor = eastOD.getOutput();

        m_LeftWheelSpeed  += (1 / westObjectSensor) * MaxSpeed;
        m_RightWheelSpeed += (1 / eastObjectSensor) * MaxSpeed;
    }
示例#4
0
    void Update()
    {
        //Read sensor values
        //sensores de luz
        float leftSensor  = LeftLD.getLinearOutput();
        float rightSensor = RightLD.getLinearOutput();
        //sensores de proximidade
        float leftRaySensor  = RRcast.getDistancia();
        float rightRaySensor = RRcast.getDistancia();

        //Calculate target motor values
        //usa a fórmula de relé (a+b-a*b)
        //quando não detecta nada na proximidade são os sensores de luz que controlam as rodas, estando o da direita ligado ao esquerdo e vice-versa.
        //quando detecta algo na frente ignora os imputs das luzes e gira as rodas em setidos opostos (com velocidade dependente da distância ao objecto) e vira-o para a dirita
        //até não ter nada nos sensores, passando as luzes novamente a controlar as rodas.
        m_LeftWheelSpeed  = (((leftRaySensor + rightRaySensor) / 2) + rightSensor - ((leftRaySensor + rightRaySensor) / 2) * rightSensor) * MaxSpeed;
        m_RightWheelSpeed = (-((leftRaySensor + rightRaySensor) / 2) + leftSensor - -(((leftRaySensor + rightRaySensor) / 2)) * leftSensor) * MaxSpeed;
    }
示例#5
0
    void Update()
    {
        //Read sensor values
        float leftSensor  = LeftLD.getLinearOutput();
        float rightSensor = RightLD.getLinearOutput();

        //Calculate target motor values
        //A velocidade das rodas é inversamente proporcional ao output dos sensores


        m_LeftWheelSpeed  = (1 / leftSensor) * MaxSpeed;
        m_RightWheelSpeed = (1 / rightSensor) * MaxSpeed;

        float westObjectSensor = westOD.getOutput();
        float eastObjectSensor = eastOD.getOutput();

        m_LeftWheelSpeed  += (1 / westObjectSensor) * MaxSpeed;
        m_RightWheelSpeed += (1 / eastObjectSensor) * MaxSpeed;
    }
示例#6
0
    void Update()
    {
        //Read sensor values
        float leftSensor  = LeftLD.getLinearOutput();
        float rightSensor = RightLD.getLinearOutput();

        //Calculate target motor values
        m_LeftWheelSpeed  = leftSensor * MaxSpeed;
        m_RightWheelSpeed = rightSensor * MaxSpeed;

        float westObjectSensor = westOD.getOutput();
        float eastObjectSensor = eastOD.getOutput();

        m_LeftWheelSpeed  += (1 / westObjectSensor) * MaxSpeed;
        m_RightWheelSpeed += (1 / eastObjectSensor) * MaxSpeed;

        //Calcular os outputs dos sensores

        //Conforme os outputs rodar o carro
    }
示例#7
0
    void Update()
    {
        //Read sensor values
        float leftSensor  = LeftLD.getLinearOutput();
        float rightSensor = RightLD.getLinearOutput();

        //Calculate target motor values
        m_LeftWheelSpeed  = leftSensor * MaxSpeed;
        m_RightWheelSpeed = rightSensor * MaxSpeed;


        //Calcular os outputs dos sensores
        bool northSensor = northOD.getOutput();
        bool southSensor = southOD.getOutput();
        bool eastSensor  = eastOD.getOutput();
        bool westSensor  = westOD.getOutput();

        //Conforme os outputs rodar o carro
        if (northSensor)
        {
            if (!eastSensor)
            {
                transform.root.transform.Rotate(0, 10, 0);
            }
            else if (!westSensor)
            {
                transform.root.transform.Rotate(0, -10, 0);
            }
            else if (!southSensor)
            {
                transform.root.transform.Rotate(0, 180, 0);
            }
        }

        if (westSensor)
        {
            if (!northSensor)
            {
                transform.root.transform.Rotate(0, 0, 0);
            }
            else if (!eastSensor)
            {
                transform.root.transform.Rotate(0, 10, 0);
            }
            else if (!southSensor)
            {
                transform.root.transform.Rotate(0, 180, 0);
            }
        }


        if (eastSensor)
        {
            if (!northSensor)
            {
                transform.root.transform.Rotate(0, 0, 0);
            }
            else if (!westSensor)
            {
                transform.root.transform.Rotate(0, -10, 0);
            }
            else if (!southSensor)
            {
                transform.root.transform.Rotate(0, 180, 0);
            }
        }

        if (southSensor)
        {
            if (!eastSensor)
            {
                transform.root.transform.Rotate(0, 10, 0);
            }
            else if (!westSensor)
            {
                transform.root.transform.Rotate(0, -10, 0);
            }
        }
    }
示例#8
0
    void Update()
    {
        //Read sensor values
        float leftSensor  = LeftLD.getLinearOutput();
        float rightSensor = RightLD.getLinearOutput();

        //Calculate target motor values
        //A velocidade das rodas é inversamente proporcional ao output dos sensores
        //Sensor da direita influencia roda da esquerda e vice-versa
        Debug.Log(leftSensor);
        m_LeftWheelSpeed  = (1 / leftSensor) * MaxSpeed;
        m_RightWheelSpeed = (1 / rightSensor) * MaxSpeed;


        //Calcular os outputs dos sensores
        bool northSensor = northOD.getOutput();
        bool southSensor = southOD.getOutput();
        bool eastSensor  = eastOD.getOutput();
        bool westSensor  = westOD.getOutput();

        //Conforme os outputs rodar o carro
        if (northSensor)
        {
            if (!eastSensor)
            {
                transform.root.transform.Rotate(0, 10, 0);
            }
            else if (!westSensor)
            {
                transform.root.transform.Rotate(0, -10, 0);
            }
            else if (!southSensor)
            {
                transform.root.transform.Rotate(0, 180, 0);
            }
        }

        if (westSensor)
        {
            if (!northSensor)
            {
                transform.root.transform.Rotate(0, 0, 0);
            }
            else if (!eastSensor)
            {
                transform.root.transform.Rotate(0, 10, 0);
            }
            else if (!southSensor)
            {
                transform.root.transform.Rotate(0, 180, 0);
            }
        }


        if (eastSensor)
        {
            if (!northSensor)
            {
                transform.root.transform.Rotate(0, 0, 0);
            }
            else if (!westSensor)
            {
                transform.root.transform.Rotate(0, -10, 0);
            }
            else if (!southSensor)
            {
                transform.root.transform.Rotate(0, 180, 0);
            }
        }
        if (southSensor)
        {
            if (!eastSensor)
            {
                transform.root.transform.Rotate(0, 10, 0);
            }
            else if (!westSensor)
            {
                transform.root.transform.Rotate(0, -10, 0);
            }
        }
    }