Repository navigation
ThermalCut compensation="control": the controller applies the kerf (#384) - #387
Merged
Merged
Conversation
) The program carries the part side of the kerf path and the controller offsets it by half the kerf. CutterCompensation gains amount_mm; the motions stay the beam path, the post writes their part side (written_path), and the decoders replay the controller's offset of what was written (camlib::controller_offset), each move checked against the plan with both corner joins bounded. - Planner (thermal/control.rs): outside corners take the controller's intersection join, the arc join is probed too; the pierce and the lead-out end are on the written path; refusals for common_line, micro_joints, corner_loops, edge_starts, leads without an arc, gaps narrower than the kerf, trimmed or crossing offsets, unclear joins. - Posting: GCodeDialect.compensation_amount_word (G41/G42 O# on a block of its own, G40 alone); compensated stretches are written and read whole and checked in batches of 64. - WinCNC plasma post: control_kerf="g41" (G41 O<kerf/2>, Users Guide 3.1.04 pp. 138-139) or "material" (the owner's declaration: the control applies its material setup's kerf with no word); cutcomp R, C and F replayed. - Wear compensation offset to the scrap side: G41 for the usual direction (it was G42, into the part), with a test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
The original self-intersection scan skipped neighboring edges. A semicircle from (0, 0) to (2, 0) through (1, −1), followed by a straight edge to (−1, −1), has a second intersection at (0.2, −0.6). The old scan accepted it. Commit 27a29ab checks both the written outline and the beam path with the engine’s planar boundary validator. The regression also checks a simple loop with the same semicircle. Linux passed the new regression, the three Rust controller-compensation integration tests and 38 Python thermal tests, including inch and millimetre output and independent G-code replay. The plasma, common-line and edge-start release benchmarks matched their committed expectations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #384
ThermalCut(compensation="control"): the program carries the part side of the kerf path and the controller applies the whole kerf. Posted with the WinCNC plasma post either as the documentedG41 O<kerf/2>/G40form or, for a control its owner declares applies its material setup's kerf itself, with no compensation word.What changed
Events.
Event::CutterCompensation(Rust and Python) gainsamount_mm(only when turning on): the controller offsets the written path by the whole amount. The motions stay where the beam centre runs, so the stream, stock, receivers, playback and stock replay are unchanged; the post writes the motions offset back by the amount. Withoutamount_mmnothing changes (serialization skips it).Planner (
src/thermal.rs, newsrc/thermal/control.rs)."computer"along the edges. At an outside corner the part side is an arc of a few micrometres (the boundary margin) that cannot be written, so the written path has the corner there and the beam path planned is the controller's intersection join: the two edges' kerf paths extended to where they meet, r / sin(θ/2) from the written corner (WinCNC Versions Information List 3.1.01a: offset arcs and "calculate a new intersection point"). The arc join (half a kerf about the written corner) that a controller could use instead lies inside it; both are probed against every part, the extension pieces with a named refusal ("an acute part corner whose extended join reaches a neighbouring part").pierce_clearance_mm; the entry move (off to on) runs straight from it to the lead arc start, the cancel move from the lead-out arc end to the written end; both probed as leads. The written straight leads are collinear with the planned ones, so they run tangent into the lead arcs and the controller's start-up end point does not depend on its entry type.common_line,micro_joints,corner_loops,edge_starts; leads without a straight part or without an arc; a kerf path bridging a gap narrower than the kerf (two outside corners meet, or a corner meets a sharp turn); a sharp turn toward the part; an element whose part side its corners trim away; a beam path that crosses itself; a corner join not clear of the parts.Controller model (new
src/controller_offset.rs, bound asnative.replay_controller_offset). Reads only written curves, side and amount: offsets each written line/arc, joins consecutive offsets at their intersection, reports each outside corner's arc join and the intersection's reach, refuses entry/cancel moves that are not tangent into the path, offsets that do not meet or that trim an element away. Near-tangent junctions (rounded words) are joined at the local intersection, else across the gap; the gap and amount x sin(turn) at the entry/cancel are reported asresidual_mm, refused beyond a quarter of the tolerance and added by the post engine to every replayed move's checked deviation, which must stay within the output tolerance.Posting (
python/camlib/postprocessor.py).GCodeDialect.compensation_amount_word(None by default; WinCNCO):G41/G42+ amount on a block of its own,G40on its own. A post whose dialect has no amount word refuses"control".written_path()(Python, independent of the Rust replay and of the planner): what the post writes for a compensated stretch.PostEngine._post_stretch: a stretch from compensation on to the move after it turns off is written and read whole (the controller joins each move with the next, so a move is known only once the next one is read), then checked in batches of at most 64 events through the same native session, so a stretch can have any length. Arcs in a stretch must be written as one G2/G3 block (the controller offsets the written arc); lowering them to lines is refused.GCodeDecoder.begin_stretch/end_stretch/replay_compensation: the decoder readsG41/G42 O<r>and replays the controller's offset of what was written;unwritten_compensation()for a control that applies the amount with no word (the decoder then checks its compensation starts with the first move after the torch fires and ends with the last before it goes off, and refuses any other cut with the torch on).compensation_unwritten.src/gcode) refuses an amount (documented); its dialect accepts the new field.WinCNC plasma post (
examples/wincnc_plasma_post.py,docs/wincnc-plasma-post.md).control_kerf="g41":G41 O<kerf/2>/G40(WinCNC Users Guide, Controller 3.1, revision 3.1.04, pp. 138-139; ShopSabre's "shopsabre plasma" post, $Revision 44226, lines 490-504). The docs state that this behaviour is documented for revision 3.1.04 and that earlier versions are not covered by the citation.control_kerf="material", material_kerf_mm=...: no compensation word, the control applies half its material setup's kerf to the left of travel from the first move afterM61to the last beforeM62. Documented as the owner's declaration of their control, not a WinCNC manual fact. Only compensated loops, in the usual direction, with the material's kerf.control_kerf=None(default): refused. WINCNC.INIcutcomppremises T0 / positive D; R and C (defaults 200 in, 0.5°) replayed by the decoder (larger, flatter arcs become lines); F (3.1.07b, no documented default) must be declared before a compensated arc is posted.Docs:
docs/operations.md(ThermalCut),docs/posts.md(compensation_amount_word),docs/wincnc-plasma-post.md,docs/library-capabilities.md.Direction finding (wear side fixed)
ThermalCut cuts outlines clockwise and holes counter-clockwise: the part is on the right of travel and the kerf/scrap on the left (
src/thermal.rs: strokes reversed sopart_leftis false;scrap()is the left normal). The controller's offset must therefore go left, G41."wear"wroteCompensationSide::Right(G42) for the default direction, which moves the torch into the part by the wear. This PR fixes it to G41 (G42 withreverse=True), withtests/thermal_control.rs::wear_compensation_offsets_to_the_scrap_side, which checks, independently of the planner, that a point one millimetre to the compensation side of every compensated cut is off the part (fails on main). That is the one change to existing output:"wear"programs now carryG41where they carriedG42(and the reverse); nothing else in them changes.Evidence
Tested commit
5b7d7d85ee7cd7761c8d3db2c21743b2fb5f17d1(clean tree; the pushed head), Linux x86_64 (kernel 6.8, Ubuntu), rustc 1.98.1, CPython 3.12.3:cargo fmt --check;ruff check python examples bench;ruff format --check python examples benchcargo clippy --workspace --all-targets --all-features -- -D warningsneedless_range_loopinsrc/surface/spline_bounds.rs:95-96, a file this PR does not touch (the same onmain), so the full lint was run with-A clippy::needless_range_loopcargo test --profile ci --workspace --all-features --lib --tests(the CI test profile: release optimisation without LTO; the release-profile integration binary was OOM-killed at a 9 GB limit on this 15 GB host)cargo test --release --doctests/thermal_control.rs(3),controller_offsetunit tests (3)main(no"control"; wear test:G42)PYTHONPATH=python python -m unittest discover -s python/testsmain); 58 skipped.python/tests/test_thermal_control.py(5) passedexamples/standalone_job.pyin a fresh directory with a spaceexamples/cadquery_job.pynot run (no CadQuery)main(dde509b) and from this branch: WinCNC plasma"computer"in inch and mm, both directions; default post (LinuxCNC dialect, beam)"computer"and"wear", both directions"computer": byte-identical."wear": identical exceptG42 D1->G41 D1(andG41->G42reversed), the side fix belowExample
A 100 x 60 mm plate with a 20 mm hole, kerf 1.6 mm, WinCNC plasma post with
start_code=None, local_coordinates="keep", M61/M62, end M66, inch at 4 decimals,control_kerf="g41":With
control_kerf="material"the program is the same less the four compensation blocks (G41 O0.0315andG40, twice; the header'sG40stays):python/tests/test_thermal_control.pychecks exactly that.Where the proposal was changed, with the evidence
radius_mm > 0), not only a straight part: with the straight lead meeting the cut at a corner, where a controller ends its start-up move differs between controllers (perpendicular to the entry or to the next move), and WinCNC does not document it.Benchmarks
Release build, sequential, this host:
python bench/run.py --label t384 --only plasma plasma-common-line plasma-edge-starts, thenpython bench/compare.py bench/expectations bench/results/t384.json: no toolpath change for any ThermalCut workload (the only rows are the other workloads, not measured in this run). numpy was supplied from a scratch directory for the runner; the CAD workloads were not run (no CadQuery). No workload was added for"control": it is a posting mode ofThermalCut, covered by the tests above.Not done
cam-post) refuses"control": only a Python post withcompensation_amount_wordwrites it.🤖 Generated with Claude Code