Esempio n. 1
0
    void Update()
    {
        //Read sensor values
        float leftSensor  = LeftBD.GetLinearOutput();
        float rightSensor = RightBD.GetLinearOutput();

        //Calculate target motor values
        m_LeftWheelSpeed  = leftSensor * MaxSpeed;
        m_RightWheelSpeed = rightSensor * MaxSpeed;
    }
Esempio n. 2
0
    void Update()
    {
        //Read sensor values
        //float leftSensor = LeftLD.GetLinearOutput ();
        //float rightSensor = RightLD.GetLinearOutput ();

        //Proximity sensor values
        float leftSensorB  = LeftBD.GetLinearOutput();
        float rightSensorB = RightBD.GetLinearOutput();

        //Calculate target motor values
        //m_LeftWheelSpeed = leftSensor * MaxSpeed;
        //m_RightWheelSpeed = rightSensor * MaxSpeed;
        if (leftSensorB == rightSensorB)
        {
            m_LeftWheelSpeed  = leftSensorB * MaxSpeed;
            m_RightWheelSpeed = rightSensorB * MaxSpeed;
        }
        else
        {
            m_LeftWheelSpeed  = leftSensorB * MaxSpeed * 1.5f;
            m_RightWheelSpeed = rightSensorB * MaxSpeed;
        }
    }
Esempio n. 3
0
    void Update()
    {
        //Read sensor values
        float leftSensor  = LeftLD.GetGaussianOutput();
        float rightSensor = RightLD.GetGaussianOutput();

        // strength
        if (leftSensor < limiarMinimo)
        {
            leftSensor = limiarMinimo;
        }
        else if (leftSensor > limiarMaximo)
        {
            leftSensor = limiarMaximo;
        }

        if (rightSensor < limiarMinimo)
        {
            rightSensor = limiarMinimo;
        }
        else if (rightSensor > limiarMaximo)
        {
            rightSensor = limiarMaximo;
        }


        // read sensor values - blocks
        float leftSensorBlock  = LeftBD.GetLinearOutput();
        float rightSensorBlock = RightBD.GetLinearOutput();

        if (leftSensorBlock < limiarMinimo)
        {
            leftSensorBlock = limiarMinimo;
        }
        else if (leftSensorBlock > limiarMaximo)
        {
            leftSensorBlock = limiarMaximo;
        }

        if (rightSensorBlock < limiarMinimo)
        {
            rightSensorBlock = limiarMinimo;
        }
        else if (rightSensorBlock > limiarMaximo)
        {
            rightSensorBlock = limiarMaximo;
        }


        //Calculate target motor values
        m_LeftWheelSpeed  = ((leftSensor + leftSensorBlock) * MaxSpeed);
        m_RightWheelSpeed = ((rightSensor + rightSensorBlock) * MaxSpeed);

        // output
        if (m_LeftWheelSpeed < limiteInferior)
        {
            m_LeftWheelSpeed = limiteInferior;
        }
        else if (m_LeftWheelSpeed > limiteSuperior)
        {
            m_LeftWheelSpeed = limiteSuperior;
        }

        if (m_RightWheelSpeed < limiteInferior)
        {
            m_RightWheelSpeed = limiteInferior;
        }
        else if (m_RightWheelSpeed > limiteSuperior)
        {
            m_RightWheelSpeed = limiteSuperior;
        }
    }