1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 13:56:24 +00:00

Fix broken reverse planner (#9914)

See MarlinFirmware/Marlin#9913 for details.
This commit is contained in:
Sebastianv650 2018-03-05 04:18:35 +01:00 committed by Scott Lahteine
parent 081ab35e82
commit bc08ce86be
2 changed files with 15 additions and 17 deletions

View File

@ -278,18 +278,26 @@ void Planner::reverse_pass_kernel(block_t* const current, const block_t * const
* Once in reverse and once forward. This implements the reverse pass.
*/
void Planner::reverse_pass() {
if (movesplanned() > 3) {
const uint8_t endnr = BLOCK_MOD(block_buffer_tail + 2); // tail is running. tail+1 shouldn't be altered because it's connected to the running block.
// tail+2 because the index is not yet advanced when checked
if (movesplanned() > 2) {
const uint8_t endnr = BLOCK_MOD(block_buffer_tail + 1); // tail is running. tail+1 shouldn't be altered because it's connected to the running block.
uint8_t blocknr = prev_block_index(block_buffer_head);
block_t* current = &block_buffer[blocknr];
// Last/newest block in buffer:
const float max_entry_speed = current->max_entry_speed;
if (current->entry_speed != max_entry_speed) {
// If nominal length true, max junction speed is guaranteed to be reached. Only compute
// for max allowable speed if block is decelerating and nominal length is false.
current->entry_speed = TEST(current->flag, BLOCK_BIT_NOMINAL_LENGTH)
? max_entry_speed
: min(max_entry_speed, max_allowable_speed(-current->acceleration, MINIMUM_PLANNER_SPEED, current->millimeters));
SBI(current->flag, BLOCK_BIT_RECALCULATE);
}
do {
const block_t * const next = current;
blocknr = prev_block_index(blocknr);
current = &block_buffer[blocknr];
if (TEST(current->flag, BLOCK_BIT_START_FROM_FULL_HALT)) // Up to this every block is already optimized.
break;
reverse_pass_kernel(current, next);
} while (blocknr != endnr);
}
@ -1413,17 +1421,11 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
// Now the transition velocity is known, which maximizes the shared exit / entry velocity while
// respecting the jerk factors, it may be possible, that applying separate safe exit / entry velocities will achieve faster prints.
const float vmax_junction_threshold = vmax_junction * 0.99f;
if (previous_safe_speed > vmax_junction_threshold && safe_speed > vmax_junction_threshold) {
// Not coasting. The machine will stop and start the movements anyway,
// better to start the segment from start.
SBI(block->flag, BLOCK_BIT_START_FROM_FULL_HALT);
if (previous_safe_speed > vmax_junction_threshold && safe_speed > vmax_junction_threshold)
vmax_junction = safe_speed;
}
}
else {
SBI(block->flag, BLOCK_BIT_START_FROM_FULL_HALT);
else
vmax_junction = safe_speed;
}
// Max entry speed of this block equals the max exit speed of the previous block.
block->max_entry_speed = vmax_junction;

View File

@ -49,9 +49,6 @@ enum BlockFlagBit {
// from a safe speed (in consideration of jerking from zero speed).
BLOCK_BIT_NOMINAL_LENGTH,
// Start from a halt at the start of this block, respecting the maximum allowed jerk.
BLOCK_BIT_START_FROM_FULL_HALT,
// The block is busy
BLOCK_BIT_BUSY,
@ -62,7 +59,6 @@ enum BlockFlagBit {
enum BlockFlag {
BLOCK_FLAG_RECALCULATE = _BV(BLOCK_BIT_RECALCULATE),
BLOCK_FLAG_NOMINAL_LENGTH = _BV(BLOCK_BIT_NOMINAL_LENGTH),
BLOCK_FLAG_START_FROM_FULL_HALT = _BV(BLOCK_BIT_START_FROM_FULL_HALT),
BLOCK_FLAG_BUSY = _BV(BLOCK_BIT_BUSY),
BLOCK_FLAG_CONTINUED = _BV(BLOCK_BIT_CONTINUED)
};