コード例 #1
0
ファイル: SensorHandler.java プロジェクト: hey0/PathFinder
  public SensorHandler() {
    distanceSensor = new EV3UltrasonicSensor(SensorPort.S1);
    colorSensor = new EV3ColorSensor(SensorPort.S4);

    distanceProvider = distanceSensor.getDistanceMode();
    colorProvider = colorSensor.getRGBMode();
  }
コード例 #2
0
  private void elevatorCollision() {
    LCD.clear();
    LCD.drawString("Collision: " + collision, 0, 4);
    Delay.msDelay(3000);
    float[] dist = new float[sonicSensor.getDistanceMode().sampleSize()];
    sonicSensor.getDistanceMode().fetchSample(dist, 0);

    if ((dist[0] - DISTANCE_TO_WALL) > 0.005) {
      drive.turnRight(5, false);
    } else {
      drive.turnLeft(5, false);
    }
    if (collision == "Wall") {
      drive.stop();
    } else if (collision == "Left Wall") {
      drive.turnRight(5, false);
    } else if (collision == "Right Wall") {
      drive.moveDistance(drive.maxSpeed(), -2);
      drive.turnLeft(20, false);
    }
  }