posts tagged with the keyword ‘plottertwitter’

2019.02.03

urm-swift-pro-00

We recently got a uArm Swift Pro robot arm at Brinn Labs and I’ve been putting it through its paces. It comes with software called uArm Studio that lets you do a lot of things, but for this post I’ll focus on drawing (or “plotting”) using a pen.

heart-bw

One of the tools I’ve used in the past with the Egg-Bot was StippleGen2 from our friends at Evil Mad Scientist Laboratories. StippleGen2 is a program written in Processing that takes an image and converts it into a series of lines, or more specifically, a single line, which is suitable for plotting.

Above is the image I started with, an “8-bit heart” as I call it. It’s a simple black and white image of a low-res heart. (Great for Valentine’s Day, right?)

heart-tsp

After running the heart through StippleGen2 and choosing the appropriate complexity of the line drawing I wanted, I saved out the file as a SVG format vector file. Perfect for plotting. (In fact, since it’s a single line, the z axis never has to move up once it starts.)

uarm-studio

I fired up uArm Studio and chose the Draw/Laser feature, and the loaded in the SVG file. I did have to scale it up a bit, as I still don’t have the exact dimensions I should use for artwork in uArm Studio.

Once the file is loaded, you hit start and there’s a step where you set the z axis so it know where the pen hits the paper. At this step, I wish there was a little more control over how the z axis moves. I think the smallest increment is one millimeter, and I think it should be smaller. (Most CNC software has some adjustment to how much you move things, so I can see adding in 0.5mm and perhaps 0.2mm as well.)

urm-swift-pro-01

While the uArm Swift Pro is awesome, I’m still going to be a little critical… One of the issues I’ve come across in the Draw/Laser part of the software is that the speed seems to be hard-coded, with no way to adjust it to go faster (or slower.) As someone who understands G-code and how CNC machines work, I found this a little annoying…

urm-swift-pro-03

So I set about to find a solution. I first posted a message on the forum, but then Chinese New Year hit and it seemed as though it would be two weeks (or more) before I got an answer. I had dug around and found that the G-code created by the Draw/Laser part of the software generates a file and drops it at ~/uarm/Temp/files/gcode/tmp_pen.gcode and I assumed that by editing the feedrate in that file, I could speed things up… I was right!

urm-swift-pro-04

My first attempt was to connect with the arm using Universal Gcode Sender, which in this case was not universal, and failed to properly talk to the arm. I dug around a bit more and found simple_stream.py which is a Python script to stream G-code to a device. Sadly, it was not compatible with Python3, but luckily, I’ve been writing a lot of Python lately, so I fixed it.

After I got it working (that is, after much hacking at the original code) I found that I could easily speed up the drawing to half the time. In this case, 5 minutes with the Python script versus 10 minutes with uArm Studio. For TSP art, great precision tends not to matter too much, and I think I could speed it up even more.

I’ll work on cleaning up my Python code and seeing if I can get it online in case others want to muck around with it.

2019.01.29

rects-01

I started playing around with the #plottertwitter thing and wanted to do some creative coding with Processing, and at least one person asked about the code, so I’ve included it below.

rects-02

Instead of drawing a rectangle, I’m creating a shape, and then varying the position of it a bit more with each row that is drawn. I reused some code I’ve used plenty of times before that keeps track of where things are drawn so the code knows when to start a new row, and when the screen is filled. After it draws a screen full it will save a PDF and exit.

Once you have a PDF (which is a vector file) you can make your plotter (or laser cutter, or CNC machine) do what you want with it. I typically bring the PDF into Inkscape and make any adjustments needed before I save it out in a format suitable for the machine I’ll be sending it to.

/* 
 * RectangleChaos.pde
 * 
 * Pete Prodoehl <pete@rasterweb.net>
 *
 * <http://rasterweb.net/raster/>
 * 
 */

import processing.pdf.*;
import java.util.Date;

int sw = 1280; // if you change the resolution here change
int sh = 720;  // it below in the setup size as well...
Date d = new Date();
long current = d.getTime()/1000; 

void setup() {
  size(1280, 720);
  stroke(0);
  strokeWeight(1);
  background(255);
  beginRecord(PDF, "output-" + current + ".pdf");
}

float xpos = 50;  // you can adjust these numbers to get 
float ypos = 50;  // different results, so play around 
float wall = 150; // and experiment a bit...
float step = 40;  //
float rsize = 40;
float mimn  = xpos;
float rowct = 0;
float multiple = 0;

void draw() {

  noFill();
  
  float x1 = xpos;
  float y1 = ypos;  
  
  // change number below for different results... try 1.33 or 2.33
  multiple = rowct * 2.33;
  
// first row is normal, after that we offset things a bit
  if (rowct > 0) {
    x1 = xpos + random(0,multiple);
    y1 = ypos + random(0,multiple);
  }
  else {
    x1 = xpos;
    y1 = ypos;
  }

  float x2 = x1 + rsize;
  float y2 = y1;

  float x3 = x1 + rsize;
  float y3 = y1 + rsize;
  
  float x4 = x1;
  float y4 = y1 + rsize;
  
  float x5 = x1;
  float y5 = y1;
  
  beginShape();
  vertex(x1,y1);
  vertex(x2,y2);
  vertex(x3,y3);
  vertex(x4,y4);
  vertex(x5,y5);
  endShape();
  
  
  // end of a row
  if (xpos > (sw-wall)) {
    xpos = mimn;
    ypos = ypos + step;
    rowct++;
  }
  else {
    xpos = xpos + step;
  }
  
  // last row, then we save the PDF and end
  if (ypos > (sh-wall)) {
    ypos = step;
    endRecord();
    exit();
  }

}

If you make something cool with this code, let me know! I’d love to see what you come up with.

|


buy the button:

Buy The Button