Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arc printing optimisations #24366

Merged
merged 20 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@
#include "../../../MarlinCore.h"
#include <math.h>

//#define DEBUG_UBL_MOTION
#define DEBUG_OUT ENABLED(DEBUG_UBL_MOTION)
#include "../../../core/debug_out.h"

#if !UBL_SEGMENTED

// TODO: The first and last parts of a move might result in very short segment(s)
// after getting split on the cell boundary, so moves like that should not
// get split. This will be most common for moves that start/end near the
// corners of cells. To fix the issue, simply check if the start/end of the line
// is very close to a cell boundary in advance and don't split the line there.

void unified_bed_leveling::line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t extruder) {
/**
* Much of the nozzle movement will be within the same cell. So we will do as little computation
Expand Down Expand Up @@ -176,7 +186,9 @@
dest.z += z0;
planner.buffer_segment(dest, scaled_fr_mm_s, extruder);

} //else printf("FIRST MOVE PRUNED ");
}
else
DEBUG_ECHOLNPGM("[ubl] skip Y segment");
}

// At the final destination? Usually not, but when on a Y Mesh Line it's completed.
Expand Down Expand Up @@ -225,7 +237,9 @@
dest.z += z0;
if (!planner.buffer_segment(dest, scaled_fr_mm_s, extruder)) break;

} //else printf("FIRST MOVE PRUNED ");
}
else
DEBUG_ECHOLNPGM("[ubl] skip Y segment");
}

if (xy_pos_t(current_position) != xy_pos_t(end))
Expand Down
9 changes: 6 additions & 3 deletions Marlin/src/gcode/motion/G2_G3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void plan_arc(
// Compute exact location by applying transformation matrix from initial radius vector(=-offset).
// To reduce stuttering, the sin and cos could be computed at different times.
// For now, compute both at the same time.
const float cos_Ti = cos(i * theta_per_segment), sin_Ti = sin(i * theta_per_segment);
const float Ti = i * theta_per_segment, cos_Ti = cos(Ti), sin_Ti = sin(Ti);
rvec.a = -offset[0] * cos_Ti + offset[1] * sin_Ti;
rvec.b = -offset[0] * sin_Ti - offset[1] * cos_Ti;
}
Expand All @@ -342,8 +342,11 @@ void plan_arc(
planner.apply_leveling(raw);
#endif

if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)))
break;
if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, i > 1 ? radius : 0
)
) break;
}
}

Expand Down
Loading