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; }
// 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 }
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; }
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; }
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; }
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 }
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); } } }
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); } } }