diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index e6eec0de63fd..9fa2257dc8a6 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -36,8 +36,18 @@ #include "../../../MarlinCore.h" #include +//#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 @@ -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. @@ -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)) diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index e7889f391840..ade014fcea99 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -343,8 +343,10 @@ void plan_arc( #endif if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 - OPTARG(SCARA_FEEDRATE_SCALING, inv_duration), i > 1 ? radius : 0.0)) - break; + OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) + , i > 1 ? radius : 0 + ) + ) break; } } diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 33a0edc700b7..e1f689471f0c 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1782,7 +1782,7 @@ void Planner::synchronize() { while (busy()) idle(); } bool Planner::_buffer_steps(const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters + , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ OPTARG(ARC_SUPPORT, const_float_t arc_radius/*=0.0*/) ) { @@ -1797,11 +1797,12 @@ bool Planner::_buffer_steps(const xyze_long_t &target // Fill the block with the specified movement if (!_populate_block(block, false, target - OPTARG(HAS_POSITION_FLOAT, target_float) - OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) - , fr_mm_s, extruder, millimeters - OPTARG(ARC_SUPPORT, arc_radius) - )) { + OPTARG(HAS_POSITION_FLOAT, target_float) + OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) + , fr_mm_s, extruder, millimeters + OPTARG(ARC_SUPPORT, arc_radius) + ) + ) { // Movement was not queued, probably because it was too short. // Simply accept that as movement queued and done return true; @@ -1859,36 +1860,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move, ); /* <-- add a slash to enable - SERIAL_ECHOLNPGM( - " _populate_block FR:", fr_mm_s, - " A:", target.a, " (", da, " steps)" - #if HAS_Y_AXIS - " B:", target.b, " (", db, " steps)" - #endif - #if HAS_Z_AXIS - " C:", target.c, " (", dc, " steps)" - #endif - #if HAS_I_AXIS - " " STR_I ":", target.i, " (", di, " steps)" - #endif - #if HAS_J_AXIS - " " STR_J ":", target.j, " (", dj, " steps)" - #endif - #if HAS_K_AXIS - " " STR_K ":", target.k, " (", dk, " steps)" - #endif - #if HAS_U_AXIS - " " STR_U ":", target.u, " (", du, " steps)" - #endif - #if HAS_V_AXIS - " " STR_V ":", target.v, " (", dv, " steps)" - #endif - #if HAS_W_AXIS - " " STR_W ":", target.w, " (", dw, " steps)" - #if HAS_EXTRUDERS - " E:", target.e, " (", de, " steps)" - #endif - ); + #define _ALINE(A) " A:", target[_AXIS(A)], " (", int32_t(target[_AXIS(A)] - position[_AXIS(A)]), " steps)" + SERIAL_ECHOLNPGM(" _populate_block FR:", fr_mm_s, LOGICAL_AXIS_MAP(_ALINE)); //*/ #if EITHER(PREVENT_COLD_EXTRUSION, PREVENT_LENGTHY_EXTRUDE) @@ -2653,14 +2626,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Convert delta vector to unit vector xyze_float_t junction_unit_vec = unit_vec - prev_unit_vec; normalize_junction_vector(junction_unit_vec); + const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec); - #if ENABLED(ARC_SUPPORT) - if (arc_radius > 0.0) - vmax_junction_sqr = junction_acceleration * arc_radius; - else - #endif - { + if (TERN0(ARC_SUPPORT, arc_radius)) { + TERN_(ARC_SUPPORT, vmax_junction_sqr = junction_acceleration * arc_radius); + } + else { NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero. const float sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive.