LaserWeb / LaserWeb4

Collaborative effort on the next version of LaserWeb / CNCWeb
GNU Affero General Public License v3.0
714 stars 193 forks source link

Help understanding camPaths before gcode generation #506

Open iceblu3710 opened 6 years ago

iceblu3710 commented 6 years ago

I have a very simple 10mm square. When inspecting the path in the workspace it makes perfect since, its closed off and everything is happy. When I interrupt the gcode processor for the millng operations just before camPaths is turned into gcode everything is really off. The camPath path values are way to large, even if its an implied precision its out by 2x. What is really wierd is that the gcode is 10mm like it should be....

I am trying to write in a gcode optimizer as well as UNoptimizer. My CNC requires max Y plunge points only as its at an 80deg angle and a through cut piece would fall into the bit unless its entry/exit is max Y somewhere. I have a routine to find maxY and rotate the paths so the start point is that location but I am very unsure of where to actually put this pre-processor.

Path from the workspace:

    {
      "id": "2cc288b9-65d8-47b6-b626-f096d98a5b6a",
      "type": "LWPOLYLINE",
      "name": "LWPOLYLINE: BC",
      "mimeType": "",
      "isRoot": false,
      "children": [],
      "selected": true,
      "visible": true,
      "transform2d": [1, 0, 0, 1, 0, 0],
      "rawPaths": [[0, 0, 0, 10, 10, 10, 10, 0, 0, 0]],
      "strokeColor": [0, 0, 0, 1],
      "fillColor": [0, 0, 0, 0],
      "dataURL": "",
      "originalPixels": null,
      "originalSize": null
    }

camPaths while at: https://github.com/LaserWeb/LaserWeb4/blob/22e0f7e3cf4d0ce36741426920e37a5e120247e2/src/lib/cam-gcode-mill.js#L256

[
  {
    "path": [
      {
        "X": 500000000,
        "Y": 500000000
      },
      {
        "X": 0,
        "Y": 500000000
      },
      {
        "X": 0,
        "Y": 0
      },
      {
        "X": 500000000,
        "Y": 0
      },
      {
        "X": 500000000,
        "Y": 500000000
      },
      {
        "X": 500000000,
        "Y": 500000000
      }
    ],
    "safeToClose": true
  }
]
tbfleming commented 6 years ago

The polygon libraries only support integer coordinates. See mesh.js for the conversion factors.

iceblu3710 commented 6 years ago

Ah I see a 2e-8 scale factor from mmtoclipper being applied.

What is the common entry point to the gcode process? I would like my path mapper function to sort the camPaths just before handing the camPaths to the cam modules as there are several different versions.