public void travelTo(double x1, double y1, int speed) {

		// instantiate variables
		double x0, y0; // current position
		double theta1; // new heading
		double forwardError; // distance from destination coordinates
		double[] displacementVector = new double[2]; // vector connecting actual
														// position to
														// destination
														// coordinates
		// set isNavigating to true
		setIsNavigating(true);

		// set destinationReached = false
		setDestinationReached(false);

		// stop motors
		setSpeeds(0, 0);

		while (!destinationReached && !ObjectDetection.objectDetected) {

			// set isNavigating to true
			setIsNavigating(true);

			// get robot's current position
			x0 = odometer.getX();
			y0 = odometer.getY();

			// calculate new heading (ie. towards destination point)
			theta1 = Math.atan((y1 - y0) / (x1 - x0)) * 180 / Math.PI;

			// adjust value of theta1 according to deltaX and deltaY
			if ((x1 - x0) < 0 && (y1 - y0) > 0) { // if heading should be in 2nd
													// quadrant
				theta1 = theta1 + 180;
			}
			if ((x1 - x0) < 0 && (y1 - y0) < 0) { // if heading should be in 3rd
													// quadrant
				theta1 = theta1 + 180;
			}
			if ((x1 - x0) > 0 && (y1 - y0) < 0) { // if heading should be in 4th
													// quadrant
				theta1 = theta1 + 360;
			}

			turnTo(theta1, speed);

			// // Forward Error Calculation

			// get update robot's current position and heading
			x0 = odometer.getX();
			y0 = odometer.getY();

			// calculation of displacement vector
			displacementVector[0] = x1 - x0;
			displacementVector[1] = y1 - y0;

			// find magnitude of displacement vector to obtain forward error
			forwardError = Math
					.sqrt((displacementVector[0] * displacementVector[0])
							+ (displacementVector[1] * displacementVector[1]));

			// decide whether destination has been reached or not. If yes, stop
			// motors.
			if (Math.abs(forwardError) <= POSITION_ERR) {
				setDestinationReached(true);
				leftMotor.stop(true);
				rightMotor.stop(true);
			} else {

				setDestinationReached(false);

				// make robot move forward
				leftMotor.forward();
				rightMotor.forward();
				leftMotor.setSpeed(speed);
				rightMotor.setSpeed(speed);

			}

			// set isNavigating to false
			setIsNavigating(false);

		}

	}