Fix initial safe_speed in jerk code (#11396)

This commit is contained in:
Scott Lahteine 2018-07-30 22:49:20 -05:00 committed by GitHub
parent 33c37d587d
commit c4f4c255b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2279,27 +2279,27 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
/** /**
* Adapted from Průša MKS firmware * Adapted from Průša MKS firmware
* https://github.com/prusa3d/Prusa-Firmware * https://github.com/prusa3d/Prusa-Firmware
*
* Start with a safe speed (from which the machine may halt to stop immediately).
*/ */
const float nominal_speed = SQRT(block->nominal_speed_sqr);
// Exit speed limited by a jerk to full halt of a previous last segment // Exit speed limited by a jerk to full halt of a previous last segment
static float previous_safe_speed; static float previous_safe_speed;
const float nominal_speed = SQRT(block->nominal_speed_sqr); // Start with a safe speed (from which the machine may halt to stop immediately).
float safe_speed = nominal_speed; float safe_speed = nominal_speed;
uint8_t limited = 0; uint8_t limited = 0;
LOOP_XYZE(i) { LOOP_XYZE(i) {
const float jerk = ABS(current_speed[i]), maxj = max_jerk[i]; const float jerk = ABS(current_speed[i]), // cs : Starting from zero, change in speed for this axis
if (jerk > maxj) { maxj = max_jerk[i]; // mj : The max jerk setting for this axis
if (limited) { if (jerk > maxj) { // cs > mj : New current speed too fast?
const float mjerk = maxj * nominal_speed; if (limited) { // limited already?
if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk; const float mjerk = nominal_speed * maxj; // ns*mj
if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk; // ns*mj/cs
} }
else { else {
++limited; safe_speed *= maxj / jerk; // Initial limit: ns*mj/cs
safe_speed = maxj; ++limited; // Initially limited
} }
} }
} }