mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 06:04:01 -06:00
Fix an issue that wrong z value was used if a new layer is started with wipe tower extrusions. (#6980)
… # Description This update, along with #6934, resolves the remaining issues with the wipe tower. The GCode class will no longer maintain its own Z height information (m_nominal_z). Instead, it will utilize the Z height from GCodeWriter's m_pos. This approach is less error-prone. This PR also fixes #6755. It also enforce "Enable Filament ramming" option @igiannakas It should fix the wipe tower crashing issue # Screenshots/Recordings/Graphs <!-- > Please attach relevant screenshots to showcase the UI changes. > Please attach images that can help explain the changes. --> ## Tests <!-- > Please describe the tests that you have conducted to verify the changes made in this PR. -->
This commit is contained in:
commit
ab55d4eefc
4 changed files with 24 additions and 19 deletions
|
@ -729,6 +729,8 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||||
gcode += gcodegen.writer().unlift(); // Make sure there is no z-hop (in most cases, there isn't).
|
gcode += gcodegen.writer().unlift(); // Make sure there is no z-hop (in most cases, there isn't).
|
||||||
|
|
||||||
double current_z = gcodegen.writer().get_position().z();
|
double current_z = gcodegen.writer().get_position().z();
|
||||||
|
|
||||||
|
|
||||||
if (z == -1.) // in case no specific z was provided, print at current_z pos
|
if (z == -1.) // in case no specific z was provided, print at current_z pos
|
||||||
z = current_z;
|
z = current_z;
|
||||||
|
|
||||||
|
@ -741,7 +743,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||||
|| !needs_toolchange // this is just finishing the tower with no toolchange
|
|| !needs_toolchange // this is just finishing the tower with no toolchange
|
||||||
|| is_ramming);
|
|| is_ramming);
|
||||||
|
|
||||||
if (should_travel_to_tower) {
|
if (should_travel_to_tower || gcodegen.m_need_change_layer_lift_z) {
|
||||||
// FIXME: It would be better if the wipe tower set the force_travel flag for all toolchanges,
|
// FIXME: It would be better if the wipe tower set the force_travel flag for all toolchanges,
|
||||||
// then we could simplify the condition and make it more readable.
|
// then we could simplify the condition and make it more readable.
|
||||||
gcode += gcodegen.retract();
|
gcode += gcodegen.retract();
|
||||||
|
@ -767,10 +769,10 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||||
toolchange_gcode_str = gcodegen.set_extruder(new_extruder_id, tcr.print_z); // TODO: toolchange_z vs print_z
|
toolchange_gcode_str = gcodegen.set_extruder(new_extruder_id, tcr.print_z); // TODO: toolchange_z vs print_z
|
||||||
if (gcodegen.config().enable_prime_tower) {
|
if (gcodegen.config().enable_prime_tower) {
|
||||||
deretraction_str += gcodegen.writer().travel_to_z(z, "restore layer Z");
|
deretraction_str += gcodegen.writer().travel_to_z(z, "restore layer Z");
|
||||||
Vec3d position{gcodegen.writer().get_position()};
|
Vec3d position{gcodegen.writer().get_position()};
|
||||||
position.z() = z;
|
position.z() = z;
|
||||||
gcodegen.writer().set_position(position);
|
gcodegen.writer().set_position(position);
|
||||||
deretraction_str += gcodegen.unretract();
|
deretraction_str += gcodegen.unretract();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4516,12 +4518,11 @@ std::string GCode::change_layer(coordf_t print_z)
|
||||||
comment << "move to next layer (" << m_layer_index << ")";
|
comment << "move to next layer (" << m_layer_index << ")";
|
||||||
gcode += m_writer.travel_to_z(z, comment.str());
|
gcode += m_writer.travel_to_z(z, comment.str());
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
//BBS: set m_need_change_layer_lift_z to be true so that z lift can be done in travel_to() function
|
m_need_change_layer_lift_z = true;
|
||||||
m_need_change_layer_lift_z = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_nominal_z = z;
|
m_nominal_z = z;
|
||||||
|
m_writer.get_position().z() = z;
|
||||||
|
|
||||||
// forget last wiping path as wiping after raising Z is pointless
|
// forget last wiping path as wiping after raising Z is pointless
|
||||||
// BBS. Dont forget wiping path to reduce stringing.
|
// BBS. Dont forget wiping path to reduce stringing.
|
||||||
|
@ -6005,14 +6006,15 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
|
||||||
if (m_spiral_vase) {
|
if (m_spiral_vase) {
|
||||||
// No lazy z lift for spiral vase mode
|
// No lazy z lift for spiral vase mode
|
||||||
for (size_t i = 1; i < travel.size(); ++i) {
|
for (size_t i = 1; i < travel.size(); ++i) {
|
||||||
gcode += m_writer.travel_to_xy(this->point_to_gcode(travel.points[i]), comment + " travel_to_xy");
|
gcode += m_writer.travel_to_xy(this->point_to_gcode(travel.points[i]), comment);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (travel.size() == 2) {
|
if (travel.size() == 2) {
|
||||||
// No extra movements emitted by avoid_crossing_perimeters, simply move to the end point with z change
|
// No extra movements emitted by avoid_crossing_perimeters, simply move to the end point with z change
|
||||||
const auto& dest2d = this->point_to_gcode(travel.points.back());
|
const auto& dest2d = this->point_to_gcode(travel.points.back());
|
||||||
Vec3d dest3d(dest2d(0), dest2d(1), z == DBL_MAX ? m_nominal_z : z);
|
Vec3d dest3d(dest2d(0), dest2d(1), z == DBL_MAX ? m_nominal_z : z);
|
||||||
gcode += m_writer.travel_to_xyz(dest3d, comment + " travel_to_xyz");
|
gcode += m_writer.travel_to_xyz(dest3d, comment, m_need_change_layer_lift_z);
|
||||||
|
m_need_change_layer_lift_z = false;
|
||||||
} else {
|
} else {
|
||||||
// Extra movements emitted by avoid_crossing_perimeters, lift the z to normal height at the beginning, then apply the z
|
// Extra movements emitted by avoid_crossing_perimeters, lift the z to normal height at the beginning, then apply the z
|
||||||
// ratio at the last point
|
// ratio at the last point
|
||||||
|
@ -6021,21 +6023,23 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
|
||||||
// Lift to normal z at beginning
|
// Lift to normal z at beginning
|
||||||
Vec2d dest2d = this->point_to_gcode(travel.points[i]);
|
Vec2d dest2d = this->point_to_gcode(travel.points[i]);
|
||||||
Vec3d dest3d(dest2d(0), dest2d(1), m_nominal_z);
|
Vec3d dest3d(dest2d(0), dest2d(1), m_nominal_z);
|
||||||
gcode += m_writer.travel_to_xyz(dest3d, comment + " travel_to_xyz");
|
gcode += m_writer.travel_to_xyz(dest3d, comment, m_need_change_layer_lift_z);
|
||||||
|
m_need_change_layer_lift_z = false;
|
||||||
} else if (z != DBL_MAX && i == travel.size() - 1) {
|
} else if (z != DBL_MAX && i == travel.size() - 1) {
|
||||||
// Apply z_ratio for the very last point
|
// Apply z_ratio for the very last point
|
||||||
Vec2d dest2d = this->point_to_gcode(travel.points[i]);
|
Vec2d dest2d = this->point_to_gcode(travel.points[i]);
|
||||||
Vec3d dest3d(dest2d(0), dest2d(1), z);
|
Vec3d dest3d(dest2d(0), dest2d(1), z);
|
||||||
gcode += m_writer.travel_to_xyz(dest3d, comment + " travel_to_xyz");
|
gcode += m_writer.travel_to_xyz(dest3d, comment);
|
||||||
} else {
|
} else {
|
||||||
// For all points in between, no z change
|
// For all points in between, no z change
|
||||||
gcode += m_writer.travel_to_xy(this->point_to_gcode(travel.points[i]), comment + " travel_to_xy");
|
gcode += m_writer.travel_to_xy(this->point_to_gcode(travel.points[i]), comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->set_last_pos(travel.points.back());
|
this->set_last_pos(travel.points.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1127,7 +1127,7 @@ void WipeTower2::toolchange_Load(
|
||||||
WipeTowerWriter2 &writer,
|
WipeTowerWriter2 &writer,
|
||||||
const WipeTower::box_coordinates &cleaning_box)
|
const WipeTower::box_coordinates &cleaning_box)
|
||||||
{
|
{
|
||||||
if (m_semm && (m_parking_pos_retraction != 0 || m_extra_loading_move != 0)) {
|
if (m_semm && m_enable_filament_ramming && (m_parking_pos_retraction != 0 || m_extra_loading_move != 0)) {
|
||||||
float xl = cleaning_box.ld.x() + m_perimeter_width * 0.75f;
|
float xl = cleaning_box.ld.x() + m_perimeter_width * 0.75f;
|
||||||
float xr = cleaning_box.rd.x() - m_perimeter_width * 0.75f;
|
float xr = cleaning_box.rd.x() - m_perimeter_width * 0.75f;
|
||||||
float oldx = writer.x(); // the nozzle is in place to do the first wiping moves, we will remember the position
|
float oldx = writer.x(); // the nozzle is in place to do the first wiping moves, we will remember the position
|
||||||
|
|
|
@ -440,7 +440,7 @@ std::string GCodeWriter::travel_to_xy(const Vec2d &point, const std::string &com
|
||||||
return w.string();
|
return w.string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &comment)
|
std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &comment, bool force_z)
|
||||||
{
|
{
|
||||||
// FIXME: This function was not being used when travel_speed_z was separated (bd6badf).
|
// FIXME: This function was not being used when travel_speed_z was separated (bd6badf).
|
||||||
// Calculation of feedrate was not updated accordingly. If you want to use
|
// Calculation of feedrate was not updated accordingly. If you want to use
|
||||||
|
@ -526,7 +526,7 @@ std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &co
|
||||||
this->set_current_position_clear(true);
|
this->set_current_position_clear(true);
|
||||||
return slop_move + xy_z_move;
|
return slop_move + xy_z_move;
|
||||||
}
|
}
|
||||||
else if (!this->will_move_z(point(2))) {
|
else if (!force_z && !this->will_move_z(point(2))) {
|
||||||
double nominal_z = m_pos(2) - m_lifted;
|
double nominal_z = m_pos(2) - m_lifted;
|
||||||
m_lifted -= (point(2) - nominal_z);
|
m_lifted -= (point(2) - nominal_z);
|
||||||
// In case that z_hop == layer_height we could end up with almost zero in_m_lifted
|
// In case that z_hop == layer_height we could end up with almost zero in_m_lifted
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
// SoftFever NOTE: the returned speed is mm/minute
|
// SoftFever NOTE: the returned speed is mm/minute
|
||||||
double get_current_speed() const { return m_current_speed;}
|
double get_current_speed() const { return m_current_speed;}
|
||||||
std::string travel_to_xy(const Vec2d &point, const std::string &comment = std::string());
|
std::string travel_to_xy(const Vec2d &point, const std::string &comment = std::string());
|
||||||
std::string travel_to_xyz(const Vec3d &point, const std::string &comment = std::string());
|
std::string travel_to_xyz(const Vec3d &point, const std::string &comment = std::string(), bool force_z = false);
|
||||||
std::string travel_to_z(double z, const std::string &comment = std::string());
|
std::string travel_to_z(double z, const std::string &comment = std::string());
|
||||||
bool will_move_z(double z) const;
|
bool will_move_z(double z) const;
|
||||||
std::string extrude_to_xy(const Vec2d &point, double dE, const std::string &comment = std::string(), bool force_no_extrusion = false);
|
std::string extrude_to_xy(const Vec2d &point, double dE, const std::string &comment = std::string(), bool force_no_extrusion = false);
|
||||||
|
@ -81,7 +81,8 @@ public:
|
||||||
std::string unretract();
|
std::string unretract();
|
||||||
std::string lift(LiftType lift_type = LiftType::NormalLift, bool spiral_vase = false);
|
std::string lift(LiftType lift_type = LiftType::NormalLift, bool spiral_vase = false);
|
||||||
std::string unlift();
|
std::string unlift();
|
||||||
Vec3d get_position() const { return m_pos; }
|
const Vec3d& get_position() const { return m_pos; }
|
||||||
|
Vec3d& get_position() { return m_pos; }
|
||||||
void set_position(const Vec3d& in) { m_pos = in; }
|
void set_position(const Vec3d& in) { m_pos = in; }
|
||||||
double get_zhop() const { return m_lifted; }
|
double get_zhop() const { return m_lifted; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue