public static void main(String args[]) {
    final Devices robotModel = new Devices();
    final Camera camera = new Camera();
    final GoalStateController goalController = new GoalStateController(robotModel, camera);

    Thread cameraUpdateThread =
        new Thread(
            new Runnable() {
              public void run() {
                while (true) {
                  camera.readNewFrame();
                }
              }
            });

    Thread goalControllerThread =
        new Thread(
            new Runnable() {
              public void run() {
                while (true) {
                  goalController.controlState();
                }
              }
            });

    cameraUpdateThread.start();
    goalControllerThread.start();
    robotModel.allMotorsOff();
    robotModel.setRoller(true);
    robotModel.setSpiral(true);
  }
  private void avoidWalls() {
    currentStateController.stop();
    final AvoidWallStateController avoidWallController = new AvoidWallStateController(robotModel);

    currentStateController = avoidWallController;

    Thread avoidWallThread =
        new Thread(
            new Runnable() {
              public void run() {
                avoidWallController.controlState();
              }
            });

    avoidWallThread.start();
  }
  private void collectGroundBalls() {
    currentStateController.stop();
    final BallCollectionStateController ballCollectionController =
        new BallCollectionStateController(robotModel, camera);

    currentStateController = ballCollectionController;

    Thread ballCollectionThread =
        new Thread(
            new Runnable() {
              public void run() {
                while (!ballCollectionController.isDone()) {
                  ballCollectionController.controlState();
                }
              }
            });

    ballCollectionThread.start();
  }