Exemplo n.º 1
0
  /*
  	Perform Simulation
  */
  public void simulate(float dt) {
    // Accelerate angular speed
    float requiredSpeed = targetAngularSpeed - angularSpeed;
    float angularAccel = requiredSpeed / dt;
    angularAccel = PApplet.constrain(angularAccel, -maxAngularAccel, maxAngularAccel);

    // Limit Angular speed
    angularSpeed += angularAccel * dt;
    angularSpeed = PApplet.constrain(angularSpeed, -maxAngularSpeed, maxAngularSpeed);

    // Orientation Simulation
    orientation += angularSpeed * dt;

    // Position simulation
    PVector worldRequiredSpeed = targetSpeed.get();
    worldRequiredSpeed.rotate(orientation);
    worldRequiredSpeed.sub(speed);

    // PVector worldRequiredSpeed = worldTargetSpeed.get();
    float dSpeed = worldRequiredSpeed.mag();
    float dAcell = dSpeed / dt;
    float dForce = Math.min(dAcell * getMass(), motorForce);

    worldRequiredSpeed.normalize();
    worldRequiredSpeed.mult(dForce);
    force.add(worldRequiredSpeed);

    super.simulate(dt);
  }
Exemplo n.º 2
0
  // \u30c7\u30fc\u30bf\u3092\u30ea\u30b9\u30c8\u306b\u683c\u7d0d\u3057\u3066\u53d6\u5f97
  public ArrayList<dotObj> getDataList(String[] lines, int targetChannel) {

    ArrayList<dotObj> retList = new ArrayList<dotObj>();

    // \u5168\u30c7\u30fc\u30bf\u3092\u53c2\u7167\u3057\u3066\u5fc5\u8981\u306a\u60c5\u5831\u3092\u53d6\u308a\u51fa\u3059
    int index = 0;
    for (int i = 0; i < lines.length; i++) {
      // ','\u3067\u533a\u5207\u308a\u914d\u5217\u306b\u683c\u7d0d
      String data[] = split(lines[i], ',');
      // channel, date, valuse
      // \u306e\u9806\u3067\u30c7\u30fc\u30bf\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b
      int channel = PApplet.parseInt(data[0]); // \u30c1\u30e3\u30f3\u30cd\u30eb
      String timeStamp = data[1]; // \u65e5\u4ed8
      float val = PApplet.parseFloat(data[2]); // \u5024

      if (channel == targetChannel) {
        // println("channel: " + channel);
        // println("date   : " + timeStamp);
        // println("val    : " + val);

        // \u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30bb\u30c3\u30c8\u3057\u3001\u914d\u5217\u306b\u683c\u7d0d
        float m = map(val, -0.5f, 0.5f, height / 4, height);
        dotObj theObj = new dotObj(index * width / 70, m, 0);
        theObj.channel = channel;
        theObj.timeStamp = timeStamp;
        theObj.val = val;
        retList.add(theObj);

        index++;
      }
    }

    return retList;
  }
 // A function to rotate a vector
 public void rotateVector(PVector v, float theta) {
   float m = v.mag();
   float a = v.heading2D();
   a += theta;
   v.x = m * PApplet.cos(a);
   v.y = m * PApplet.sin(a);
 }
Exemplo n.º 4
0
  public void draw(PApplet canvas, float scale) {
    PVector orient = PVector.fromAngle(orientation);
    orient.mult(scale * getRadius());
    float x = (float) position.x * scale;
    float y = (float) position.y * scale;
    float diameter = getRadius() * 2 * scale;

    canvas.fill(teamColor);
    canvas.stroke(0);
    canvas.ellipse(x, y, diameter, diameter);
    canvas.line(x, y, x + (float) orient.x, y + (float) orient.y);

    // Delegate Decoration to Robot
    float heading = orient.heading();
    float drawScale = 100f / scale * getRadius();

    canvas.translate(x, y);
    canvas.rotate(heading);
    canvas.scale(drawScale);
    // TODO: How to resolve scale, so that teams don't have to mind it also...
    decorateRobot(canvas);
    canvas.scale(1f / drawScale);
    canvas.rotate(-heading);
    canvas.translate(-x, -y);
  }
Exemplo n.º 5
0
 public static void main(String[] passedArgs) {
   String[] appletArgs = new String[] {"fdg"};
   if (passedArgs != null) {
     PApplet.main(concat(appletArgs, passedArgs));
   } else {
     PApplet.main(appletArgs);
   }
 }
    public void avoid(ArrayList obstacles) {

      // Make a vector that will be the position of the object
      // relative to the Boid rotated in the direction of boid's velocity
      PVector closestRotated = new PVector(sight + 1, sight + 1);
      float closestDistance = 99999;
      Obstacle avoid = null;

      // Let's look at each obstacle
      for (int i = 0; i < obstacles.size(); i++) {
        Obstacle o = (Obstacle) obstacles.get(i);

        float d = PVector.dist(loc, o.loc);
        PVector dir = vel.get();
        dir.normalize();
        PVector diff = PVector.sub(o.loc, loc);

        // Now we use the dot product to rotate the vector that points from boid to obstacle
        // Velocity is the new x-axis
        PVector rotated = new PVector(diff.dot(dir), diff.dot(getNormal(dir)));

        // Is the obstacle in our path?
        if (PApplet.abs(rotated.y) < (o.radius + r)) {
          // Is it the closest obstacle?
          if ((rotated.x > 0) && (rotated.x < closestRotated.x)) {
            closestRotated = rotated;
            avoid = o;
          }
        }
      }

      // Can we actually see the closest one?
      if (PApplet.abs(closestRotated.x) < sight) {

        // The desired vector should point away from the obstacle
        // The closer to the obstacle, the more it should steer
        PVector desired =
            new PVector(closestRotated.x, -closestRotated.y * sight / closestRotated.x);
        desired.normalize();
        desired.mult(closestDistance);
        desired.limit(maxspeed);
        // Rotate back to the regular coordinate system
        rotateVector(desired, vel.heading2D());

        // Draw some debugging stuff
        if (debug) {
          stroke(0);
          line(loc.x, loc.y, loc.x + desired.x * 10, loc.y + desired.y * 10);
          avoid.highlight(true);
        }

        // Apply Reynolds steering rules
        desired.sub(vel);
        desired.limit(maxforce);
        acc.add(desired);
      }
    }
Exemplo n.º 7
0
  public void processSerialData() {
    byte[] inBuf = new byte[20];
    switch (serial.read()) {
      case 'A':
        // wait for all data arrived
        while (serial.available() < 16) {}
        // read all data
        serial.readBytes(inBuf);
        Acc_RAW = (inBuf[1] << 8) + (inBuf[0] & 0xFF);
        Gyro_RAW = (inBuf[3] << 8) + (inBuf[2] & 0xFF);
        // int intbit = 0;
        // intbit = (inBuf[7] << 24) | ((inBuf[6] & 0xFF) << 16) | ((inBuf[5] & 0xFF) << 8) |
        // (inBuf[4] & 0xFF);
        // Angle = Float.intBitsToFloat(intbit);
        int AngleInt = (inBuf[5] << 8) + (inBuf[4] & 0xFF);
        Angle = PApplet.parseFloat(AngleInt) / 10;
        Acc_Angle = (inBuf[7] << 8) + (inBuf[6] & 0xFF);
        Gyro_Rate = (inBuf[9] << 8) + (inBuf[8] & 0xff);
        Drive = (inBuf[11] << 8) + (inBuf[10] & 0xFF);
        statusFlag = (inBuf[13] << 8) + (inBuf[12] & 0xFF);
        int BatLevelInt = (inBuf[15] << 8) + (inBuf[14] & 0xFF);
        Steer = (inBuf[17] << 8) + (inBuf[16] & 0xFF);
        BatLevel = PApplet.parseFloat(BatLevelInt) / 10;
        println(
            "Acc="
                + Acc_RAW
                + "  Gyro="
                + Gyro_RAW
                + "  Angle="
                + Angle
                + "  Acc_Angle="
                + Acc_Angle
                + "  Gyro_Rate="
                + Gyro_Rate
                + "  Drive="
                + Drive
                + "  Status="
                + statusFlag);
        break;

      case 'E':
        // wait for all data arrived
        while (serial.available() < 6) {}
        // read all data
        serial.readBytes(inBuf);
        int P = (inBuf[1] << 8) + (inBuf[0] & 0xFF);
        int I = (inBuf[3] << 8) + (inBuf[2] & 0xFF);
        int D = (inBuf[5] << 8) + (inBuf[4] & 0xFF);
        conf_KP.setValue(P);
        conf_KI.setValue(I);
        conf_KD.setValue(D);
        println("P=" + P + " I=" + I + " D=" + D);
        break;
    }
    serial.clear();
  }
Exemplo n.º 8
0
 public void InitSerial(float portValue) {
   // initialize the serial port selected in the listBox
   println(
       "initializing serial "
           + PApplet.parseInt(portValue)
           + " in serial.list()"); // for debugging
   // grab the name of the serial port
   String portPos = Serial.list()[PApplet.parseInt(portValue)];
   // initialize the port
   serial = new Serial(this, portPos, 115200);
   // read bytes into a buffer until you get a linefeed (ASCII 10):
   serial.bufferUntil('\n');
   println("done init serial");
   // initialized com port flag
   init_com = 1;
 }
Exemplo n.º 9
0
  // joku randomilla tämän vierestä
  // tylsä bruteforcemenetelmä hajotusfiiliksen tuotoksena
  int[] getadj(PApplet pa, int x, int y, int z, boolean[] visited) {
    // {-x, x, -y, y, -z, z}
    int[][] dirs = {
      {-1, 0, 0},
      {1, 0, 0},
      {0, -1, 0},
      {0, 1, 0},
      {0, 0, -1},
      {0, 0, 1}
    };
    boolean ok = true;
    int[] dir;
    do {
      int i = (int) (pa.random(0, 6));
      dir = dirs[i];

      ok = true;
      if (x == 0 && i == 0) ok = false;
      if (y == 0 && i == 2) ok = false;
      if (z == 0 && i == 4) ok = false;
      if (x == size - 1 && i == 1) ok = false;
      if (y == size - 1 && i == 3) ok = false;
      if (z == size - 1 && i == 5) ok = false;
    } while (!ok || visited[world.at(x + dir[0], y + dir[1], z + dir[2])]);
    return dir;
  }
Exemplo n.º 10
0
  // \u30c7\u30fc\u30bf\u53d6\u5f97
  public void getAllData() {

    // xively\u304b\u3089\u306e\u30c7\u30fc\u30bf\u53d6\u5f97
    String lines[] = getDataFromXively(URL, MY_KEY);

    // \u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u30ea\u30b9\u30c8\u306b\u683c\u7d0d
    dotLists = new ArrayList<ArrayList<dotObj>>();

    // \u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u53d6\u5f97
    int max_channel = 0;
    int min_channel = 9999;
    for (int i = 0; i < lines.length; i++) {
      String data[] = split(lines[i], ',');
      int theChannel = PApplet.parseInt(data[0]);
      if (min_channel > theChannel) {
        min_channel = theChannel;
      }
      if (max_channel < theChannel) {
        max_channel = theChannel;
      }
    }

    // \u5168\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001\u30ea\u30b9\u30c8\u306b\u683c\u7d0d
    for (int channel = min_channel; channel <= max_channel; channel++) {
      ArrayList<dotObj> dotList = getDataList(lines, channel);
      dotLists.add(dotList);
    }
  }
Exemplo n.º 11
0
  public void controlEvent(ControlEvent theEvent) {
    // PulldownMenu is if type ControlGroup.
    // A controlEvent will be triggered from within the ControlGroup.
    // therefore you need to check the originator of the Event with
    // if (theEvent.isGroup())
    // to avoid an error message from controlP5.
    if (theEvent.isGroup()) {
      if (theEvent.group().name() == "ruleChoiceList") {
        //    println(theEvent.group().value()+" from "+theEvent.group());
        selectedRule = PApplet.parseInt(theEvent.group().value());
        // has to be here for the controlp5 library
      }
    } else if (theEvent.isController()) {
      //    println(theEvent.controller().value()+" from "+theEvent.controller());
    }

    //  switch(theEvent.controller().id()) {
    //    case(1):
    //    myColorRect = (int)(theEvent.controller().value());
    //    break;
    //    case(2):
    //    myColorBackground = (int)(theEvent.controller().value());
    //    break;
    //    case(3):
    //    println(theEvent.controller().stringValue());
    //    break;
    //  }

  }
Exemplo n.º 12
0
  public void render(PGraphics g) {
    if (parent != null) rot = PApplet.lerp(rot, parent.rot, 0.25f);

    g.rotate(rot);
    g.textSize(txtSize);
    g.text(txt, 0, 0);
    g.translate(g.textWidth(txt) * kerning, 0);

    for (int i = 0; i < children.size(); i++) children.get(i).render(g);
  }
Exemplo n.º 13
0
  public static ArrayList<BChar> buildString(PApplet app, String str, float wander) {
    ArrayList<BChar> bchars = new ArrayList<BChar>(str.length());

    for (int i = 0, n = str.length(); i < n; i++) {
      bchars.add(new BChar(str.substring(i, i + 1), app.random(-wander, wander)));
      if (i > 0) bchars.get(i - 1).addChild(bchars.get(i));
    }

    return bchars;
  }
    public void render() {
      // Draw a triangle rotated in the direction of velocity
      float theta = vel.heading2D() + PApplet.radians(90);
      fill(100);
      stroke(0);
      pushMatrix();
      translate(loc.x, loc.y);
      rotate(theta);
      beginShape(PConstants.TRIANGLES);
      vertex(0, -r * 2);
      vertex(-r, r * 2);
      vertex(r, r * 2);
      endShape();

      if (debug) {
        stroke(50);
        line(0, 0, 0, -sight);
      }
      popMatrix();
    }
 public void draw() {
   lights();
   background(255);
   noStroke();
   fill(200);
   translate(-width / 2, 0);
   t += 0.001f;
   int offset = 10;
   float shapeSize = 5.0f;
   for (int i = 1; i < 10; i++) {
     // ellipse(noise(t+i*offset*0.01)*width, sin(float(frameCount + i*offset)/100)*height/2,
     // shapeSize*i, shapeSize*i);
     float x = noise(t + i * offset * 0.01f) * width;
     float y = sin(PApplet.parseFloat(frameCount + i * offset) / 100) * height / 2;
     pushMatrix();
     translate(x, y);
     sphere(shapeSize * i);
     popMatrix();
   }
 }
Exemplo n.º 16
0
 /**
  * List the fonts known to the PDF renderer. This is like PFont.list(), however not all those
  * fonts are available by default.
  */
 @SuppressWarnings("unchecked")
 public static String[] listFonts() {
   if (fontList == null) {
     HashMap<?, ?> map = getMapper().getAliases();
     //      Set entries = map.entrySet();
     //      fontList = new String[entries.size()];
     fontList = new String[map.size()];
     int count = 0;
     for (Object entry : map.entrySet()) {
       fontList[count++] = (String) ((Map.Entry) entry).getKey();
     }
     //      Iterator it = entries.iterator();
     //      int count = 0;
     //      while (it.hasNext()) {
     //        Map.Entry entry = (Map.Entry) it.next();
     //        //System.out.println(entry.getKey() + "-->" + entry.getValue());
     //        fontList[count++] = (String) entry.getKey();
     //      }
     fontList = PApplet.sort(fontList);
   }
   return fontList;
 }
Exemplo n.º 17
0
 public static void main(String args[]) {
   PApplet.main(new String[] {"xhtml1"});
 }
 public static void main(String args[]) {
   PApplet.main(new String[] {"--bgcolor=#F0F0F0", "SimpleOpenNI_NITE_Hands"});
 }
Exemplo n.º 19
0
 /*static int	SKEL_HEAD
 static int	SKEL_LEFT_ANKLE
 static int	SKEL_LEFT_COLLAR
 static int	SKEL_LEFT_ELBOW
 static int	SKEL_LEFT_FINGERTIP
 static int	SKEL_LEFT_FOOT
 static int	SKEL_LEFT_HAND
 static int	SKEL_LEFT_HIP
 static int	SKEL_LEFT_KNEE
 static int	SKEL_LEFT_SHOULDER
 static int	SKEL_LEFT_WRIST
 static int	SKEL_NECK
 static int	SKEL_RIGHT_ANKLE
 static int	SKEL_RIGHT_COLLAR
 static int	SKEL_RIGHT_ELBOW
 static int	SKEL_RIGHT_FINGERTIP
 static int	SKEL_RIGHT_FOOT
 static int	SKEL_RIGHT_HAND
 static int	SKEL_RIGHT_HIP
 static int	SKEL_RIGHT_KNEE
 static int	SKEL_RIGHT_SHOULDER
 static int	SKEL_RIGHT_WRIST
 static int	SKEL_TORSO
 static int	SKEL_WAIST */
 public static void main(String args[]) {
   PApplet.main(new String[] {"--bgcolor=#FFFFFF", "kinectPong"});
 }
Exemplo n.º 20
0
 public static void main(String args[]) {
   PApplet.main(new String[] {"--bgcolor=#ECE9D8", "fractalTree3"});
 }
 public static void main(String args[]) {
   PApplet.main(new String[] {"Pendulum"});
 }
Exemplo n.º 22
0
 public static void main(String args[]) {
   PApplet.main(new String[] {"--bgcolor=#FFFFFF", "sketch_aug05a"});
 }
Exemplo n.º 23
0
 // Close the sound engine
 public void stop() {
   Sonia.stop();
   super.stop();
 }
Exemplo n.º 24
0
  public boolean launchVirtualMachine(boolean presenting) {
    String[] vmParams = getMachineParams();
    String[] sketchParams = getSketchParams(presenting);
    int port = 8000 + (int) (Math.random() * 1000);
    String portStr = String.valueOf(port);

    // Older (Java 1.5 and earlier) version, go figure
    //    String jdwpArg = "-Xrunjdwp:transport=dt_socket,address=" + portStr +
    // ",server=y,suspend=y";
    //    String debugArg = "-Xdebug";
    // Newer (Java 1.5+) version that uses JVMTI
    String jdwpArg =
        "-agentlib:jdwp=transport=dt_socket,address=" + portStr + ",server=y,suspend=y";

    // Everyone works the same under Java 7 (also on OS X)
    String[] commandArgs = new String[] {Base.getJavaPath(), jdwpArg};

    /*
        String[] commandArgs = null;
        if (!Base.isMacOS()) {
          commandArgs = new String[] {
            Base.getJavaPath(),
            jdwpArg
          };
        } else {
          // Decided to just set this to 1.6 only, because otherwise it's gonna
          // be a shitshow if folks are getting Apple's 1.6 with 32-bit and
          // Oracle's 1.7 when run in 64-bit mode. ("Why does my sketch suck in
          // 64-bit? Why is retina broken?)
          // The --request flag will prompt to install Apple's 1.6 JVM if none is
          // available. We're specifying 1.6 so that we can get support for both
          // 32- and 64-bit, because Oracle won't be releasing Java 1.7 in 32-bit.
          // Helpfully, the --request flag is not present on Mac OS X 10.6
          // (luckily it is also not needed, because 1.6 is installed by default)
          // but it requires an additional workaround to not use that flag,
          // otherwise will see an error about an unsupported option. The flag is
          // available with 10.7 and 10.8, the only other supported versions of
          // OS X at this point, because we require 10.6.8 and higher. That also
          // means we don't need to check for any other OS versions, the user is
          // a douchebag and modifies Info.plist to get around the restriction.
          if (false) {
            if (System.getProperty("os.version").startsWith("10.6")) {
              commandArgs = new String[] {
                "/usr/libexec/java_home",
                "--version", "1.6",
                "--exec", "java",
                "-d" + Base.getNativeBits(),
                jdwpArg
              };
            } else {  // for 10.7, 10.8, etc
              commandArgs = new String[] {
                "/usr/libexec/java_home",
                "--request",  // install on-demand
                "--version", "1.6",
                "--exec", "java",
                "-d" + Base.getNativeBits(),
    //          debugArg,
                jdwpArg
              };
            }
          } else {
            // testing jdk-7u40
            commandArgs = new String[] {
              //"/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java",
              Base.getJavaPath(),
              jdwpArg
            };
          }
        }
        */

    commandArgs = PApplet.concat(commandArgs, vmParams);
    commandArgs = PApplet.concat(commandArgs, sketchParams);
    //  PApplet.println(commandArgs);
    //  commandArg.setValue(commandArgs);
    launchJava(commandArgs);

    AttachingConnector connector = (AttachingConnector) findConnector("com.sun.jdi.SocketAttach");
    // PApplet.println(connector);  // gets the defaults

    Map arguments = connector.defaultArguments();

    //  Connector.Argument addressArg =
    //    (Connector.Argument)arguments.get("address");
    //  addressArg.setValue(addr);
    Connector.Argument portArg = (Connector.Argument) arguments.get("port");
    portArg.setValue(portStr);

    //    Connector.Argument timeoutArg =
    //      (Connector.Argument)arguments.get("timeout");
    //    timeoutArg.setValue("10000");

    // PApplet.println(connector);  // prints the current
    // com.sun.tools.jdi.AbstractLauncher al;
    // com.sun.tools.jdi.RawCommandLineLauncher rcll;

    // System.out.println(PApplet.javaVersion);
    // http://java.sun.com/j2se/1.5.0/docs/guide/jpda/conninv.html#sunlaunch

    try {
      //      boolean available = false;
      //      while (!available) {
      while (true) {
        try {
          vm = connector.attach(arguments);
          //          vm = connector.attach(arguments);
          if (vm != null) {
            //            generateTrace();
            //            available = true;
            return true;
          }
        } catch (IOException e) {
          //          System.out.println("waiting");
          //          e.printStackTrace();
          try {
            Thread.sleep(100);
          } catch (InterruptedException e1) {
            e1.printStackTrace();
          }
        }
      }
      //    } catch (IOException exc) {
      //      throw new Error("Unable to launch target VM: " + exc);
    } catch (IllegalConnectorArgumentsException exc) {
      throw new Error("Internal error: " + exc);
    }
  }
Exemplo n.º 25
0
  private Library(File folder, String groupName) {
    super(folder);
    this.group = groupName;

    libraryFolder = new File(folder, "library");
    examplesFolder = new File(folder, "examples");
    referenceFile = new File(folder, "reference/index.html");

    File exportSettings = new File(libraryFolder, "export.txt");
    StringDict exportTable =
        exportSettings.exists() ? Util.readSettings(exportSettings) : new StringDict();

    exportList = new HashMap<String, String[]>();

    // get the list of files just in the library root
    String[] baseList = libraryFolder.list(standardFilter);
    //    System.out.println("Loading " + name + "...");
    //    PApplet.println(baseList);

    String appletExportStr = exportTable.get("applet");
    if (appletExportStr != null) {
      appletExportList = PApplet.splitTokens(appletExportStr, ", ");
    } else {
      appletExportList = baseList;
    }

    String androidExportStr = exportTable.get("android");
    if (androidExportStr != null) {
      androidExportList = PApplet.splitTokens(androidExportStr, ", ");
    } else {
      androidExportList = baseList;
    }

    // for the host platform, need to figure out what's available
    File nativeLibraryFolder = libraryFolder;
    String hostPlatform = Platform.getName();
    //    System.out.println("1 native lib folder now " + nativeLibraryFolder);
    // see if there's a 'windows', 'macosx', or 'linux' folder
    File hostLibrary = new File(libraryFolder, hostPlatform);
    if (hostLibrary.exists()) {
      nativeLibraryFolder = hostLibrary;
    }
    //    System.out.println("2 native lib folder now " + nativeLibraryFolder);
    // check for bit-specific version, e.g. on windows, check if there
    // is a window32 or windows64 folder (on windows)
    hostLibrary = new File(libraryFolder, hostPlatform + Platform.getNativeBits());
    if (hostLibrary.exists()) {
      nativeLibraryFolder = hostLibrary;
    }
    //    System.out.println("3 native lib folder now " + nativeLibraryFolder);

    if (hostPlatform.equals("linux") && System.getProperty("os.arch").equals("arm")) {
      hostLibrary = new File(libraryFolder, "linux-armv6hf");
      if (hostLibrary.exists()) {
        nativeLibraryFolder = hostLibrary;
      }
    }

    // save that folder for later use
    nativeLibraryPath = nativeLibraryFolder.getAbsolutePath();

    // for each individual platform that this library supports, figure out what's around
    for (int i = 1; i < platformNames.length; i++) {
      String platformName = platformNames[i];
      String platformName32 = platformName + "32";
      String platformName64 = platformName + "64";
      String platformNameArmv6hh = platformName + "-armv6hf";

      // First check for things like 'application.macosx=' or 'application.windows32' in the
      // export.txt file.
      // These will override anything in the platform-specific subfolders.
      String platformAll = exportTable.get("application." + platformName);
      String[] platformList = platformAll == null ? null : PApplet.splitTokens(platformAll, ", ");
      String platform32 = exportTable.get("application." + platformName + "32");
      String[] platformList32 = platform32 == null ? null : PApplet.splitTokens(platform32, ", ");
      String platform64 = exportTable.get("application." + platformName + "64");
      String[] platformList64 = platform64 == null ? null : PApplet.splitTokens(platform64, ", ");
      String platformArmv6hf = exportTable.get("application." + platformName + "-armv6hf");
      String[] platformListArmv6hf =
          platformArmv6hf == null ? null : PApplet.splitTokens(platformArmv6hf, ", ");

      // If nothing specified in the export.txt entries, look for the platform-specific folders.
      if (platformAll == null) {
        platformList = listPlatformEntries(libraryFolder, platformName, baseList);
      }
      if (platform32 == null) {
        platformList32 = listPlatformEntries(libraryFolder, platformName32, baseList);
      }
      if (platform64 == null) {
        platformList64 = listPlatformEntries(libraryFolder, platformName64, baseList);
      }
      if (platformListArmv6hf == null) {
        platformListArmv6hf = listPlatformEntries(libraryFolder, platformNameArmv6hh, baseList);
      }

      if (platformList32 != null || platformList64 != null || platformListArmv6hf != null) {
        multipleArch[i] = true;
      }

      // if there aren't any relevant imports specified or in their own folders,
      // then use the baseList (root of the library folder) as the default.
      if (platformList == null
          && platformList32 == null
          && platformList64 == null
          && platformListArmv6hf == null) {
        exportList.put(platformName, baseList);

      } else {
        // once we've figured out which side our bread is buttered on, save it.
        // (also concatenate the list of files in the root folder as well
        if (platformList != null) {
          exportList.put(platformName, platformList);
        }
        if (platformList32 != null) {
          exportList.put(platformName32, platformList32);
        }
        if (platformList64 != null) {
          exportList.put(platformName64, platformList64);
        }
        if (platformListArmv6hf != null) {
          exportList.put(platformNameArmv6hh, platformListArmv6hf);
        }
      }
    }
    //    for (String p : exportList.keySet()) {
    //      System.out.println(p + " -> ");
    //      PApplet.println(exportList.get(p));
    //    }

    // get the path for all .jar files in this code folder
    packageList = Util.packageListFromClassPath(getClassPath());
  }
Exemplo n.º 26
0
  /**
   * Part of the MessageConsumer interface, this is called
   * whenever a piece (usually a line) of error message is spewed
   * out from the compiler. The errors are parsed for their contents
   * and line number, which is then reported back to Editor.
   */
  public void message(String s) {
    int i;

    System.out.println("**************[ROBOTIS]***********************************");
    // remove the build path so people only see the filename
    // can't use replaceAll() because the path may have characters in it which
    // have meaning in a regular expression.
    if (!verbose) {
      while ((i = s.indexOf(buildPath + File.separator)) != -1) {
        s = s.substring(0, i) + s.substring(i + (buildPath + File.separator).length());
      }
    }
  
    // look for error line, which contains file name, line number,
    // and at least the first line of the error message
    String errorFormat = "([\\w\\d_]+.\\w+):(\\d+):\\s*error:\\s*(.*)\\s*";
    String[] pieces = PApplet.match(s, errorFormat);

//    if (pieces != null && exception == null) {
//      exception = sketch.placeException(pieces[3], pieces[1], PApplet.parseInt(pieces[2]) - 1);
//      if (exception != null) exception.hideStackTrace();
//    }
    
    if (pieces != null) {
      String error = pieces[3], msg = "";
      
      if (pieces[3].trim().equals("SPI.h: No such file or directory")) {
        error = _("Please import the SPI library from the Sketch > Import Library menu.");
        msg = _("\nAs of Arduino 0019, the Ethernet library depends on the SPI library." +
              "\nYou appear to be using it or another library that depends on the SPI library.\n\n");
      }
      
      if (pieces[3].trim().equals("'BYTE' was not declared in this scope")) {
        error = _("The 'BYTE' keyword is no longer supported.");
        msg = _("\nAs of Arduino 1.0, the 'BYTE' keyword is no longer supported." +
              "\nPlease use Serial.write() instead.\n\n");
      }
      
      if (pieces[3].trim().equals("no matching function for call to 'Server::Server(int)'")) {
        error = _("The Server class has been renamed EthernetServer.");
        msg = _("\nAs of Arduino 1.0, the Server class in the Ethernet library " +
              "has been renamed to EthernetServer.\n\n");
      }
      
      if (pieces[3].trim().equals("no matching function for call to 'Client::Client(byte [4], int)'")) {
        error = _("The Client class has been renamed EthernetClient.");
        msg = _("\nAs of Arduino 1.0, the Client class in the Ethernet library " +
              "has been renamed to EthernetClient.\n\n");
      }
      
      if (pieces[3].trim().equals("'Udp' was not declared in this scope")) {
        error = _("The Udp class has been renamed EthernetUdp.");
        msg = _("\nAs of Arduino 1.0, the Udp class in the Ethernet library " +
              "has been renamed to EthernetUdp.\n\n");
      }
      
      if (pieces[3].trim().equals("'class TwoWire' has no member named 'send'")) {
        error = _("Wire.send() has been renamed Wire.write().");
        msg = _("\nAs of Arduino 1.0, the Wire.send() function was renamed " +
              "to Wire.write() for consistency with other libraries.\n\n");
      }
      
      if (pieces[3].trim().equals("'class TwoWire' has no member named 'receive'")) {
        error = _("Wire.receive() has been renamed Wire.read().");
        msg = _("\nAs of Arduino 1.0, the Wire.receive() function was renamed " +
              "to Wire.read() for consistency with other libraries.\n\n");
      }

      if (pieces[3].trim().equals("'Mouse' was not declared in this scope")) {
        error = _("'Mouse' only supported on the Arduino Leonardo");
        //msg = _("\nThe 'Mouse' class is only supported on the Arduino Leonardo.\n\n");
      }
      
      if (pieces[3].trim().equals("'Keyboard' was not declared in this scope")) {
        error = _("'Keyboard' only supported on the Arduino Leonardo");
        //msg = _("\nThe 'Keyboard' class is only supported on the Arduino Leonardo.\n\n");
      }
      
      RunnerException e = null;
      if (!sketchIsCompiled) {
        // Place errors when compiling the sketch, but never while compiling libraries
        // or the core.  The user's sketch might contain the same filename!
        e = sketch.placeException(error, pieces[1], PApplet.parseInt(pieces[2]) - 1);
      }

      // replace full file path with the name of the sketch tab (unless we're
      // in verbose mode, in which case don't modify the compiler output)
      if (e != null && !verbose) {
        SketchCode code = sketch.getCode(e.getCodeIndex());
        String fileName = (code.isExtension("ino") || code.isExtension("pde")) ? code.getPrettyName() : code.getFileName();
        int lineNum = e.getCodeLine() + 1;
        s = fileName + ":" + lineNum + ": error: " + pieces[3] + msg;        
      }
            
      if (exception == null && e != null) {
        exception = e;
        exception.hideStackTrace();
      }      
    }
    
    System.err.print(s);
  }
Exemplo n.º 27
0
 public static void main(String args[]) {
   PApplet.main(new String[] {"example_20_4"});
 }
Exemplo n.º 28
0
 public void stop() {
   mymod.stop();
   super.stop();
 }
Exemplo n.º 29
0
 public static void main(String args[]) {
   PApplet.main(new String[] {"--bgcolor=#f3f2f5", "portaPlay"});
 }
Exemplo n.º 30
0
  protected String[] getMachineParams() {
    ArrayList<String> params = new ArrayList<String>();

    // params.add("-Xint"); // interpreted mode
    // params.add("-Xprof");  // profiler
    // params.add("-Xaprof");  // allocation profiler
    // params.add("-Xrunhprof:cpu=samples");  // old-style profiler

    // TODO change this to use run.args = true, run.args.0, run.args.1, etc.
    // so that spaces can be included in the arg names
    String options = Preferences.get("run.options");
    if (options.length() > 0) {
      String pieces[] = PApplet.split(options, ' ');
      for (int i = 0; i < pieces.length; i++) {
        String p = pieces[i].trim();
        if (p.length() > 0) {
          params.add(p);
        }
      }
    }

    //    params.add("-Djava.ext.dirs=nuffing");

    if (Preferences.getBoolean("run.options.memory")) {
      params.add("-Xms" + Preferences.get("run.options.memory.initial") + "m");
      params.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m");
    }

    if (Base.isMacOS()) {
      params.add("-Xdock:name=" + build.getSketchClassName());
      //      params.add("-Dcom.apple.mrj.application.apple.menu.about.name=" +
      //                 sketch.getMainClassName());
    }
    // sketch.libraryPath might be ""
    // librariesClassPath will always have sep char prepended
    params.add(
        "-Djava.library.path="
            + build.getJavaLibraryPath()
            + File.pathSeparator
            + System.getProperty("java.library.path"));

    params.add("-cp");
    params.add(build.getClassPath());
    //    params.add(sketch.getClassPath() +
    //        File.pathSeparator +
    //        Base.librariesClassPath);

    // enable assertions
    // http://dev.processing.org/bugs/show_bug.cgi?id=1188
    params.add("-ea");
    // PApplet.println(PApplet.split(sketch.classPath, ':'));

    String outgoing[] = new String[params.size()];
    params.toArray(outgoing);

    //    PApplet.println(outgoing);
    //    PApplet.println(PApplet.split(outgoing[0], ":"));
    //    PApplet.println();
    //    PApplet.println("class path");
    //    PApplet.println(PApplet.split(outgoing[2], ":"));

    return outgoing;
    // return (String[]) params.toArray();

    //  System.out.println("sketch class path");
    //  PApplet.println(PApplet.split(sketch.classPath, ';'));
    //  System.out.println();
    //  System.out.println("libraries class path");
    //  PApplet.println(PApplet.split(Base.librariesClassPath, ';'));
    //  System.out.println();
  }