Exemple #1
0
  @Override
  public void draw() {
    // When a frame becomes available
    if (HighGui.queryFrame(capture, im)) {
      background(70);

      // Draw it
      image(PUtils.getPImage(im), 0, 0);

      ThresholdType type = ThresholdType.CV_THRESH_BINARY;
      if (r.value() != -1) type = ThresholdType.values()[(int) r.value() - 1];
      ImgProc.threshold(im, im_thresh, thresh_slider.value(), 255, type);
      image(PUtils.getPImage(im_thresh), w, 0);
    }
  }
Exemple #2
0
  public void mouseDragged() {
    if (paused) {
      ArrayList objects = timeline.getStatefulObjects();
      for (int i = 0; i < objects.size(); i++) {
        CelestialObject obj = (CelestialObject) objects.get(i);
        if (obj.isMouseOver()) {
          dragging = true;
          PVector pos = obj.getPosition();
          pos.x = mouseX;
          pos.y = mouseY;

          timeline.reset();
          timeline.setCurrentState(objects);
          sliderTimeline.setValue(0);
          break;
        }
      }
    }
  }
Exemple #3
0
  public void setup() {
    size(1024, 768);
    background(0);
    frameRate(30);
    smooth();

    drawVectors = false;

    paused = true;

    timeline = new Timeline();

    sim = new GravitySimulation();

    sun = new Star(5000, 25, new PVector(300, 500), new PVector(0, 0), 0, "sun");
    planet = new Planet(10, 10, new PVector(500, 500), new PVector(0, 40), "planet");
    planet2 = new Planet(50, 10, new PVector(150, 500), new PVector(0, -40), "planet2");

    timeline.registerStatefulObject(sun);
    timeline.registerStatefulObject(planet);
    timeline.registerStatefulObject(planet2);

    controlP5 = new ControlP5(this);

    btnRewind = controlP5.addButton("btnRewind_OnClick", 0, 800, 20, 50, 20);
    btnRewind.setLabel("Rewind");

    btnPlayPause = controlP5.addButton("btnPlayPause_OnClick", 0, 860, 20, 50, 20);
    btnPlayPause.setLabel("Play");

    btnFastForward = controlP5.addButton("btnFastForward_OnClick", 0, 920, 20, 80, 20);
    btnFastForward.setLabel("Fast Forward");

    sliderTimeline = controlP5.addSlider("sliderTimeline_OnClick", 0, 10000, 0, 20, 720, 900, 10);
    sliderTimeline.setLabel("Timeline");
  }
  public void draw() {
    background(0);
    // Strings composition
    textFont(createFont("Arial bold", 24));
    fill(c_red);
    stroke(255);
    text("OpenWheels GUI V1.0", 20, 30);
    textSize(16);
    // textAlign(CENTER);
    fill(c_azure);
    text("Acc_RAW:  " + Acc_RAW, 150, 65);
    AccSlider.setValue(Acc_RAW);
    text("Gyro_RAW: " + Gyro_RAW, 150, 90);
    GyroSlider.setValue(Gyro_RAW);
    text("Acc_Angle:  " + Acc_Angle + "\u00b0", 150, 115);
    text("Gyro_Rate: " + Gyro_Rate + "\u00b0/sec", 150, 140);
    text("Drive: " + Drive, 150, 165);
    text("Steer: " + Steer, 150, 190);
    text("BatLevel: " + nf(BatLevel, 1, 1) + "V", 150, 215);
    text("Status: " + statusFlag, 150, 240);
    graphGauge();
    graphGrid();

    // call the function that plot the angular of acc, with few screen settings
    graphRoll(PApplet.parseFloat(Acc_Angle), VideoBuffer2, c_red); // xPos, YPos, YSpan
    // call the function that plot the estimate angular, with few screen settings
    graphRoll(Angle, VideoBuffer1, c_yellow); // xPos, YPos, YSpan

    // call arduino for data every timePolling [msec]
    int timePolling = 50; // 50msec=20Hz
    time1 = millis();
    if (init_com == 1) {
      while (serial.available() > 0) processSerialData();
      if ((time1 - time2) > timePolling) {
        if (requestPID == true) {
          serial.write('E');
          requestPID = false;
        } else if (writePID == true) {
          int P = PApplet.parseInt(conf_KP.value());
          int I = PApplet.parseInt(conf_KI.value());
          int D = PApplet.parseInt(conf_KD.value());
          char data[] = {0, 0, 0, 0, 0};
          data[0] = 'W';
          data[1] = PApplet.parseChar(P);
          data[2] = PApplet.parseChar(I);
          data[3] = PApplet.parseChar(D);
          data[4] = ' ';
          String str = new String(data);
          serial.write(str);
          println(str);
          // println(" P=" + P + " I=" + I + " D=" + D);
          writePID = false;
        }
        // else if (RUN==true ) {serial.write('A');}
        else {
          serial.write('A');
        }
        time2 = time1;
      }
    }
  }