// Method scans input and maps it; if obstacle is in front, left and right,
  // backpedal.  If there is a space adjacent but an obstacle at the front,
  // turns to move around the obstacle using the available space.
  public static void movRow() {
    double nextCell = mapObj.basicProb(); // work out probability
    // output to RConsole through BlueTooth
    // btObj.stringToRCon("Object Probability in next Cell: %2f" + nextCell);

    // mapObj.printMap(columns, numOfRowCells);

    // sonar scan around of the robot
    boolean[] scanResults = new boolean[3];
    scanResults = mapObj.scanAll();
    mapObj.updateMap(scanResults);
    // btObj.stringToRCon("Scan Results: " + scanResults[0] + ", " + scanResults[1] + ", " +
    // scanResults[2]);
    // mapObj.printMap(columns, numOfRowCells);

    if (scanResults[1]) { // if there's an obstacle in front
      // if there's an obstacle to the left & right.  i.e. a dead end
      if (scanResults[0] && scanResults[2]) {
        turnAround(scanResults[2], mapObj, movObj); // move backwards
      } else {
        // call movAround() method to navigate around the obstacle
        movAround(scanResults[1], mapObj, movObj);
      }
    } else {
      movObj.nextCell(mapObj); // move forward a cell
    }
  }
  // Method to move around an obstacle - runs when obstacle is in front
  public static void movAround(boolean r, MapSystem ms, Movement mv) {
    mv.turn(r, ms); // true = right turn; false = left turn
    movRow(); // scan and move forward if necessary
    mv.turn(!r, ms); // invert the boolean to turn the other way

    // move forward twice to pass the obstacle
    movRow();
    ++loop2;
    movRow();
    ++loop2;

    mv.turn(!r, ms); // turn to face original column
    boolean extend = mapObj.scanAhead(); // flag to check object is passed
    while (extend) {
      mv.turn(r, ms); // turn to move along the axis
      movObj.nextCell(mapObj);
      ++loop2;
      mv.turn(!r, ms); // face the original column
      if (!mapObj.scanAhead()) { // if an obstacle is not found anymore
        extend = false; // break the while loop
      } else {
      }
    }
    movRow(); // move into the original column
    mv.turn(r, ms); // face the correct way to continue the patrol
  }