Back to Freecad

ADR-002: Internal Representation of tool paths

src/Mod/CAM/Roadmap/ADR/ADR-002.md

1.1.15.8 KB
Original Source

ADR-002: Internal Representation of tool paths

Status

Legacy

Context

We require a data structure to hold the computed tool path data. The internal representation will be directly rendered into the 3D scene. Tool paths may contain hundreds of thousands or even millions of elements so memory utilization should be considered. The tool paths will be converted into g-code during post-processing.

Decision

We will use an abbreviated subset of gcode as the internal representation. The intent is not to support the full range of RS274 features but to provide enough to capture user intent and to efficiently render the tool paths visually.

The internal representation (Path Commands) resembles gcode but does not support all gcode features. It differs from gcode in significant ways.

FreeCAD Path CommandsGcode
always in FreeCAD native units (MM)May be in MM or IN
velocity is represented in units per secondvelocity is represented in units per minute
absolute coordinates are in the FreeCAD global coordinate system. No other coordinate systems exist.absolute coordinates are relative to the active coordinate system
gcode command coordinates are always absolutegcode coordinates may be either absolute or relative
no modal commandssome gcodes affect how subsequent gcodes are interpreted
machine agnosticmachine specific

List of currently supported G-code commands

CommandDescriptionSupported ArgumentsDisplayed
G0, G00Rapid moveX,Y,Z,A,B,CRed
G1, G01Normal interpolated moveX,Y,Z,A,B,CGreen
G2, G02Clockwise arcX,Y,Z,A,B,C,I,J,KGreen
G3, G03Counterclockwise arcX,Y,Z,A,B,C,I,J,KGreen
G73chipbreak drill operationX,Y,Z,R,QRed/Green
G74left hand tapping operationX,Y,Z,R,QRed/Green
G81drill operationX,Y,Z,R,QRed/Green
G82drill operation with dwellX,Y,Z,R,QRed/Green
G83drill operation with peckX,Y,Z,R,QRed/Green
G84right hand tapping operationX,Y,Z,R,QRed/Green
G38.2Straight probe move (used in probe operation)Z,FYellow
M0, M00Compulsory stop
M1, M01Optional stop
M3, M03Spindle on (clockwise rotation)S<rounds per minute>
M4, M04Spindle on (counterclockwise rotation)S<rounds per minute>
M6, M06Tool changeT<tool number>
(Message)comment

Fixtures

FreeCAD Job setup allows operations to be conducted in multiple machine fixtures. Path commands for activating fixtures are supported for: G54, G55, G56, G57, G58, G59, G59.1 G59.2, G59.3, G59.4, G59.5, G59.6, G59.7, G59.8, G59.9,

Non-Conforming commands

These commands do not conform to this ADR and are subject to deprecation and should not be used.

CommandDescriptionSupported Arguments
G80cancel canned cycle
G90absolute coordinates
G91relative coordinates
G41Tool radius compensation valueRadius compensation is done in FreeCAD
G42Tool radius compensation valueRadius compensation is done in FreeCAD
G98Return to initial Z level in canned cycle
G99Return to R level in canned cycle
G40Cancel tool compensation

Consequences

Advantages

  • it is human readable
  • it is memory efficient
  • it is easily converted into final gcode
  • it is extensible

Disadvantages

  • Gcode is not explicit. A command contains semantics about where to move the cutter to but not where it is coming from. Therefore the first move will always appear as a move from the origin
  • Directly inspecting the path commands will not reflect either the document unit schema or the selected output unit schema.