Explorar el Código

🩹 Arc/Planner optimization followup (#24509)

tombrazier hace 2 años
padre
commit
3b4a5a1ae8
No account linked to committer's email address
Se han modificado 2 ficheros con 7 adiciones y 5 borrados
  1. 6
    4
      Marlin/src/gcode/motion/G2_G3.cpp
  2. 1
    1
      Marlin/src/module/planner.cpp

+ 6
- 4
Marlin/src/gcode/motion/G2_G3.cpp Ver fichero

294
     // An arc can always complete within limits from a speed which...
294
     // An arc can always complete within limits from a speed which...
295
     // a) is <= any configured maximum speed,
295
     // a) is <= any configured maximum speed,
296
     // b) does not require centripetal force greater than any configured maximum acceleration,
296
     // b) does not require centripetal force greater than any configured maximum acceleration,
297
-    // c) allows the print head to stop in the remining length of the curve within all configured maximum accelerations.
297
+    // c) is <= nominal speed,
298
+    // d) allows the print head to stop in the remining length of the curve within all configured maximum accelerations.
298
     // The last has to be calculated every time through the loop.
299
     // The last has to be calculated every time through the loop.
299
     const float limiting_accel = _MIN(planner.settings.max_acceleration_mm_per_s2[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]),
300
     const float limiting_accel = _MIN(planner.settings.max_acceleration_mm_per_s2[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]),
300
                 limiting_speed = _MIN(planner.settings.max_feedrate_mm_s[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]),
301
                 limiting_speed = _MIN(planner.settings.max_feedrate_mm_s[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]),
301
-                limiting_speed_sqr = _MIN(sq(limiting_speed), limiting_accel * radius);
302
+                limiting_speed_sqr = _MIN(sq(limiting_speed), limiting_accel * radius, sq(scaled_fr_mm_s));
302
     float arc_mm_remaining = flat_mm;
303
     float arc_mm_remaining = flat_mm;
303
 
304
 
304
     for (uint16_t i = 1; i < segments; i++) { // Iterate (segments-1) times
305
     for (uint16_t i = 1; i < segments; i++) { // Iterate (segments-1) times
357
 
358
 
358
       // calculate safe speed for stopping by the end of the arc
359
       // calculate safe speed for stopping by the end of the arc
359
       arc_mm_remaining -= segment_mm;
360
       arc_mm_remaining -= segment_mm;
360
-
361
-      hints.curve_radius = i > 1 ? radius : 0;
362
       hints.safe_exit_speed_sqr = _MIN(limiting_speed_sqr, 2 * limiting_accel * arc_mm_remaining);
361
       hints.safe_exit_speed_sqr = _MIN(limiting_speed_sqr, 2 * limiting_accel * arc_mm_remaining);
363
 
362
 
364
       if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints))
363
       if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints))
365
         break;
364
         break;
365
+
366
+      hints.curve_radius = radius;
366
     }
367
     }
367
   }
368
   }
368
 
369
 
383
   #endif
384
   #endif
384
 
385
 
385
   hints.curve_radius = 0;
386
   hints.curve_radius = 0;
387
+  hints.safe_exit_speed_sqr = 0.0f;
386
   planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints);
388
   planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints);
387
 
389
 
388
   #if ENABLED(AUTO_BED_LEVELING_UBL)
390
   #if ENABLED(AUTO_BED_LEVELING_UBL)

+ 1
- 1
Marlin/src/module/planner.cpp Ver fichero

806
     float accelerate_steps_float = (nominal_rate_sq - sq(float(initial_rate))) * (0.5f / accel);
806
     float accelerate_steps_float = (nominal_rate_sq - sq(float(initial_rate))) * (0.5f / accel);
807
     accelerate_steps = CEIL(accelerate_steps_float);
807
     accelerate_steps = CEIL(accelerate_steps_float);
808
     const float decelerate_steps_float = (nominal_rate_sq - sq(float(final_rate))) * (0.5f / accel);
808
     const float decelerate_steps_float = (nominal_rate_sq - sq(float(final_rate))) * (0.5f / accel);
809
-    decelerate_steps = decelerate_steps_float;
809
+    decelerate_steps = FLOOR(decelerate_steps_float);
810
 
810
 
811
     // Steps between acceleration and deceleration, if any
811
     // Steps between acceleration and deceleration, if any
812
     plateau_steps -= accelerate_steps + decelerate_steps;
812
     plateau_steps -= accelerate_steps + decelerate_steps;

Loading…
Cancelar
Guardar