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
46379470
Commit
46379470
authored
Jul 28, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve print duration estimation by taking direction into account
parent
c138af26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
gcoder.py
printrun/gcoder.py
+23
-6
No files found.
printrun/gcoder.py
View file @
46379470
...
@@ -398,12 +398,14 @@ class GCode(object):
...
@@ -398,12 +398,14 @@ class GCode(object):
self
.
height
=
self
.
zmax
-
self
.
zmin
self
.
height
=
self
.
zmax
-
self
.
zmin
def
estimate_duration
(
self
):
def
estimate_duration
(
self
):
lastx
=
lasty
=
laste
=
lastf
=
0.0
lastx
=
lasty
=
lastz
=
laste
=
lastf
=
0.0
lastdx
=
0
lastdy
=
0
x
=
y
=
e
=
f
=
0.0
x
=
y
=
e
=
f
=
0.0
currenttravel
=
0.0
currenttravel
=
0.0
moveduration
=
0.0
moveduration
=
0.0
totalduration
=
0.0
totalduration
=
0.0
acceleration
=
1500.0
# mm/s/s ASSUMING THE DEFAULT FROM SPRINTER !!!
acceleration
=
2000.0
# mm/s^2
layerbeginduration
=
0.0
layerbeginduration
=
0.0
#TODO:
#TODO:
# get device caps from firmware: max speed, acceleration/axis
# get device caps from firmware: max speed, acceleration/axis
...
@@ -422,6 +424,7 @@ class GCode(object):
...
@@ -422,6 +424,7 @@ class GCode(object):
else
:
else
:
x
=
line
.
x
if
line
.
x
is
not
None
else
lastx
x
=
line
.
x
if
line
.
x
is
not
None
else
lastx
y
=
line
.
y
if
line
.
y
is
not
None
else
lasty
y
=
line
.
y
if
line
.
y
is
not
None
else
lasty
z
=
line
.
z
if
line
.
z
is
not
None
else
lastz
e
=
line
.
e
if
line
.
e
is
not
None
else
laste
e
=
line
.
e
if
line
.
e
is
not
None
else
laste
# mm/s vs mm/m => divide by 60
# mm/s vs mm/m => divide by 60
f
=
line
.
f
/
60.0
if
line
.
f
is
not
None
else
lastf
f
=
line
.
f
/
60.0
if
line
.
f
is
not
None
else
lastf
...
@@ -438,10 +441,20 @@ class GCode(object):
...
@@ -438,10 +441,20 @@ class GCode(object):
# subsquent moves are in opposite directions, as requested
# subsquent moves are in opposite directions, as requested
# speed is constant but printer has to fully decellerate
# speed is constant but printer has to fully decellerate
# and reaccelerate
# and reaccelerate
# The following code tries to fix it by forcing a full
currenttravel
=
math
.
hypot
(
x
-
lastx
,
y
-
lasty
)
# reacceleration if this move is in the opposite direction
if
currenttravel
==
0
and
line
.
e
is
not
None
:
# of the previous one
currenttravel
=
abs
(
line
.
e
)
if
line
.
relative_e
else
abs
(
line
.
e
-
laste
)
dx
=
x
-
lastx
dy
=
y
-
lasty
if
dx
*
lastdx
+
dy
*
lastdy
<=
0
:
lastf
=
0
currenttravel
=
math
.
hypot
(
dx
,
dy
)
if
currenttravel
==
0
:
if
line
.
z
is
not
None
:
currenttravel
=
abs
(
line
.
z
)
if
line
.
relative
else
abs
(
line
.
z
-
lastz
)
elif
line
.
e
is
not
None
:
currenttravel
=
abs
(
line
.
e
)
if
line
.
relative_e
else
abs
(
line
.
e
-
laste
)
# Feedrate hasn't changed, no acceleration/decceleration planned
# Feedrate hasn't changed, no acceleration/decceleration planned
if
f
==
lastf
:
if
f
==
lastf
:
moveduration
=
currenttravel
/
f
if
f
!=
0
else
0.
moveduration
=
currenttravel
/
f
if
f
!=
0
else
0.
...
@@ -458,10 +471,14 @@ class GCode(object):
...
@@ -458,10 +471,14 @@ class GCode(object):
# FIXME: probably a little bit optimistic, but probably a much better estimate than the previous one:
# FIXME: probably a little bit optimistic, but probably a much better estimate than the previous one:
# moveduration = math.sqrt(2 * distance / acceleration) # probably buggy : not taking actual travel into account
# moveduration = math.sqrt(2 * distance / acceleration) # probably buggy : not taking actual travel into account
lastdx
=
dx
lastdy
=
dy
totalduration
+=
moveduration
totalduration
+=
moveduration
lastx
=
x
lastx
=
x
lasty
=
y
lasty
=
y
lastz
=
z
laste
=
e
laste
=
e
lastf
=
f
lastf
=
f
...
...
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