Package ch.bfh.ti.kybernetik.engine.model

Examples of ch.bfh.ti.kybernetik.engine.model.Roboter


   *
   * @param roboterKI
   * @return a new {@link RoboterController}
   */
  public static RoboterController createRoboterController(RoboterKI roboterKI) {
    Roboter roboter = RoboterFactory.createRoboter();
    DefaultRoboterControllerImpl roboterController = new DefaultRoboterControllerImpl(roboter, roboterKI,
        new DefaultRoboterConstructionImpl(roboter));

    return roboterController;
  }
View Full Code Here


   * @return a new {@link RoboterController} with a random positioned
   *         {@link Roboter} Model
   */
  public static RoboterController createRandomRoboterController(int maxX, int maxY) {
    RoboterKI roboterKI = RobKIFactr.getRoboterKI(DEFAULT_WESEN);
    Roboter roboter = RoboterFactory.createRandomRoboter(maxX, maxY);
    DefaultRoboterControllerImpl roboterController = new DefaultRoboterControllerImpl(roboter, roboterKI,
        new DefaultRoboterConstructionImpl(roboter));

    return roboterController;
  }
View Full Code Here

          @Override
          public void performAction(RoboterController roboterController) {
            // System.out.println("Simulator: Iterate RoboterController");
            double leftSensorIntensity = 0;
            double rightSensorIntensity = 0;
            Roboter roboter = roboterController.getRoboter();
            RoboterConstruction roboterConstruction = roboterController.getRoboterConstruction();
            for (LightBulbController lightBulbController : lightBulbControllers) {

              // Left Light Sensor
              Point2d leftLightSensorPoint = roboterConstruction.getRoboterElementPoint(roboter.getLeftLightSensor());
              Vector2d leftLightSensorVector = roboterConstruction.getRoboterElementAngleVector(roboter.getLeftLightSensor());

              leftSensorIntensity = leftSensorIntensity
                  + lightBulbController.calculateIntensity(leftLightSensorPoint, roboter.getLeftLightSensor(),
                      leftLightSensorVector);

              // Right Light Sensor
              Point2d rightLightSensorPoint = roboterConstruction.getRoboterElementPoint(roboter.getRightLightSensor());
              Vector2d rightLightSensorVector = roboterConstruction.getRoboterElementAngleVector(roboter
                  .getRightLightSensor());

              rightSensorIntensity = rightSensorIntensity
                  + lightBulbController.calculateIntensity(rightLightSensorPoint, roboter.getRightLightSensor(),
                      rightLightSensorVector);

            }
            // Changed Left Sensor Intensity
            if (leftSensorIntensity != roboter.getLeftLightSensor().getSensorIntensity()) {
              notifyObservers(new LightSensorModelObserverCommand(roboter, LightSensorCommandState.SENSOR_INTENSITY_CHANGED,
                  roboter.getLeftLightSensor()));
              logger.debug("Changed Left Light Sensor Intensity to {}: " + leftSensorIntensity);
              roboter.getLeftLightSensor().setSensorIntensity(leftSensorIntensity);
            }
            if (leftSensorIntensity == 0) {
              notifyObservers(new LightSensorModelObserverCommand(roboter, LightSensorCommandState.SENSOR_INTENSITY_REMAINS,
                  roboter.getLeftLightSensor()));
            }
            // Changed Right Sensor Intensity
            if (rightSensorIntensity != roboter.getRightLightSensor().getSensorIntensity()) {
              notifyObservers(new LightSensorModelObserverCommand(roboter, LightSensorCommandState.SENSOR_INTENSITY_CHANGED,
                  roboter.getRightLightSensor()));
              logger.debug("Changed Right Light Sensor Intensity to {}: " + rightSensorIntensity);
              roboter.getRightLightSensor().setSensorIntensity(rightSensorIntensity);
            }
            if (rightSensorIntensity == 0) {
              notifyObservers(new LightSensorModelObserverCommand(roboter, LightSensorCommandState.SENSOR_INTENSITY_REMAINS,
                  roboter.getRightLightSensor()));
            }
            RoboterMove rm = roboterController.calculateNewRoboterPosition(leftSensorIntensity, rightSensorIntensity);

            calculateOutOfWindowAreaPosition(roboterController, rm);
View Full Code Here

    return currentRoboterMoveState;
  }

  @Override
  public List<RoboterMove> calculateNextEstimatedRoboterMoves(int count) {
    Roboter iterationRoboter = new Roboter(this.roboter);
    List<RoboterMove> estimatedRoboterMoveStates = new LinkedList<RoboterMove>();
    for (int i = 0; i < count; i++) {
      DefaultRoboterConstructionImpl constructionImpl = new DefaultRoboterConstructionImpl(iterationRoboter);
      RoboterMove roboterMoveState = calculateNextRoboterMove(constructionImpl);
      estimatedRoboterMoveStates.add(roboterMoveState);
      // Set new roboter data
      iterationRoboter.setX(roboterMoveState.getNewRoboterPoint().getX());
      iterationRoboter.setY(roboterMoveState.getNewRoboterPoint().getY());
      iterationRoboter.setDirection(roboterMoveState.getNewDirectionVector());
    }
    return estimatedRoboterMoveStates;
  }
View Full Code Here

    gc.setMaximumLogicUpdateInterval(1 / RENDER_UPDATE_RATE);
    gc.setMaximumLogicUpdateInterval(1 / RENDER_UPDATE_RATE);

    Iterator<Roboter> it = simulator.getRoboterList().iterator();
    while (it.hasNext()) {
      Roboter roboter = it.next();
      RoboterComponent rc = new RoboterComponent(roboter, simulator.getRoboterConstructionForRoboter(roboter));
      this.roboterComponents.add(rc);
    }

    Iterator<LightBulb> it2 = simulator.getLightBulbList().iterator();
View Full Code Here

      }
    }
  }

  private void redirectRobotToPoint(RoboterComponent rc, Point2d mouseClickedPointPosition) {
    Roboter roboter = rc.getModelObject();
    Vector2d vec = new Vector2d(mouseClickedPointPosition.getX() - roboter.getX(), mouseClickedPointPosition.getY() - roboter.getY());
    vec.normalize();
    roboter.setDirection(vec);
  }
View Full Code Here

  private void redirectRobotsToPoint(Point2d mouseClickedPointPosition) {
    Iterator<RoboterComponent> it = this.roboterComponents.iterator();
    while (it.hasNext()) {
      RoboterComponent rc = it.next();
      Roboter roboter = rc.getModelObject();
      Vector2d vec = new Vector2d(mouseClickedPointPosition.getX() - roboter.getX(), mouseClickedPointPosition.getY()
          - roboter.getY());
      vec.normalize();
      roboter.setDirection(vec);
    }
  }
View Full Code Here

TOP

Related Classes of ch.bfh.ti.kybernetik.engine.model.Roboter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.