public void checkIfSharpCorner() {
   leftMotor.stop();
   rightMotor.stop();
   isSharpCorner = false;
   int performedRotation = 0;
   DifferentialPilot pilot = new DifferentialPilot(2, 10, leftMotor, rightMotor);
   if (getRealTimeValue() >= 0.1) {
     pilot.rotate(-4);
     isSharpCorner = true;
     tellLineBehaviorIsSharpCorner();
   } else {
     for (int i = 0; i <= 40; i++) {
       pilot.rotate(1);
       performedRotation += 1;
       if (getRealTimeValue() >= 0.1) {
         isSharpCorner = true;
         tellLineBehaviorIsSharpCorner();
         break;
       }
       if (Button.readButtons() != 0) {
         this.interrupt();
       }
     }
   }
   if (!isSharpCorner) {
     align(pilot, performedRotation);
     line.setIsNoSharpCorner();
   }
 }
  public ManageNxtSteering(DataExchange DE) {
    // initialize variables
    DEObj = DE;

    centreMotor = Motor.B;
    centreMotor.resetTachoCount();
    curPos = centreMotor.getTachoCount();
    centreMotor.setSpeed(MIN_STEER_SPD);
    // centreMotor.setAcceleration(10000);
    centreMotor.flt();

    oldDyn = 0;
    newCmd = DataExchange.NULL_CMD;
    isNxtStop = isNxtCalib = false;
  };
 @Override
 public void waitComplete() throws RemoteException {
   motor.waitComplete();
 }
 @Override
 public void flt(boolean immediateReturn) throws RemoteException {
   motor.flt(immediateReturn);
 }
 @Override
 public RegulatedMotorListener removeListener() throws RemoteException {
   return motor.removeListener();
 }
 @Override
 public int getSpeed() throws RemoteException {
   return motor.getSpeed();
 }
 @Override
 public int getLimitAngle() throws RemoteException {
   return motor.getLimitAngle();
 }
 @Override
 public void rotateTo(int limitAngle) throws RemoteException {
   motor.rotateTo(limitAngle);
 }
 @Override
 public void backward() throws RemoteException {
   motor.backward();
 }
 @Override
 public void forward() throws RemoteException {
   motor.forward();
 }
 @Override
 public void close() throws RemoteException {
   motor.close();
 }
 @Override
 public void setAcceleration(int acceleration) throws RemoteException {
   motor.setAcceleration(acceleration);
 }
 @Override
 public void setStallThreshold(int error, int time) throws RemoteException {
   motor.setStallThreshold(error, time);
 }
 @Override
 public boolean isStalled() throws RemoteException {
   return motor.isStalled();
 }
  public void run() {

    // infinite task
    while (true) {
      // retrieve decoded opcode info
      synchronized (this) {
        newDyn = DEObj.getNxtDyn();
        newCmd = DEObj.getNxtCmd();
        newPos = DEObj.getNxtPos();
        curPos = centreMotor.getTachoCount();
        DEObj.setCurSteerPos(curPos);
      }
      ;

      // steer to newPos, if conditions apply
      if ((newCmd != DataExchange.EXIT_CMD) && (newCmd != DataExchange.NULL_CMD)) {
        if (oldDyn != newDyn) {
          oldDyn = newDyn;

          switch (newCmd) {
            case DataExchange.STOP_CMD:
              isNxtStop = true;
              centreMotor.stop();
              break;
            case DataExchange.CAL_CMD:
              centreMotor.rotate(getDeltaPos(newPos, curPos));
              LCD.clear(6);
              LCD.drawString("CMD:: CALIBRATE", 0, 6);
              break;
            case DataExchange.START_CMD:
              isNxtStop = false;
              if (isNxtCalib) {
                // calibration is done, the current TachoCount
                // position becomes the reference, i.e. "0 deg".
                isNxtCalib = false;
                centreMotor.resetTachoCount();
                curPos = centreMotor.getTachoCount();
              }
              break;
            case DataExchange.RELEASE_CMD:
              // when user releases the mouse drag, the vehicle attempts to recover a straight
              // drive.
              // It simulates what happens naturally in a real car when the driver gets his hands
              // off
              // the steering upon exiting from a curve.
              centreMotor.rotateTo(0);
              break;
            case DataExchange.FRWD_CMD:
            case DataExchange.BKWD_CMD:
              if (!isNxtStop) {
                centreMotor.rotate(getDeltaPos(newPos, curPos));
              }
              break;
            default:
              break;
          }
          ; // switch case
        } // if (old != new)
        else {
          centreMotor.flt();
        }

        try {
          // thread going to sleep
          ManageNxtSteering.sleep(50);
        } catch (InterruptedException e) {
          e.printStackTrace();
          LCD.drawString("EX-6:", 0, 5);
          LCD.refresh();
        }

      } // if (new != EXIT_CMD)
      else {
        if (newCmd == DataExchange.EXIT_CMD) {
          centreMotor.stop(); /* stop motor */
          break; /* exit while loop */
        }
      }
    } // while loop

    DEObj.setNXTdone(true);
  }
 @Override
 public void rotate(int angle, boolean immediateReturn) throws RemoteException {
   motor.rotate(angle, immediateReturn);
 }
 @Override
 public void rotate(int angle) throws RemoteException {
   motor.rotate(angle);
 }
 @Override
 public void resetTachoCount() throws RemoteException {
   motor.resetTachoCount();
 }
 @Override
 public void rotateTo(int limitAngle, boolean immediateReturn) throws RemoteException {
   motor.rotateTo(limitAngle, immediateReturn);
 }
 @Override
 public int getTachoCount() throws RemoteException {
   return motor.getTachoCount();
 }
 @Override
 public void setSpeed(int speed) throws RemoteException {
   motor.setSpeed(speed);
 }
 @Override
 public boolean isMoving() throws RemoteException {
   return motor.isMoving();
 }
 @Override
 public float getMaxSpeed() throws RemoteException {
   return motor.getMaxSpeed();
 }
 @Override
 public void addListener(RegulatedMotorListener listener) throws RemoteException {
   motor.addListener(listener);
 }