Sandify CLI

Welcome Paul!

Sandify is a beast, written in javascript, very interconnected with it’s front end. The frameworks are react, redux, and react-bootstrap. We made very little effort to make the math reusable. It is pretty embedded into sandify.

But, hope is not lost. The goofy scara stuff started as a python script, and wasn’t incorporated into sandify until I had a few people asking for it. The original math, and code to convert from thetarho to goofy gcode is here:

Theta rho is the format created by Bruce Shapiro for the sisyphus machines. Theta is the angle of the arm. Rho is a normalized (0 to 1) radius value for the distance from the center.

You asked for gcode to goofy gcode though. Let me tell you why thetarho is easier for this.

First off, a move in gcode is a line. But moves in goofy scara code are all arcs. Moving the shoulder and elbows always results in arcs, not lines (except for some arcs with infinite radii :slight_smile: ). Thetarho also only creates arcs. If you want to convert a square to scara or thetarho, you have to break it up into a couple of hundred commands to get a smooth line-like edge. If you want a cartesian gcode to scara gcode converter, you need to break up the lines.

Gcode for a square might look like this:

G1 X100 Y100
G1 X-100 Y100
G1 X-100 Y-100
G1 X100 Y-100
G1 X100 Y100

It can really look a lot of ways, but this is the best for human readability :slight_smile:. If you just took the coordinates (100,100) , (-100,100) and converted them to angles, your scara machine would draw a circle to get to each of those points.

So you really need to break that line up into (100,100), (99.9,100),(99.8,100)… etc. Then convert each point to scara angles. Sandify does this already when you import gcode and export theta rho. It is all in the exporter for theta rho. That could be rewritten easily enough.

The second trick is accumulating the angles over 2 pi. When the gcode goes from (-0.1,100) to (0.1,100); the naive approach would be to just convert each of those coordinates to shoulder angles independently. But that would result in an angle going from <2pi to >0. But you want it to go to >2pi. And the next time around, go over 4pi. Otherwise the arms would unwind every time they passed over that angle.

To fix that, sandify takes two consecutive points and computes the smallest angle to get there, and adds that to the start angle. That accumulator math is baked into the thetarho conversion. It is safe because we already broke every move into small ones that are definitely smaller than pi, so it is easy to be sure we won’t accidentally go the wrong way around the circle.

Compare that to converting thetarho format. This is the simplest thetarho script:

0.00 0.00
628 1.00

That goes from 0 angle to 100pi, as it also goes from the center (0) to the edge (1). That makes a big spiral that starts in the middle, makes 100 turns, and ends at the outside edge. The way sisyphus interprets between them, the radius at each turn will increase by 0.01. it will be a nice spiral.

If you just took those two end points and converted them to scara, it would be something like:

G1 X0.00 Y0.00
G1 X600 Y597

It is something like that, I’m not actually doing the math. There are 6 “units” in a circle. The shoulder would move 100 circles. The elbow would move 100 circles, minus a half circle to end up fully extending the arm.

That would do exactly the same spiral. When X was at 6, Y would be at 5.97, which would make the radius of the ball 0.01 from the center to the outer edge.

Even huge arcs like that one will be mapped correctly. Anything from sandify will definitely be converted correctly. I also think any pattern from the web in thetarho would be converted correctly.

Any patterns in gcode that you want in scara can be converted in sandify by importing and exporting as thetarho, then converting to scara using that script. Or just export the scara directly.