CauldronDevelopmentLLC / CAMotics

Open-Source Simulation & Computer Aided Machining - A 3-axis CNC GCode simulator
Other
622 stars 143 forks source link

how to add other machines? #403

Open tcurdt opened 1 year ago

tcurdt commented 1 year ago

I wanted to add a custom machine but run into a few hurdles raising many questions:

Screenshot 2023-08-22 at 23 13 10 Screenshot 2023-08-22 at 23 13 43
jcoffland commented 1 year ago

I seems machines can only be added at compile time?

You can add new machines to the machines directory and restart CAMotics and they should show up. Currently, you need a .json and a .tco.

I suspect the .tco file defines the 3D view of the machine - what format is that?

It's an arbitrary format that some other developer came up with. I've considered converting everything to STL files but STL has no provision for storing other info so you'd have to have a separate STL for each part of the machine. It makes sense to just add the triangles directly to the JSON file rather than referencing an external TCO or STL files. The TCO contains lists of triangles, lines and vertices.

The positioning of the path/material seems to vary when switching machines. Why is that? How can this be controlled (or may I say fixed)?

This is messy. It would be very helpful if we had some sort of machine editor. You would need to be able to load a triangle mesh (probably from STL) for each axis and the base and then specify home positions (i.e. 3D offsets which put the mesh into the home position), and the relationships between the axes. On some machines, for example, the x-axis moves with the y-axis and the z-axis moves with both axes. But that's not always the case. You could have a stationary z-axis and a moving base or lots of other combinations. An editor would let you position the parts of the machine at their homes, specify their limits and then save the result as a machine definition.

Once the machine editing is sorted out it would be great to detect collisions or moves beyond the machine's limits.

jcoffland commented 1 year ago

I've replace the TCO format with pure JSON. Now the machine files are in compressed JSON .json.bz2 files. I completely removed TCO support.

tcurdt commented 1 year ago

I've replace the TCO format with pure JSON. Now the machine files are in compressed JSON .json.bz2 files. I completely removed TCO support.

Wow! That was quick 🙂

Once the machine editing is sorted out...

But do you really want to add a machine editor? That sounds like a lot of work. Or what exactly do you have in mind there? Wouldn't it be maybe enough to have a certain number of types of machines that can be parameterised?

I personally wouldn't need a fancy STL type visualisation. But being able to specify the cutting area is what brought me here. Just my 2 cents.

jcoffland commented 1 year ago

But do you really want to add a machine editor? That sounds like a lot of work. Or what exactly do you have in mind there?

I was not thinking about a whole 3D editor but an editor where you could load in the 3D parts created in some other CAD program.

Wouldn't it be maybe enough to have a certain number of types of machines that can be parameterised?

You do make a good point. The first thing to do would be to make it possible to just edit the existing machine parameters and save them as your own machine. Importing the 3D drawings is more involved.

spot1984 commented 7 months ago

It sure would be nice to model machines in CAD packages (e.g. FreeCAD, OpenSCAD, TinkerCAD, Blender, Fusion360, etc.) and export meshes in a common format (e.g. .obj, .step, .stl) that could be converted and assembled into machines either in Camotics or even with something as simple as a python script included in the machines directory that could convert a collection of meshes into a json file that could be edited to finish the machine? I'm trying to make a suggestion that would balance enabling the community without hand typing vertices, lines, and triangles, and also not distracting Camotics mainstream development

tcurdt commented 7 months ago

It sure would be nice to model machines in CAD packages [...] and export meshes in a common format [...] that could be converted and assembled into machines

I looked into the json but TBH I couldn't really make much sense of it yet.

{
  "name": "X-Carve",
  "model": "x-carve.tco",
  "tool": [1, 1, 1],
  "workpiece": [0, 0, 0],

  "reverse_winding": true,
  "transform": [
    [1, 0, 0, 0],
    [0, -1, 0, 75],
    [0, 0, 1, 0],
    [0, 0, 0, 1]
  ],

  "parts": {
    "x": {
      "init": [0, 0, 0],
      "home": [0, 0, 0],
      "min": [0, 0, 0],
      "max": [9, 0, 0],
      "movement": [1, 1, 0]
    },

    "y": {
      "init": [0, 0, 0],
      "home": [0, 0, 0],
      "min": [0, 0, 0],
      "max": [0, 0, 0],
      "movement": [0, 1, 0]
    },

    "z": {
      "init": [0, 0, 0],
      "home": [0, 0, 0],
      "min": [0, 0, 0],
      "max": [0, 0, 0],
      "movement": [1, 1, 1]
    }
  }
}

Why doesn't this have dimensions but is mostly 1 based? Why is transform a 4x4 matrix?

I would love to add my customized PrintNC somehow. It would be super cool if you could give some guidance, @jcoffland

jcoffland commented 7 months ago

https://www.brainvoyager.com/bv/doc/UsersGuide/CoordsAndTransforms/SpatialTransformationMatrices.html

tcurdt commented 7 months ago

Why is transform a 4x4 matrix?

https://www.brainvoyager.com/bv/doc/UsersGuide/CoordsAndTransforms/SpatialTransformationMatrices.html

I see - rotate and translate.

But how are the dimensions defined? Through the related 3d model I assume?

jcoffland commented 7 months ago

It's been a long time since I looked at this. The source code is the best place to find out how this all works.

tcurdt commented 7 months ago

I can't find the x-carve.tco referenced in the json.

I've checked https://github.com/CauldronDevelopmentLLC/CAMotics/tree/master/src/camotics/machine but I don't see where the 3d model of the machine comes in yet.

jcoffland commented 7 months ago

CAMotics no longer uses the TCO format. The machine files are bzip2 compressed JSON. See the machines directory.

tcurdt commented 7 months ago

CAMotics no longer uses the TCO format. The machine files are bzip2 compressed JSON. See the machines directory.

Sure - but neither the old TCO format nor the JSON format has the 3D Model information.

jcoffland commented 7 months ago

The JSON files contain all the part data. The parts contain lines and mesh which describe the shape.

tcurdt commented 7 months ago

This is the shapeoko_3.json. I don't see any lines or mesh. 🤔

{
  "name": "Shapeoko 3",
  "model": "shapeoko_3.tco",
  "tool": [1, 1, 1],
  "workpiece": [0, 0, 0],

  "reverse_winding": true,
  "transform": [
    [1, 0, 0, 0],
    [0, -1, 0, 75],
    [0, 0, 1, 0],
    [0, 0, 0, 1]
  ],

  "parts": {
    "x": {
      "init": [0, 0, 0],
      "home": [0, 0, 0],
      "min": [0, 0, 0],
      "max": [9, 0, 0],
      "movement": [1, 1, 0]
    },

    "y": {
      "init": [0, 0, 0],
      "home": [0, 0, 0],
      "min": [0, 0, 0],
      "max": [0, 0, 0],
      "movement": [0, 1, 0]
    },

    "z": {
      "init": [0, 0, 0],
      "home": [0, 0, 0],
      "min": [0, 0, 0],
      "max": [0, 0, 0],
      "movement": [1, 1, 1]
    }
  }
}
jcoffland commented 7 months ago

That's the old file.

https://github.com/CauldronDevelopmentLLC/CAMotics/blob/master/machines/shapeoko_3.json.bz2

tcurdt commented 7 months ago

Just realized the I am running an old version (1.2.0). I guess that's why.

spot1984 commented 1 week ago

1.2.0 is the latest release, so still using the .tco format until the next release.