Skip to content

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

Closed

Description

@CameronBrooks11

Slice S3 of #136 — make the simulator share the single O1 motion model, closing the planner/simulator time divergence.

Problem

After S-bnd (#282) the simulator consumes the Motion IR but still runs its own hand-rolled time/tow pass that is deliberately G92-blind (if SET_POSITION: continue, marked minimal:). So PlanResultOut.timeSeconds (planner, via nominal_metrics) and SimulationResultOut.estimatedTimeSeconds (simulator) still disagree by construction across G92 (zero_axes) boundaries.

Approach

Replace the simulator's motion pass with a single call to nominal_metrics(program.moves, program.meta.mandrel_diameter) — the same G92-aware O1 model the planner uses. Motion math then lives in exactly one place; the simulator only counts (commands, moves) and derives the (now-degenerate) average_feed_rate_mmpm = distance/time*60.

  • Extend NominalMetrics with move_count (motion-producing moves, distance>0) so the simulator gets its moves count without re-deriving distance.
  • Drop the unused default_feed_rate/DEFAULT_FEED_RATE (a feed-before-set program now raises SimulationError, wrapped from nominal_metrics).
  • commands_executed = 1 + len(program.moves) (header + one per Move) — unchanged.

Acceptance

  • Simulator computes time/distance/tow solely via nominal_metrics; no motion math in simulator.py (grep).
  • NEW test: plan_wind(def).total_time_s == simulate_program(read_program(plan.commands)).estimated_time_s exactly for a G92-bearing golden (divergence closed by construction). Same for tow.
  • Regenerate the sim half of tests/sim_plot_snapshot.json (deliberate G92-aware delta: time/distance/tow shift to match the planner; commands_executed/moves stable; plot half unchanged — S4 owns the plotter G92 frame). Reviewed JSON diff.
  • test_example_goldens byte-equal (untouched) · ruff + mypy clean · no OpenAPI drift (SimulationResult shape unchanged).

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

Activity

  1. added
    python
    on Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    python

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions