Route exclusion travels at planned lift height

This commit is contained in:
Harry Loud committed 2026-09-14 12:27:34 +01:00
1 parent 7ad51860af
commit 5ec9169bc7
3 files changed
+29 -4

No files matched your search

+13 -4
View File
@@ -9044,16 +9044,25 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
};
const auto route_around_exclusion_volumes = [&](
Polyline &path,
const std::optional<double> &start_z_override) {
const std::optional<double> &start_z_override,
const bool include_planned_lift = false) {
if (m_exclusion_volume_travel_avoidance.empty() || path.size() < 2)
return false;
const double target_z = z == DBL_MAX ? m_nominal_z : z;
double route_start_z = start_z_override.value_or(nominal_writer_z());
double route_end_z = target_z;
if (include_planned_lift) {
const Vec2d destination_xy = this->point_to_gcode(path.back());
std::tie(route_start_z, route_end_z) = m_writer.planned_travel_z(
Vec3d(destination_xy.x(), destination_xy.y(), target_z),
m_need_change_layer_lift_z);
}
const ExclusionVolumeTravelAvoidance::Result result =
m_exclusion_volume_travel_avoidance.route(
to_gcode_polyline(path),
start_z_override.value_or(nominal_writer_z()),
target_z,
route_start_z,
route_end_z,
active_extruder_id());
if (!result.rerouted())
return false;
@@ -9162,7 +9171,7 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
}
exclusion_volume_travel_rerouted =
route_around_exclusion_volumes(travel, std::nullopt) ||
route_around_exclusion_volumes(travel, std::nullopt, true) ||
(last_post_before_retract == this->last_pos() && exclusion_volume_travel_rerouted);
} else {
// Reset the wipe path when traveling, so one would not wipe along an old path.
+13
View File
@@ -971,6 +971,19 @@ std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &co
return out_string;
}
std::pair<double, double> GCodeWriter::planned_travel_z(const Vec3d &point, const bool force_z) const
{
double destination_z = point.z();
if (std::abs(m_to_lift) > EPSILON) {
if ((!this->is_current_position_clear() || m_pos != point) &&
m_to_lift + m_pos.z() > point.z())
destination_z = m_to_lift + m_pos.z();
} else if (!force_z && !this->will_move_z(point.z())) {
destination_z = m_pos.z();
}
return { m_pos.z(), destination_z };
}
std::string GCodeWriter::travel_to_z(double z, const std::string &comment, bool force)
{
/* If target Z is lower than current Z but higher than nominal Z
+3
View File
@@ -80,6 +80,9 @@ public:
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_xyz(const Vec3d &point, const std::string &comment = std::string(), bool force_z = false);
// Physical Z range which travel_to_xyz() will emit without mutating writer state.
// This includes an existing lift or a pending lazy lift.
std::pair<double, double> planned_travel_z(const Vec3d &point, bool force_z = false) const;
std::string travel_to_z(double z, const std::string &comment = std::string(), bool force = false);
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);