public static void main(String[] args){
		
		// get ready to connect to slave brick
		CommunicationServer communicationServer = new CommunicationServer();
		// establish connection
		CommunicationController communicationController = new CommunicationController(communicationServer);
		// Instantiate classes of all basic components
		TwoWheeledRobot robot = new TwoWheeledRobot(LEFT_MOTOR, RIGHT_MOTOR, LIGHT_SENSOR_MOTOR, MIDDLE_ULTRASONIC_SENSOR, LEFT_LIGHT_SENSOR, RIGHT_LIGHT_SENSOR, communicationController);
		Odometer odometer = new Odometer(robot);
		USPoller usPoller = new USPoller(robot);
		LightPoller lp1 = new LightPoller(robot, LSensor.LEFT);
		LightPoller lp2 = new LightPoller(robot, LSensor.RIGHT);
		Navigation navigation = new Navigation(robot, odometer, usPoller, lp1, lp2);
		MidLightSensorController midLightSensor = new MidLightSensorController(robot);
		Hider hider = new Hider(odometer, navigation, usPoller, midLightSensor);

		//start to get connection with Bluetooth server provided by TA
		BTReceiver btReceiver = new BTReceiver();
		startCorner = btReceiver.getCorner(); // this gets the start corner for use by the searcher and the localizer
		role = btReceiver.getRole();

		// switch that gets the starting corner and sets it as an int, for use by the 
		switch(startCorner) {
		case BOTTOM_LEFT:
			corner = 1;
			break;
		case TOP_LEFT:
			corner = 2;
			break;
		case TOP_RIGHT:
			corner = 3;
			break;
		case BOTTOM_RIGHT:
			corner = 4;
			break;
		}
		
		// starts either the attacker or defender code based on the bluetooth command passed
		switch(role) {
		case ATTACKER:{
			
			// gets the destination point for the flag
			int dropX = btReceiver.getDx();
			int dropY = btReceiver.getDy();

			// start the LCD display
			startLCDDisplay(odometer, usPoller, communicationController, lp2, lp2);
			
			// localize
			localize(odometer, navigation, usPoller, lp1, lp2, corner);
			
			// search
			Searcher search = new Searcher(odometer, navigation, usPoller, midLightSensor, hider);
			search.findBeacon();
			
			// flaghandler (pickup)
			hider.positionAndGrab();
			
			// navigate to drop off point
			navigation.travelTo(dropX*tileLength, dropY*tileLength, true);
			
			// flaghandler (drop)
			hider.putDownAndGo();
			
			// navigate to end point (corner)
			navigation.travelTo(-15, -15, false);
			
			break;
			}
		// Defender role	
		case DEFENDER:{
			
			// gets the flag point
			int flagX = btReceiver.getFx();
			int flagY = btReceiver.getFy();

			// start the LCD display
			startLCDDisplay(odometer, usPoller, communicationController, lp2, lp2);
			
			// localize
			localize(odometer, navigation, usPoller, lp1, lp2, corner);
			
			// hider
			hider.pickUpDefender(flagX, flagY);
			hider.hide();
			// navigate to end point (corner)
			navigation.travelTo(-15, -15, false);
			break;
			}
		}
		
		
		// once the escape button is pressed, the robot will exit
		while (Button.waitForAnyPress() != Button.ID_ESCAPE);
		System.exit(0);
	}