public void avoidObstacle() {
		
		// set status
		isAvoiding = true;
		
		// initialize variables
		double delta = 0;
		double fwdError = 0;
		long time1=0;
		long time2=0;

		// get reading from top us sensor
		int dist = up[Constants.topUSPollerIndex].getLatestFilteredDataPoint();

		// get actual destination
		double x1 = Constants.robotDest[0];
		double y1 = Constants.robotDest[1];

		// approach obstacle if too far
		if (dist > 20) {

			// slowly approach obstacle
			nav.setSpeeds(Navigation.SLOW, Navigation.SLOW);
			
			// start time keeping for timeout
			time1 = System.currentTimeMillis();

			do {
				
				dist = up[Constants.topUSPollerIndex]
						.getLatestFilteredDataPoint();
				
				time2 = System.currentTimeMillis();
				
				// stop approach if timed out
				if(time2 - time1 > 2000){
					break;
				}
				
			} while (dist > 23);

			// stop approaching obstacle
			nav.stopMotors();
		}

		// turn robot 90 degrees clockwise
		nav.rotateBy(-90, false, Navigation.SLOW);
				
		// turn us sensor towards obstacle
		sensorMotor.rotateTo(-110, false);

		// do bang bang wall follower

		do {
			// follow obstacle
			doBangBang();

			// check for obstacle (e.g. a robot passing in front) at the front
			// at the same time
			if (up[Constants.bottomUSPollerIndex].getLatestFilteredDataPoint() < 20) {

				// stop motors
				nav.stopMotors();

				// wait until robot passes by
				while (up[Constants.bottomUSPollerIndex]
						.getLatestFilteredDataPoint() < 20) {
					LCD.drawString("Waiting for obstacle",0,0);
					LCD.drawString("at front to move",0,1);
				}
				
			}

			// check if in-line with destination point
			// by calculating difference in heading.
			// if so, stop bang bang

			// get destination heading
			double destAng = destAng(x1, y1);
			double robotAng = odo.getAng();

			// calculate difference in heading in two ways
			double delta1 = Math.abs(robotAng - destAng);
			double delta2 = Math.abs(robotAng - destAng + 360);

			// choose smallest difference in heading
			delta = Math.min(delta1, delta2);
			
			// calculate position error between position and destination
			fwdError = calcFwdError(x1, y1);

		} while (delta > 10  && fwdError > 10);
		
		// stop robot
		nav.stopMotors();
		
		// turn sensor back
		sensorMotor.rotateTo(0, false);
		
		// reset status
		isAvoiding = false;
		
		try{
			Thread.sleep(1000);
		}catch(Exception e){}
		
	}