Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
12d32a2b
Commit
12d32a2b
authored
Nov 05, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add home position handling to GCoder
parent
5eabffce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
7 deletions
+24
-7
gcoder.py
printrun/gcoder.py
+24
-7
No files found.
printrun/gcoder.py
View file @
12d32a2b
...
@@ -109,10 +109,15 @@ class GCode(object):
...
@@ -109,10 +109,15 @@ class GCode(object):
relative
=
False
relative
=
False
relative_e
=
False
relative_e
=
False
current_tool
=
0
current_tool
=
0
# Home position: current absolute position counted from machine origin
home_x
=
0
home_y
=
0
home_z
=
0
# Current position: current absolute position counted from machine origin
# Current position: current absolute position counted from machine origin
current_x
=
0
current_x
=
0
current_y
=
0
current_y
=
0
current_z
=
0
current_z
=
0
# For E this is the absolute position from machine start
current_e
=
0
current_e
=
0
# Offset: current offset between the machine origin and the machine current
# Offset: current offset between the machine origin and the machine current
# absolute coordinate system (as shifted by G92s)
# absolute coordinate system (as shifted by G92s)
...
@@ -122,8 +127,9 @@ class GCode(object):
...
@@ -122,8 +127,9 @@ class GCode(object):
offset_e
=
0
offset_e
=
0
# Expected behavior:
# Expected behavior:
# - G28 X => X axis is homed, offset_x <- 0, current_x <- home_x
# - G28 X => X axis is homed, offset_x <- 0, current_x <- home_x
# - G92 Xk => X axis does not move, offset_x <- current_x - k,
# - G92 Xk => X axis does not move, so current_x does not change
# current_x does not change
# and offset_x <- current_x - k,
# - absolute G1 Xk => X axis moves, current_x <- offset_x + k
# How to get...
# How to get...
# current abs X from machine origin: current_x
# current abs X from machine origin: current_x
# current abs X in machine current coordinate system: current_x - offset_x
# current abs X in machine current coordinate system: current_x - offset_x
...
@@ -141,10 +147,12 @@ class GCode(object):
...
@@ -141,10 +147,12 @@ class GCode(object):
est_layer_height
=
None
est_layer_height
=
None
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
,
home_pos
=
None
):
self
.
lines
=
[
Line
(
l2
)
for
l2
in
self
.
lines
=
[
Line
(
l2
)
for
l2
in
(
l
.
strip
()
for
l
in
data
)
(
l
.
strip
()
for
l
in
data
)
if
l2
]
if
l2
]
if
home_pos
:
self
.
home_x
,
self
.
home_y
,
self
.
home_z
=
home_pos
if
self
.
lines
:
if
self
.
lines
:
self
.
_preprocess_lines
()
self
.
_preprocess_lines
()
self
.
filament_length
=
self
.
_preprocess_extrusion
()
self
.
filament_length
=
self
.
_preprocess_extrusion
()
...
@@ -237,11 +245,20 @@ class GCode(object):
...
@@ -237,11 +245,20 @@ class GCode(object):
elif
line
.
command
==
"G28"
:
elif
line
.
command
==
"G28"
:
if
not
any
([
line
.
x
,
line
.
y
,
line
.
z
]):
if
not
any
([
line
.
x
,
line
.
y
,
line
.
z
]):
current_x
=
current_y
=
current_z
=
0
offset_x
=
offset_y
=
offset_z
=
0
current_x
=
self
.
home_x
current_y
=
self
.
home_y
current_z
=
self
.
home_z
else
:
else
:
if
line
.
x
is
not
None
:
current_x
=
0
if
line
.
x
is
not
None
:
if
line
.
y
is
not
None
:
current_y
=
0
offset_x
=
0
if
line
.
z
is
not
None
:
current_z
=
0
current_x
=
self
.
home_x
if
line
.
y
is
not
None
:
offset_y
=
0
current_y
=
self
.
home_y
if
line
.
z
is
not
None
:
offset_z
=
0
current_z
=
self
.
home_z
elif
line
.
command
==
"G92"
:
elif
line
.
command
==
"G92"
:
if
line
.
x
is
not
None
:
offset_x
=
current_x
-
line
.
x
if
line
.
x
is
not
None
:
offset_x
=
current_x
-
line
.
x
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment