Skip to content

exclude_object: drop the skipped-object offset after a park outside the transform (fixes #22) - #24

Draft
alandebortolo wants to merge 1 commit into
Snapmaker:mainfrom
DesignMaster-Solutions:fix-22-exclude-object-park
Draft

alandebortolo wants to merge 1 commit into
Snapmaker:mainfrom
DesignMaster-Solutions:fix-22-exclude-object-park

Conversation

@alandebortolo

@alandebortolo alandebortolo commented Nov 3, 2026 •

Copy link
Copy Markdown

Fixes #22.

While an object is skipped, exclude_object keeps a per-extruder XYZ offset (last skipped G-code position minus last printed position). The U1 pause park (MOVE_TO_DISCARD_FILAMENT_POSITION) moves the head with toolhead.manual_move(), so gcode_move resets its position through exclude_object.get_position(), which returns the parked position plus that stale offset. The next G1 that does not set both X and Y (Resume's _CLIENT_EXTRUDE, an E-only move) carries the wrong XY and is rejected with "Move out of range", or, inside the bed, travels there while extruding.

The same happens with no pause at all: the U1 tool change and the chute park are manual_moves too, and the offset that is stale there is the swapped-in tool's, from the last time it printed the skipped object. @abehrman lost two prints this way on a stock U1 (2.0.0.205): the prime after a swap went past Y max on one, and 222 mm across the part while extruding on the other (#22 (comment)).

This implements the fix @SwineFlew931 proposed in the issue: get_position() compares the position below the transform with the last one _normal_move() sent. If they differ, the head was moved outside the transform, so the XYZ offset is zeroed and the last printed position becomes the real one. The E offset is left as it was. Any manual_move (pause park, tool change, chute park) leaves those two positions different, which is why one check covers both reports.

How I tested it, without a printer. The firmware at 93cb12f runs in Klipper batch mode with the shipped lava/printer.cfg and fluidd.cfg. A file is printed through virtual_sdcard, and Pause and Resume go through the same webhook handlers Moonraker calls, with the shipped INNER_PAUSE/INNER_RESUME. Four cases: pause during the skipped layers, the end-of-print park followed by G1 E30, a park while the object is still being skipped, and a two-colour print where every swap is the U1 Orca profile's change_filament_gcode plus the chute prime (SAVE_GCODE_STATE, MOVE_TO_DISCARD_FILAMENT_POSITION, E-only prime, MOVE_TO_XY_IDLE_POSITION_EXTRUDER, RESTORE_GCODE_STATE), with one of the second tool's objects skipped.

  • 93cb12f: 4 of 4 fail. Resume and the end-of-print G1 E30 stop with Move out of range on Y axis (33.000 448.500 and 35.000 450.500); after the park inside the skipped object, the G-code position says X33 while the head is at X45; at the fifth tool change the chute GET_POSITION says toolhead X92.7 Y300.5, gcode X82.7 Y230.5, and the G1 E20 prime drags the head to X82.7 Y230.5 while extruding
  • with this patch: 4 of 4 complete; every park and all seven tool changes keep gcode equal to the toolhead
  • the two prints @abehrman lost on hardware, replayed through the same harness (his files unmodified, Skip injected at the sd_pos his klippy.log gives, GET_POSITION around every chute prime): on 93cb12f stock, the 2026-10-27 file stops at the 35th tool change with Move out of range on Y axis: 81.489 337.635 10.850 (his log: 148.989 337.635 10.874, same Y and same stale offset, X differing by his T1 chute X) and the 2026-11-01 file has no error but at the 26th tool change the chute prime moves the head to X28.113 Y202.421 while extruding (his "about (28.1, 202.4)"); with this patch 143 of 143 and 61 of 61 tool changes keep gcode equal to the toolhead and both prints end complete (tests/issue22/replay_real.py, docs/evidence/issue-22/real-print-*.txt)
  • three deliberately wrong versions of the patch fail the same test
  • same results on 7ac453b (2.1.0)

Test, fixtures and logs: https://github.com/DesignMaster-Solutions/u1-fixpack (tests/test_issue22.py, tests/prove.sh, docs/evidence/issue-22/), with CI on every push.

Draft because batch mode has no physics and no real sensors: this proves the firmware logic, not a print. I would like a run on a physical U1 before it is marked ready. The 2.1.0 release in #23 does not touch exclude_object.py, and the patch applies cleanly on it too.

Built with AI coding assistance; I reviewed and tested it.

…he transform

Fixes Snapmaker#22 (skip an object, Pause, Resume fails with
"Move out of range").

While an object is skipped, exclude_object keeps a per-extruder offset:
last skipped G-code position minus last printed position. The U1 pause park
(MOVE_TO_DISCARD_FILAMENT_POSITION) moves the head with toolhead.manual_move(),
so gcode_move resets its position through exclude_object.get_position(), which
returns the parked position plus that stale offset. The next G1 that does not
set both X and Y (Resume's _CLIENT_EXTRUDE, an E-only move) carries the wrong
XY and is rejected, or, inside the bed, travels there while extruding.

get_position() now compares the position below the transform with the last
one _normal_move() sent. If they differ, the head was moved outside the
transform, so the XYZ offset is zeroed and the last printed position becomes
the real one. The E offset is left as it was.

Diagnosis and the suggested fix are from the issue's reporter; this patch
implements that suggestion. Regression test: tests/test_issue22.py (red on 93cb12f, green with this patch) in
github.com/DesignMaster-Solutions/u1-fixpack.
@alandebortolo

Copy link
Copy Markdown
Author

Re-checked on 2.1.0 now that it is on main (7ac453b, which does not touch exclude_object.py). Stock 2.1.0 fails the same 3 cases as 2.0.0: Resume and the end-of-print G1 E30 still stop with Move out of range on Y axis, and after a park inside the skipped object the reported position is still off by the object's offset. With this change, unmodified, 3 of 3 pass, and the 3 deliberately wrong variants still fail.

Output of that run, with the firmware commit at the top of each file: https://github.com/DesignMaster-Solutions/u1-fixpack/tree/main/docs/evidence/2.1.0/issue-22 (CI now runs it on both 2.0.0 and 2.1.0: https://github.com/DesignMaster-Solutions/u1-fixpack/actions/runs/41927199144).

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.

Skipping an object, then pausing, makes Resume fail with "Move out of range": exclude_object offset leaks into gcode position after the pause park

2 participants