domoszlai / juicy-gcode

A lightweight SVG to GCode converter for maximal curve fitting
https://hackage.haskell.org/package/juicy-gcode
MIT License
110 stars 7 forks source link

Control feedrate with object colour (Feature Request) #20

Closed SuperMonkeyRules closed 1 year ago

SuperMonkeyRules commented 1 year ago

I think it would be helpful if juicy gcode could be able to get the colour of an object and use that to set that paths feedrate (and laser power).

Im trying to read through the code and do it myself, but im not very familiar with Haskell. Any guidance would be great, if you dont want to do it your self.

domoszlai commented 1 year ago

I've been thinking about using colors as additional input for a while. The simplest thing could be something like a mapping from color to GCODE commands in a config file. The commands could be injected into the output when the color changes... I don't have the time do it right now, but I can help you of course if you have any specififc question

domoszlai commented 1 year ago
gcode {
   begin = "G17;G90;G0 Z1;G0 X0 Y0"
   end = "G0 Z1"
   toolon =  "G00 Z1"
   tooloff = "G01 Z0 F10.00"
}
colors {
   000000 = "M220 S50"
   0000ff = "M220 S80"
}

Something like this. Could it work?

domoszlai commented 1 year ago

So, do you think the proposed solution would work for you? I don't want to invest in a complicated thing before it proved to be necessary. Also, would you be able to test it?

SuperMonkeyRules commented 1 year ago

It looks like it would work and I would be happy to test it.

domoszlai commented 1 year ago

Are you able to build the project?

SuperMonkeyRules commented 1 year ago

Im not too familiar with it but I could try.

domoszlai commented 1 year ago

All right, let's give a try. It should be pretty easy with stack. You should follow the installatin section in the README, but run an extra git checkout color after git clone.

So, I preperad branch color. It should be able to generate color specific gcode. Unfortunately, I had to change the config file format to YAML. Anyway, this is the config I used, I hope it gives you an idea how to use it:

begin: 
  - "G17"
  - "G90"
  - "G0 Z1"
  - "G0 X0 Y0"
end:
  - "G0 Z1"
toolon:
  - "G01 Z0 F10.00"
tooloff:
  - "G00 Z1"
colors:
   "000000": 
       - "; black"
   "FF0000": 
       - "; red"
   "FFFF00": 
       - "; yellow"   
SuperMonkeyRules commented 1 year ago

Thank you so much Ill try it out in the morning.

SuperMonkeyRules commented 1 year ago

Its able to convert the svg to gcode but doesnt seem to add any thing to do with colours. This is what I have under config.yaml and Im running the command with juicy-gcode.exe drawing.svg --curve-fitting=linear -f config.yaml -o test.gcode

begin:

Github doesnt seem to want to format it nicely

domoszlai commented 1 year ago

I added your config along with a simple SVG + generated output here: https://github.com/domoszlai/juicy-gcode/tree/color/resources/tests/color

I hope this helps to eliminate most of the potential problems.

If it still dosn't work, please attach your SVG, I'll have a look

domoszlai commented 1 year ago

The latest release, v1.0.0.0, enables you to set color specific feedrate. Please have a look and reopen this case if it does not work for you