Fix speed math for wipe, which was causing too fast retraction. Includes regression test. #1468
This commit is contained in:
parent
bc0b9e1b72
commit
4c2c31b554
3 changed files with 22 additions and 8 deletions
|
@ -41,6 +41,9 @@ sub _build_retract_speed_mm_min {
|
|||
|
||||
sub _build_scaled_wipe_distance {
|
||||
my $self = shift;
|
||||
|
||||
# how far do we move in XY at travel_speed for the time needed to consume
|
||||
# retract_length at retract_speed?
|
||||
# reduce feedrate a bit; travel speed is often too high to move on existing material
|
||||
# too fast = ripping of existing material; too slow = short wipe path, thus more blob
|
||||
return scale($self->retract_length / $self->retract_speed * $Slic3r::Config->travel_speed * 0.8);
|
||||
|
|
|
@ -485,19 +485,23 @@ sub retract {
|
|||
: [undef, $self->z + $self->extruder->retract_lift, 0, 'lift plate during travel'];
|
||||
|
||||
# check that we have a positive wipe length
|
||||
if ($wipe_path && (my $total_wipe_length = $wipe_path->length)) {
|
||||
$self->speed('travel');
|
||||
if ($wipe_path) {
|
||||
$self->speed($self->speeds->{travel} * 0.8);
|
||||
|
||||
# subdivide the retraction
|
||||
my $retracted = 0;
|
||||
for (1 .. $#$wipe_path) {
|
||||
my $segment_length = $wipe_path->[$_-1]->distance_to($wipe_path->[$_]);
|
||||
$retracted += my $e = $retract->[2] * ($segment_length / $total_wipe_length);
|
||||
$gcode .= $self->G1($wipe_path->[$_], undef, $e, $retract->[3] . ";_WIPE");
|
||||
foreach my $line (@{$wipe_path->lines}) {
|
||||
my $segment_length = $line->length;
|
||||
# reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one
|
||||
# due to rounding
|
||||
my $e = $retract->[2] * ($segment_length / $self->extruder->scaled_wipe_distance) * 0.95;
|
||||
$retracted += $e;
|
||||
$gcode .= $self->G1($line->b, undef, $e, $retract->[3] . ";_WIPE");
|
||||
}
|
||||
if ($retracted > $retract->[2]) {
|
||||
# if we retracted less than we had to, retract the remainder
|
||||
# TODO: add regression test
|
||||
$self->speed('retract');
|
||||
$gcode .= $self->G1(undef, undef, $retract->[2] - $retracted, $comment);
|
||||
}
|
||||
} else {
|
||||
|
|
11
t/gcode.t
11
t/gcode.t
|
@ -1,4 +1,4 @@
|
|||
use Test::More tests => 2;
|
||||
use Test::More tests => 3;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
@ -7,6 +7,7 @@ BEGIN {
|
|||
use lib "$FindBin::Bin/../lib";
|
||||
}
|
||||
|
||||
use List::Util qw(first);
|
||||
use Slic3r;
|
||||
use Slic3r::Geometry qw(scale);
|
||||
use Slic3r::Test;
|
||||
|
@ -27,12 +28,18 @@ use Slic3r::Test;
|
|||
|
||||
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
||||
my $have_wipe = 0;
|
||||
my @retract_speeds = ();
|
||||
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
||||
my ($self, $cmd, $args, $info) = @_;
|
||||
$have_wipe = 1 if $info->{retracting} && $info->{dist_XY} > 0;
|
||||
if ($info->{retracting} && $info->{dist_XY} > 0) {
|
||||
$have_wipe = 1;
|
||||
my $move_time = $info->{dist_XY} / ($args->{F} // $self->F);
|
||||
push @retract_speeds, abs($info->{dist_E}) / $move_time;
|
||||
}
|
||||
});
|
||||
|
||||
ok $have_wipe, "wipe";
|
||||
ok !defined (first { abs($_ - $config->retract_speed->[0]*60) < 5 } @retract_speeds), 'wipe moves don\'t retract faster than configured speed';
|
||||
}
|
||||
|
||||
__END__
|
||||
|
|
Loading…
Reference in a new issue