FullControlXYZ / fullcontrol

Python version of FullControl for toolpath design (and more) - the readme below is best source of information
GNU General Public License v3.0
672 stars 78 forks source link

[QUESTION] Pen Plotting with Rotating Tool (2.5 Axis) #61

Open dhumpo opened 10 months ago

dhumpo commented 10 months ago

I am designing a variable line width pen plotter with a rotating z axis. The line thickness is determined by the rotation of the marker tool. (perpendicular/90deg to tool path tangent = on/full width)

https://github.com/FullControlXYZ/fullcontrol/assets/156947078/c5842998-d86c-46c1-8d39-b869cab337c7

I am using Blender's geometry nodes to pre-visualize/design a variable line width plot. I'm then exporting as an indexed, 3 coordinate list. Below is a sample of the .ply data from Blender (X, Y, Rotation in Radians)

ply #concise coordinate in meters, x,y,rotation format ascii 1.0 comment Created in Blender version 4.0.2 element vertex 9216 property float x property float y property float z #radians element edge 9088 property int vertex1 property int vertex2 end_header 5.5847714e-08 1.8739383 0.676805 #first coordinate with rot value 0.014846257 1.8739147 0.67858016 #second... 0.029689893 1.8737563 0.6825235 0.04452504 1.8733462 0.68454605 0.05934261 1.8725877 0.6866971 0.074131355 1.8714039 0.6933933 0.08887847 1.8697386 0.702613 0.103570454 1.8675553 0.708761 0.118194 1.864838 0.7144503

I plan on building a CoreXY rig with a stepper at the head controlling marker rotation, converting that z coordinate into degrees rotation. Currently, I'm appending/replacing the z coordinate with the calculated rotation (based off of the sampled image/curve tangent) out of convenience. This format could change, it would just be a matter of appending the rotation value to one of the 3 color coordinates that .ply can also store. Whatever makes more sense for this implementation.

I don't have Excel and was reading the overview doc for the python implementation. Are there objects/templates that allow for the import of a coordinate list like the one above (or any indexed coordinate list, was using .ply as a debug) for it to be properly read by FC?

Additionally, curious how you all would approach the z-axis rotation. That would be messing with the FC design, as this plotter is a thing that does not factor in states associated with FDM. (working exclusively in travel paths, no layer heights, etc.). I am a complete python/scripting novice, so would appreciate a layman's response (if possible).

Thanks dhumpo

fullcontrol-xyz commented 10 months ago

Comment copied from reddit:

Once you know your final implementation, I'll help you get set up in FullControl. It's very easy to import the data (using standard python functionality) and convert it into the appropriate data for FullControl/GCode (e.g. X Y ROTATION). As I said, I'll demo that once you know your setup. But following another comment to your post, if you choose to vary Z height, that will be different than if you use pen rotation. Both are very interesting options. There is some ongoing interesting in using FullControl for pen plotting, including previewing the path with correct widths and automatically generating paths from images, etc. So I'm keen to generalise any of the things you do as much as possible and make it useful for other people

In the quickest implementation, am I correct in thinking you need to import a csv file of lots of lines of "X, Y, ROTATION" and convert that to GCode? What is the format of the GCode? Does the letter Z in gcode need to change to another letter?

dhumpo commented 10 months ago

That is correct. I plan on using GRBL firmware (or similar that would work on an Arduino shield). For readability/debug purposes, I think changing Z to r would be helpful.

As I've been developing the drawing tool in Blender, I realized the plotter should have some way of raising and lowering the marker. This is a secondary goal but wanted to include it in the discussion as well.

Because we've forfeited the z-axis, the design could be modified so that the printing/traverse states control a servo that raises the whole tool head (marker and stepper) perpendicular to the work surface. I can imagine this is a common design modification for plotters programmed with FC. Similar to the design below:

Screenshot 2024-01-20 090248

Best dhumpo

fullcontrol-xyz commented 10 months ago

I'd suggest you actually use a 4-axis version of FullControl. The rotation can be specified by the B rotation axis. Then you can either write the exact Z value you want for each point if you have a stepper motor controlling Z. Or if you have some kind of on/off servo for Z, you could design Z of each point to be 0 or 1, and then the gcode would be interpreted based on whether it has Z0 or Z1 written in the gcode line. Sound good?

dhumpo commented 10 months ago

From a hardware standpoint I like the sound of a binary servo.

There are some plotting designs that are not indexed nicely, unlike the design shown in the first post. In this case I would need to define the travel path (z servo on/1) in addition to the plot path, (servo off/0) correct?

Or would the FC design interpolate a travel vector between the end of one path, and the beginning of the next in the index sequence?

I'll make a quick animation to depict the indexing issue if what I'm describing this poorly.

dhumpo commented 10 months ago

https://github.com/FullControlXYZ/fullcontrol/assets/156947078/20b44165-1a01-4bf6-b415-d3981783088c

The white line is an animation of the plot path from index 0-600. When the plot path reaches the end of one segment would an FC design be able to interpolate a travel path to the beginning of the next segment?

I understand this sequence should run vertically down the work surface, and that this will antagonize plot times, but I've yet to determine a solution in Blender.

fullcontrol-xyz commented 10 months ago

Yep that's all easy in FullControl. There can be a quick check for each new point, and whenever the x-value of a point is lower than the previous point, you know you're starting a new line and can automatically add these steps: move to Z1, move to next XY, move to Z0, continue through points. Alternatively, if you imported data included information about which lines are drawn and which are travel, that's even easier. It would also be possible, with a little bit of python magickery, to re-order the lines to run sequentially from top to bottom.

dhumpo commented 10 months ago

Ok great, I think that quick check will work fine. Drawing travel lines in Blender is possible but doesn't sound necessary with the solution you described.

The python magickery would be a similar check, reordering the group index of each segment by decreasing y value?

For example, an if loop looking for a negative change in the x value, and then sorting that group index (the line segment) by the y value of the first index in that group.

fullcontrol-xyz commented 10 months ago

Yep exactly, I was thinking you'd split your large list into a series of smaller lists and then order them and potentially reverse them as required. There are lots of other ways to do it too. That's why we made FullControl use native python as much as possible to allow complete freedom during design.

ES-Alexander commented 9 months ago

Noting that if you calculate expected extrusion widths from the rotation angles within FullControl then it should be possible to visualise nicely with FullControl's plotting functionality (to make sure it's doing what you expect, and in case you want to generate paths in FullControl instead of always using Blender), potentially using a colour gradient to show the drawing order (since there isn't yet support for toolpath animation) :-)


For linking purposes, this Issue is relevant to #15.