按源扩展坐标偏置UVW覆盖

This commit is contained in:
cnc
2026-06-06 08:45:25 +08:00
parent 82f222ba44
commit de5f28f7ee
5 changed files with 62 additions and 31 deletions

View File

@@ -2970,29 +2970,35 @@ if not any(event["type"] == "program-end" and event["line"] == 5 for event in co
l20 = load("cnc_sim_linuxcnc_coordinate_l20.json")
if not any(
event["type"] == "set-g5x-offset" and
event["line"] == 4 and
event["line"] == 5 and
event["tool"] == 2 and
event["start"]["x"] == 4 and
event["start"]["y"] == 4 and
event["start"]["z"] == 4
event["start"]["z"] == 4 and
event["start"]["u"] == 4 and
event["start"]["v"] == 4 and
event["start"]["w"] == 4
for event in l20
):
raise SystemExit("missing G10 L20 P2 offset event after G55 selection")
if not any(event["type"] == "program-end" and event["line"] == 5 for event in l20):
if not any(event["type"] == "program-end" and event["line"] == 6 for event in l20):
raise SystemExit("missing G10 L20 program end line number")
p0 = load("cnc_sim_linuxcnc_coordinate_p0.json")
if not any(
event["type"] == "set-g5x-offset" and
event["line"] == 3 and
event["line"] == 4 and
event["tool"] == 2 and
event["start"]["x"] == 7 and
event["start"]["y"] == 8 and
event["start"]["z"] == 9
event["start"]["z"] == 9 and
event["start"]["u"] == 10 and
event["start"]["v"] == 11 and
event["start"]["w"] == 12
for event in p0
):
raise SystemExit("missing G10 L2 P0 active G55 offset event")
if not any(event["type"] == "program-end" and event["line"] == 4 for event in p0):
if not any(event["type"] == "program-end" and event["line"] == 5 for event in p0):
raise SystemExit("missing G10 P0 program end line number")
select_all = load("cnc_sim_linuxcnc_coordinate_select_all.json")
@@ -3035,20 +3041,28 @@ if not any(event["type"] == "program-end" and event["line"] == 7 for event in g9
g52_offset = load("cnc_sim_linuxcnc_g52_offset.json")
g52_states = [
(event["line"], event["start"]["x"], event["start"]["y"], event["start"]["z"])
(
event["line"],
event["start"]["x"],
event["start"]["y"],
event["start"]["z"],
event["start"]["u"],
event["start"]["v"],
event["start"]["w"],
)
for event in g52_offset
if event["type"] == "set-g92-offset" and event["line"] > 0
]
expected_g52_states = [
(2, 1, 2, 0),
(3, 1, 3, 0),
(4, 0, 0, 0),
(5, 1, 3, 0),
(6, 0, 0, 0),
(3, 1, 2, 0, 4, 5, 0),
(4, 1, 3, 0, 4, 6, 0),
(5, 0, 0, 0, 0, 0, 0),
(6, 1, 3, 0, 4, 6, 0),
(7, 0, 0, 0, 0, 0, 0),
]
if g52_states != expected_g52_states:
raise SystemExit(f"unexpected G52 shared offset sequence: {g52_states!r}")
if not any(event["type"] == "program-end" and event["line"] == 7 for event in g52_offset):
if not any(event["type"] == "program-end" and event["line"] == 8 for event in g52_offset):
raise SystemExit("missing G52 offset program end line number")
g52_xz_nurbs = load("cnc_sim_linuxcnc_g52_xz_nurbs.json")

View File

@@ -3998,29 +3998,35 @@ if not any(event["type"] == "program-end" and event["line"] == 5 for event in co
l20 = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_coordinate_l20.json").read_text())
if not any(
event["type"] == "set-g5x-offset" and
event["line"] == 4 and
event["line"] == 5 and
event["tool"] == 2 and
event["start"]["x"] == 4 and
event["start"]["y"] == 4 and
event["start"]["z"] == 4
event["start"]["z"] == 4 and
event["start"]["u"] == 4 and
event["start"]["v"] == 4 and
event["start"]["w"] == 4
for event in l20
):
raise SystemExit("missing source-linked G10 L20 P2 offset event after G55 selection")
if not any(event["type"] == "program-end" and event["line"] == 5 for event in l20):
if not any(event["type"] == "program-end" and event["line"] == 6 for event in l20):
raise SystemExit("missing source-linked G10 L20 program end line number")
p0 = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_coordinate_p0.json").read_text())
if not any(
event["type"] == "set-g5x-offset" and
event["line"] == 3 and
event["line"] == 4 and
event["tool"] == 2 and
event["start"]["x"] == 7 and
event["start"]["y"] == 8 and
event["start"]["z"] == 9
event["start"]["z"] == 9 and
event["start"]["u"] == 10 and
event["start"]["v"] == 11 and
event["start"]["w"] == 12
for event in p0
):
raise SystemExit("missing source-linked G10 L2 P0 active G55 offset event")
if not any(event["type"] == "program-end" and event["line"] == 4 for event in p0):
if not any(event["type"] == "program-end" and event["line"] == 5 for event in p0):
raise SystemExit("missing source-linked G10 P0 program end line number")
select_all = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_coordinate_select_all.json").read_text())
@@ -4063,20 +4069,28 @@ if not any(event["type"] == "program-end" and event["line"] == 7 for event in g9
g52_offset = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g52_offset.json").read_text())
g52_states = [
(event["line"], event["start"]["x"], event["start"]["y"], event["start"]["z"])
(
event["line"],
event["start"]["x"],
event["start"]["y"],
event["start"]["z"],
event["start"]["u"],
event["start"]["v"],
event["start"]["w"],
)
for event in g52_offset
if event["type"] == "set-g92-offset" and event["line"] > 0
]
expected_g52_states = [
(2, 1, 2, 0),
(3, 1, 3, 0),
(4, 0, 0, 0),
(5, 1, 3, 0),
(6, 0, 0, 0),
(3, 1, 2, 0, 4, 5, 0),
(4, 1, 3, 0, 4, 6, 0),
(5, 0, 0, 0, 0, 0, 0),
(6, 1, 3, 0, 4, 6, 0),
(7, 0, 0, 0, 0, 0, 0),
]
if g52_states != expected_g52_states:
raise SystemExit(f"unexpected source-linked G52 shared offset sequence: {g52_states!r}")
if not any(event["type"] == "program-end" and event["line"] == 7 for event in g52_offset):
if not any(event["type"] == "program-end" and event["line"] == 8 for event in g52_offset):
raise SystemExit("missing source-linked G52 offset program end line number")
g52_xz_nurbs = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g52_xz_nurbs.json").read_text())

View File

@@ -1,5 +1,6 @@
G21 G90 G17
G0 X5 Y6 Z7
G10 L20 P2 X1 Y2 Z3
(Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc convert_setup computes G10 L20 linear offsets for X/Y/Z/U/V/W from the current position.)
G0 X5 Y6 Z7 U8 V9 W10
G10 L20 P2 X1 Y2 Z3 U4 V5 W6
G55
M30

View File

@@ -1,4 +1,5 @@
G21 G90 G17
(Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc convert_setup maps G10 P0 to the active coordinate system and stores U/V/W through PROGRAM_TO_USER_LEN.)
G55
G10 L2 P0 X7 Y8 Z9
G10 L2 P0 X7 Y8 Z9 U10 V11 W12
M30

View File

@@ -1,6 +1,7 @@
G21 G90 G17
G52 X1 Y2
G52 Y3
(Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc convert_axis_offsets treats G52 offsets as sticky per-axis values, including U/V/W, and G92.2/G92.3 suspend and restore #5211-#5219.)
G52 X1 Y2 U4 V5
G52 Y3 V6
G92.2
G92.3
G92.1