Overhaul of the planner (#11578)
- Move FWRETRACT to the planner - Combine leveling, skew, etc. in a single modifier method - Have kinematic and non-kinematic moves call one planner method
This commit is contained in:
		
				
					committed by
					
						
						Scott Lahteine
					
				
			
			
				
	
			
			
			
						parent
						
							8323a08642
						
					
				
				
					commit
					c437bb08f1
				
			@@ -35,10 +35,6 @@
 | 
			
		||||
  #include "../../module/scara.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if HAS_FEEDRATE_SCALING && ENABLED(AUTO_BED_LEVELING_BILINEAR)
 | 
			
		||||
  #include "../../feature/bedlevel/abl/abl.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if N_ARC_CORRECTION < 1
 | 
			
		||||
  #undef N_ARC_CORRECTION
 | 
			
		||||
  #define N_ARC_CORRECTION 1
 | 
			
		||||
@@ -139,20 +135,12 @@ void plan_arc(
 | 
			
		||||
 | 
			
		||||
  const float fr_mm_s = MMS_SCALED(feedrate_mm_s);
 | 
			
		||||
 | 
			
		||||
  millis_t next_idle_ms = millis() + 200UL;
 | 
			
		||||
 | 
			
		||||
  #if HAS_FEEDRATE_SCALING
 | 
			
		||||
    // SCARA needs to scale the feed rate from mm/s to degrees/s
 | 
			
		||||
    const float inv_segment_length = 1.0f / float(MM_PER_ARC_SEGMENT),
 | 
			
		||||
                inverse_secs = inv_segment_length * fr_mm_s;
 | 
			
		||||
    float oldA = planner.position_float[A_AXIS],
 | 
			
		||||
          oldB = planner.position_float[B_AXIS]
 | 
			
		||||
          #if ENABLED(DELTA_FEEDRATE_SCALING)
 | 
			
		||||
            , oldC = planner.position_float[C_AXIS]
 | 
			
		||||
          #endif
 | 
			
		||||
          ;
 | 
			
		||||
  #if ENABLED(SCARA_FEEDRATE_SCALING)
 | 
			
		||||
    const float inv_duration = fr_mm_s / MM_PER_ARC_SEGMENT;
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  millis_t next_idle_ms = millis() + 200UL;
 | 
			
		||||
 | 
			
		||||
  #if N_ARC_CORRECTION > 1
 | 
			
		||||
    int8_t arc_recalc_count = N_ARC_CORRECTION;
 | 
			
		||||
  #endif
 | 
			
		||||
@@ -196,57 +184,32 @@ void plan_arc(
 | 
			
		||||
 | 
			
		||||
    clamp_to_software_endstops(raw);
 | 
			
		||||
 | 
			
		||||
    #if HAS_FEEDRATE_SCALING
 | 
			
		||||
      inverse_kinematics(raw);
 | 
			
		||||
      ADJUST_DELTA(raw);
 | 
			
		||||
    #if HAS_LEVELING && !PLANNER_LEVELING
 | 
			
		||||
      planner.apply_leveling(raw);
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
    #if ENABLED(SCARA_FEEDRATE_SCALING)
 | 
			
		||||
      // For SCARA scale the feed rate from mm/s to degrees/s
 | 
			
		||||
      // i.e., Complete the angular vector in the given time.
 | 
			
		||||
      if (!planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder, MM_PER_ARC_SEGMENT))
 | 
			
		||||
        break;
 | 
			
		||||
      oldA = delta[A_AXIS]; oldB = delta[B_AXIS];
 | 
			
		||||
    #elif ENABLED(DELTA_FEEDRATE_SCALING)
 | 
			
		||||
      // For DELTA scale the feed rate from Effector mm/s to Carriage mm/s
 | 
			
		||||
      // i.e., Complete the linear vector in the given time.
 | 
			
		||||
      if (!planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], SQRT(sq(delta[A_AXIS] - oldA) + sq(delta[B_AXIS] - oldB) + sq(delta[C_AXIS] - oldC)) * inverse_secs, active_extruder, MM_PER_ARC_SEGMENT))
 | 
			
		||||
        break;
 | 
			
		||||
      oldA = delta[A_AXIS]; oldB = delta[B_AXIS]; oldC = delta[C_AXIS];
 | 
			
		||||
    #elif HAS_UBL_AND_CURVES
 | 
			
		||||
      float pos[XYZ] = { raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS] };
 | 
			
		||||
      planner.apply_leveling(pos);
 | 
			
		||||
      if (!planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], raw[E_AXIS], fr_mm_s, active_extruder, MM_PER_ARC_SEGMENT))
 | 
			
		||||
        break;
 | 
			
		||||
    #else
 | 
			
		||||
      if (!planner.buffer_line_kinematic(raw, fr_mm_s, active_extruder))
 | 
			
		||||
        break;
 | 
			
		||||
    #endif
 | 
			
		||||
    if (!planner.buffer_line(raw, fr_mm_s, active_extruder, MM_PER_ARC_SEGMENT
 | 
			
		||||
      #if ENABLED(SCARA_FEEDRATE_SCALING)
 | 
			
		||||
        , inv_duration
 | 
			
		||||
      #endif
 | 
			
		||||
    ))
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Ensure last segment arrives at target location.
 | 
			
		||||
  #if HAS_FEEDRATE_SCALING
 | 
			
		||||
    inverse_kinematics(cart);
 | 
			
		||||
    ADJUST_DELTA(cart);
 | 
			
		||||
  COPY(raw, cart);
 | 
			
		||||
 | 
			
		||||
  #if HAS_LEVELING && !PLANNER_LEVELING
 | 
			
		||||
    planner.apply_leveling(raw);
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(SCARA_FEEDRATE_SCALING)
 | 
			
		||||
    const float diff2 = HYPOT2(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB);
 | 
			
		||||
    if (diff2)
 | 
			
		||||
      planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], cart[Z_AXIS], cart[E_AXIS], SQRT(diff2) * inverse_secs, active_extruder, MM_PER_ARC_SEGMENT);
 | 
			
		||||
  #elif ENABLED(DELTA_FEEDRATE_SCALING)
 | 
			
		||||
    const float diff2 = sq(delta[A_AXIS] - oldA) + sq(delta[B_AXIS] - oldB) + sq(delta[C_AXIS] - oldC);
 | 
			
		||||
    if (diff2)
 | 
			
		||||
      planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], cart[E_AXIS], SQRT(diff2) * inverse_secs, active_extruder, MM_PER_ARC_SEGMENT);
 | 
			
		||||
  #elif HAS_UBL_AND_CURVES
 | 
			
		||||
    float pos[XYZ] = { cart[X_AXIS], cart[Y_AXIS], cart[Z_AXIS] };
 | 
			
		||||
    planner.apply_leveling(pos);
 | 
			
		||||
    planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], cart[E_AXIS], fr_mm_s, active_extruder, MM_PER_ARC_SEGMENT);
 | 
			
		||||
  #else
 | 
			
		||||
    planner.buffer_line_kinematic(cart, fr_mm_s, active_extruder);
 | 
			
		||||
  #endif
 | 
			
		||||
  planner.buffer_line(raw, fr_mm_s, active_extruder, MM_PER_ARC_SEGMENT
 | 
			
		||||
    #if ENABLED(SCARA_FEEDRATE_SCALING)
 | 
			
		||||
      , inv_duration
 | 
			
		||||
    #endif
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  COPY(current_position, cart);
 | 
			
		||||
  COPY(current_position, raw);
 | 
			
		||||
} // plan_arc
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user