Skip to content

AdaptivePocket: check the stock against top_z_mm (#344) - #364

Merged
10-X-eng merged 32 commits into
stevecad:mainfrom
Wookie1:adaptive-pocket-top
Nov 21, 2026
Merged

10-X-eng merged 32 commits into
stevecad:mainfrom
Wookie1:adaptive-pocket-top

Conversation

@Wookie1

@Wookie1 Wookie1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #344. Stacked on #363 (which is stacked on #362): their commits show here too, so please merge those first.

What changes

  • AdaptivePocket runs Pocket's stock-top proof (StockTop) before any motion. Stock above top_z_mm that the cutter can reach is refused; stock removed by earlier operations is accepted; stock outside the region is judged by the tool assembly. Without committed stock, a lower top is refused. The report carries stock_top.
  • stepdown_mm is a strict maximum for both Pocket and AdaptivePocket. The stock model can't tell a faced top's sweep error from material, so depths are planned from the highest reachable stock above the top inside the accepted band. Before, a top 0.1 mm below uncut stock (tolerance 0.01, stepdown 1) gave a 1.1 mm first cut. A faced top can therefore gain a last, nearly empty pass; the standalone rest example's golden program is regenerated for that.
  • A rescan that finds stock above the height the depths were planned from (same generation, foreign stock) refuses before the next motion. Lower-top plans are bound to the committed stock they were planned from.
  • The floor and allowances are checked against the authored top before a higher planning top is used, so a floor above the top stays refused.
  • Regressions in tests/pocket_top.rs cover the refusal for AdaptivePocket and measure the depth each motion removes from the stock.

bench/results/baseline.json and docs/benchmarks.md are untouched.

Wookie1 and others added 23 commits November 18, 2026 05:45
stevecad#190)

The sampled LeadingOracle from tests/roughing.rs (no planner, prover or
stock code) now also checks AdaptivePocket's engagement_front runs: the
L pocket, both link-feed runs, the square and circular wall-pass pockets,
and the three ramp-entry runs. Every cutting and stay-down link stroke's
leading contact must stay within acos(1 - stepover / r) plus the same
3 degree sampling slack the roughing test uses.

A new test checks the oracle itself: a slot through fresh stock reads the
full leading half-circle, and a pass beside a through-cut at 0.5, 1 and
1.5 mm reads acos(1 - w / r) to within its whole-degree count.

Test-only: LeadingOracle and its methods become pub(crate) so adaptive.rs
and ramp_entry_front.rs can use it; no existing assertion changes.
engagement_front is now the only adaptive planner for AdaptivePocket and
Roughing's AdaptiveClearing. The orbit planners, their options
(orbit_radius_mm, min_orbit_radius_mm, local_orbit_tolerance_mm,
boundary_tolerance_mm, AdaptivePocket's clockwise), their proofs and their
tests are removed. Their names and fields are refused when a program is
read. Tests that ran on them are converted to the engagement front where
they test more than the old planner. Regeneration now treats every
adaptive operation as reading committed clearance.
The engagement front planned its first level from the stock's top, so
with uncut stock above a lower top_z_mm that level was deeper than
stepdown_mm and nothing refused it. AdaptivePocket now runs Pocket's
stock-top proof (StockTop) before any motion, plans its levels from
top_z_mm, rescans stock it did not see committed, admits each motion
against stock left beside the region, and reports stock_top. Without
committed stock a lower top is refused.
…#344)

A top up to 16 x tolerance_mm below the stock is accepted as the stock
model's band, but Pocket and AdaptivePocket then placed their first depth
from the authored top: with tolerance 0.01 and a top 0.1 mm below uncut stock
the first motion removed 1.1 mm with a 1 mm stepdown. StockTop now reports
the highest such stock the cutter can reach, and both plan their depths from
it. Regression measures the depth each motion removes from the stock.
…stevecad#190)

The earlier serializers wrote orbit_radius_mm and its siblings (null) and
boundary_tolerance_mm, and an adaptive pocket's clockwise, for every
strategy; engagement_front never used them. A program that chose
engagement_front is read without them. One without a path_strategy was
planned by the old default, disk_front, and is refused with that reason
instead of being read as engagement_front. The regression reads the
unchanged roughing-open-block.json from before the removal.
…acing (stevecad#190)

The allowance for slivers between sampled discs used the largest sample
step for every disc. A move shorter than that step then cleared its own
leading edge from its start: a 0.1 mm straight cut in fresh stock read 179
degrees as one move and 0 as 200 moves. Each disc now carries the allowance
of its own move's spacing. New test: the same slot and side step read the
same split into one move or 200.
…tevecad#344)

Measuring the depths from any stock in the band moved them by a faced
top's sweep error (1e-5 mm) and added a redundant last pass where the depth
was an exact number of stepdowns (standalone rest example). The depths now
move only when the reachable stock is more than tolerance_mm above the top;
within it they stay where they were, and the first cut is at most a
stepdown plus that tolerance.
…ing (stevecad#344)

Depths are planned from any reachable stock above the top inside the band:
the stock model cannot tell a faced top's sweep error from material, so no
depth of cut exceeds stepdown_mm below it. A faced top can therefore gain a
last, nearly empty pass (the standalone rest example's golden program does,
regenerated). A rescan that finds stock above the top the depths were planned
from refuses before the next motion, and the floor is checked against the
authored top before a higher planning top is used.
The oracle cleared stock within an inflated radius of sampled centres, so
an unchecked lead could clear stock ahead of its own end: a 0.0005 mm cut
after a 1 mm lead read 0 degrees with the lead as one move and 179 with it
split in 2,000. It now keeps each swept piece (line or arc) and clears
exactly the points within the cutter radius of it, so the reading does not
depend on how moves are split or sampled. New test for the lead case.
@Wookie1 Wookie1 self-assigned this Nov 20, 2026
Wookie1 and others added 6 commits November 20, 2026 15:24
# Conflicts:
#	python/camlib/operations.py
#	src/adaptive.rs
#	src/roughing.rs
)

stevecad#348's corner-cap test asserts every cut stays inside the L pocket with
assert_entire_l_sweep, which this branch had removed with the orbit
planner tests. The helper is planner-independent; it is restored as on
main.
@10-X-eng

Copy link
Copy Markdown
Contributor

The rest-pocket benchmark now matches the stock-top check. The faced stock still has a positive upper height bound above the authored Z5 top. Getting to Z3 with a 1 mm maximum stepdown takes three levels. The first pocket gains 15 motions and the rest operation gains 41, bringing the workload from 130 to 186 motions and from 169 to 225 posted blocks. The certain leftover and overcut are both zero.

The added floor regression also reproduced a separate error on the submitted head. With a Z10 top, a 1 mm stepdown and a floor 0.0000000005 mm below Z8, subtracting an epsilon before rounding the layer count ended the plan at Z8. The planner now includes the final level at the requested floor. All nine stock-top tests passed together on Linux.

@10-X-eng
10-X-eng added this pull request to the merge queue Nov 21, 2026
@10-X-eng
10-X-eng removed this pull request from the merge queue due to a manual request Nov 21, 2026
@10-X-eng
10-X-eng enabled auto-merge November 21, 2026 15:45
@10-X-eng
10-X-eng added this pull request to the merge queue Nov 21, 2026
Merged via the queue into stevecad:main with commit 643c648 Nov 21, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AdaptivePocket does not check the stock against top_z_mm

2 participants