private void rotate(String direction) throws IOException {
   if (!direction.equals("RIGHT") && !direction.equals("LEFT")) {
     throw new IllegalArgumentException("Invalid Direction " + direction);
   }
   mobileRobot.sendCommand("P1.ROTATE" + direction + " 90");
   result = input.readLine();
 }
  private void scan(String device) throws IOException {

    switch (device.toUpperCase()) {
      case "SONAR":
        device = "S";
        break;
      case "LASER":
        device = "L";
        break;
      default:
        throw new IllegalArgumentException("Invalid device " + device);
    }

    mobileRobot.sendCommand(device + "1.SCAN");
    try {
      result = input.readLine();
    } catch (InterruptedIOException e) {
      result = input.readLine();
    }
    parseMeasure(result, measures);

    if (device.equals("S")) {
      occupancyMap.drawSonarScan(position, measures);
    } else if (device.equals("L")) {
      occupancyMap.drawLaserScan(position, measures);
    }
  }
 private void currentPos() throws IOException {
   mobileRobot.sendCommand("R1.GETPOS");
   result = input.readLine();
   parsePosition(result, position);
 }
 private void moveForward(int steps) throws IOException {
   mobileRobot.sendCommand("P1.MOVEFW " + steps * occupancyMap.getCellDimension());
   result = input.readLine();
 }