Пример #1
0
  /**
   * Reads a single sensorvalue. Called by readSensorGroup
   *
   * @param x read at this x-position
   * @param y read at this y-position
   * @param z read at this z-position
   * @return SensorValue The read SensorValue
   */
  public SensorValue readSingleSensor(float x, float y, float z, double angle) {

    // Send Position to robot
    robotGoTo(new Point3Dim(x, y, z), angle);

    SensorValue s = null;
    // Wait for response from robot, time out if no response
    if (!waitForResponse()) {
      return null;
    }

    s = readValueParser();
    System.out.println("Read value: " + s.getValue());
    inData = null; // reset indata after having read it

    return s;
  }
  /**
   * Draws a sphere
   *
   * @param sensVal the sensorvalue to be represented in the GraphicsPane
   */
  public void drawSphere(SensorValue sensVal) {
    Appearance ap = new Appearance();

    ap.setTransparencyAttributes(
        new TransparencyAttributes(TransparencyAttributes.NICEST, transparency));

    float a = sensVal.getValue();

    ColoringAttributes color =
        new ColoringAttributes(new Color3f(a / 255, 0.0f, (1 - (a / 255))), 0);
    ap.setColoringAttributes(color);

    SensorRepresentation sphere = new SensorRepresentation(0.2f, 100, ap, sensVal);
    sensorRepList.add(sphere);

    TransformGroup transformGrp = new TransformGroup();
    Transform3D transform = new Transform3D();

    transform.setTranslation(new Vector3f(sensVal.getX(), sensVal.getY(), sensVal.getZ()));
    transformGrp.setTransform(transform);

    transformGrp.addChild(sphere);
    this.addChild(transformGrp);
  }