Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/python/common/hal_glib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,14 @@ def get_position(self):
u -= self.stat.g92_offset[6]
v -= self.stat.g92_offset[7]
w -= self.stat.g92_offset[8]
# the tilted work plane sits inside G92
if getattr(self.stat, 'g68_active', 0):
r = self.stat.g68_rotation
o = self.stat.g68_offset
x, y, z = x - o[0], y - o[1], z - o[2]
x, y, z = (r[0] * x + r[3] * y + r[6] * z,
r[1] * x + r[4] * y + r[7] * z,
r[2] * x + r[5] * y + r[8] * z)

relp = [x, y, z, a, b, c, u, v, w]
return p,relp,dtg
Expand Down
8 changes: 8 additions & 0 deletions lib/python/gladevcp/drowidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ def position(self):
u -= self.status.g92_offset[6]
v -= self.status.g92_offset[7]
w -= self.status.g92_offset[8]
# the tilted work plane sits inside G92
if getattr(self.status, 'g68_active', 0):
r = self.status.g68_rotation
o = self.status.g68_offset
x, y, z = x - o[0], y - o[1], z - o[2]
x, y, z = (r[0] * x + r[3] * y + r[6] * z,
r[1] * x + r[4] * y + r[7] * z,
r[2] * x + r[5] * y + r[8] * z)

relp = [x, y, z, a, b, c, u, v, w]
if self.display_units_mm != self.machine_units_mm:
Expand Down
20 changes: 13 additions & 7 deletions lib/python/preview_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
# (issue #269), M2, which blanks the next preview, and M6 or M61, which has
# no Q to restate. Cutter radius compensation (gcodes[4]) is left out, because
# the blocks after it would be refused while it is on. The tool length offset
# (gcodes[9]) and the tilted work plane (gcodes[12]) are restated with their
# values instead.
MODAL_GCODES = (3, 6, 14, 7, 5, 10, 16, 8, 11, 13, 15)
# (gcodes[9]), the tilted work plane (gcodes[12]) and the G92 offsets
# (gcodes[16]) are restated with their values instead.
MODAL_GCODES = (3, 6, 14, 7, 5, 10, 8, 11, 13, 15)
MODAL_MCODES = (2, 4, 5, 6, 7, 8, 9)

def preview_initcodes(s, inifile):
"""The machine's state as G-code for a preview interpreter to start
from: the startup code, the units, the tilted work plane, the tool
in the spindle, the position, the active modes and the tool length
offset in force."""
from: the startup code, the units, the G92 offsets, the tilted work
plane, the tool in the spindle, the position, the active modes and the
tool length offset in force."""
wrapped = axis_kinds.wrapped(inifile)
s.poll()
codes = []
Expand All @@ -26,12 +26,18 @@ def preview_initcodes(s, inifile):
if startup:
codes.append(startup)
codes.append("G%d" % (20 + (s.linear_units == 1)))
axes = [(i, "XYZABCUVW"[i]) for i in range(9) if s.axis_mask & (1 << i)]
# The G92 offsets as G52 sets them, by value: the startup code may clear
# them, and G92.3 would take them from the preview's parameters. They
# come in machine units, ahead of the plane, which sits inside them and
# refuses a change to them
if any(s.g92_offset[i] for i, axis in axes):
codes.append("G52" + "".join(" %s%.12f" % (axis, s.g92_offset[i]) for i, axis in axes))
plane = workplane_code(s)
if plane:
codes.append(plane)
codes.append("G90")
codes.append("T%d M6" % s.tool_in_spindle)
axes = [(i, "XYZABCUVW"[i]) for i in range(9) if s.axis_mask & (1 << i)]
position = "G53 G0"
for i, axis in axes:
pos = s.position[i] % 360.0 if wrapped[i] else s.position[i]
Expand Down
2 changes: 2 additions & 0 deletions tests/workplane-preview/expected
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ composed then G68.4: same end
gimbal: same end
no plane: preview line 1: G68.4 needs an active tilted work plane to build on; machine: G68.4 needs an active tilted work plane to build on
unfinished MDI sequence: same end
G52: same end
G52 and a plane: same end
4 changes: 4 additions & 0 deletions tests/workplane-preview/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,8 @@ def case(name, prog, *setup):
case("gimbal", "move.ngc", "G20", "G68.2 P1 X0.5 Y0.2 Z0.1 I20 J90 K30")
case("no plane", "compose.ngc", "G20")
case("unfinished MDI sequence", "move.ngc", "G20", "G68.2 P2 Q1 X0 Y0 Z0")
# G52 offsets reach the preview by value, under a plane as without one
case("G52", "move.ngc", "G21", "G52 X3 Y-2 Z7")
case("G52 and a plane", "move.ngc", "G21", "G52 X3 Y-2 Z7", "G68.2 X10 Y20 Z5 I10 J20 K30")
mdi("G69", "G52 X0 Y0 Z0")
c.state(linuxcnc.STATE_OFF)
Loading