Skip to content

refactor(simulation): adopt the single O1 nominal_metrics; close the planner/sim divergence (S3) - #285

Merged
CameronBrooks11 merged 1 commit into
mainfrom
refactor/motion-ir-sim-metrics
Jun 28, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
refactor/motion-ir-sim-metrics

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

S3 of #136 — closes #284.

The simulator now derives time/tow from nominal_metrics (the same G92-aware O1 model the planner uses) instead of its own hand-rolled, G92-blind pass. Motion math lives in one place — simulator.py has zero motion math now (grep: no sqrt/arc). The historical planner/simulator divergence is closed by construction.

The proof

New test_planner_and_simulator_time_agree_by_construction: plan_wind(def).total_time_s == simulate_program(read_program(plan.commands)).estimated_time_s (rel 1e-7 — the only residual is G-code emitted-precision rounding; the planner reports full-precision floats).

Reviewable delta — sim half of sim_plot_snapshot.json regenerated

G92-aware time/distance/tow drop to match the planner (e.g. multi_layer 1733.98s → 905.47s = the planner total). commands_executed and average_feed_rate_mmpm are stable; the plot half is untouched (the plotter G92 frame is S4).

Other

  • NominalMetrics gains move_count so the simulator's moves needs no separate distance pass.
  • Dropped the unused default_feed_rate/DEFAULT_FEED_RATE.
  • SimulationResult shape unchanged → no OpenAPI drift; example G-code byte-equal; 153 passed; ruff/format/mypy clean.

Part of #136. Follows S-bnd (#282/#283); precedes S4 (plotter geometry) and S5 (cleanup).

…divergence

The simulator now derives time/tow from `nominal_metrics` — the same G92-aware O1
model the planner uses — instead of its own hand-rolled, G92-blind pass. Motion
math lives in exactly one place; the simulator only counts commands and reports
the shared metrics, so `PlanResultOut.timeSeconds` and
`SimulationResultOut.estimatedTimeSeconds` agree by construction (up to G-code
emitted-precision rounding, asserted by a new planner/simulator agreement test).

`NominalMetrics` gains `move_count` (motion-producing moves) so the simulator's
`moves` count needs no separate distance pass. The unused `default_feed_rate`/
`DEFAULT_FEED_RATE` are dropped (a feed-before-set program now raises
SimulationError, wrapped from nominal_metrics).

The sim half of `sim_plot_snapshot.json` is regenerated: estimated time / distance
/ tow drop to the G92-aware values (e.g. multi_layer 1733.98s -> 905.47s, matching
the planner total); `commands_executed` and `average_feed_rate_mmpm` are stable and
the plot half is untouched (the plotter G92 frame is S4). SimulationResult shape is
unchanged (no OpenAPI drift); example G-code stays byte-equal.

Closes #284. Part of #136.
@CameronBrooks11
CameronBrooks11 merged commit 64f49cb into main Jun 28, 2026
21 checks passed
@CameronBrooks11
CameronBrooks11 deleted the refactor/motion-ir-sim-metrics branch June 28, 2026 15:37
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.

S3 — simulator shares the single O1 nominal_metrics; close the planner/sim divergence

1 participant