More minor bug fixes in planner.

Reverse planner was over-writing the initial/buffer tail entry speed,
which reset the forward planner and caused it to lose track of its
speed. Should now accelerate into short linear segments much nicer now.
This commit is contained in:
Sonny J 2011-09-04 11:19:08 -06:00
parent 5e2e935bda
commit f1e5ff35ec

View File

@ -100,12 +100,13 @@ static double max_allowable_speed(double acceleration, double target_velocity, d
static void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) { static void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) {
if (!current) { return; } if (!current) { return; }
double entry_speed = current->max_entry_speed; if (previous) { // Prevent reverse planner from over-writing buffer_tail entry speed.
double entry_speed = current->max_entry_speed; // Re-write to ensure at max possible speed
double exit_speed; double exit_speed;
if (next) { if (next) {
exit_speed = next->entry_speed; exit_speed = next->entry_speed;
} else { } else {
exit_speed = 0.0; exit_speed = 0.0; // Assume last block has zero exit velocity
} }
// If the required deceleration across the block is too rapid, reduce the entry_factor accordingly. // If the required deceleration across the block is too rapid, reduce the entry_factor accordingly.
if (entry_speed > exit_speed) { if (entry_speed > exit_speed) {
@ -114,6 +115,7 @@ static void planner_reverse_pass_kernel(block_t *previous, block_t *current, blo
} }
current->entry_speed = entry_speed; current->entry_speed = entry_speed;
} }
}
// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This
@ -354,19 +356,17 @@ void plan_buffer_line(double x, double y, double z, double feed_rate, int invert
-previous->delta_mm[Z_AXIS] * block->delta_mm[Z_AXIS] )/ -previous->delta_mm[Z_AXIS] * block->delta_mm[Z_AXIS] )/
( previous->millimeters * block->millimeters ); ( previous->millimeters * block->millimeters );
// Avoid divide by zero for straight junctions around 180 degress // Avoid divide by zero for straight junctions near 180 degrees. Limit to min nominal speeds.
vmax_junction = min(previous->nominal_speed,block->nominal_speed);
if (cos_theta > -0.95) { if (cos_theta > -0.95) {
// Compute maximum junction velocity based on maximum acceleration and junction deviation // Compute maximum junction velocity based on maximum acceleration and junction deviation
double sin_theta_d2 = sqrt((1-cos_theta)/2); // Trig half angle identity double sin_theta_d2 = sqrt((1-cos_theta)/2); // Trig half angle identity
vmax_junction = vmax_junction = max(0.0, min(vmax_junction,
sqrt(settings.acceleration*60*60 * settings.junction_deviation * sin_theta_d2/(1-sin_theta_d2)); sqrt(settings.acceleration*60*60 * settings.junction_deviation * sin_theta_d2/(1-sin_theta_d2)) ) );
vmax_junction = max(0.0,min(vmax_junction, min(previous->nominal_speed,block->nominal_speed)));
} else {
vmax_junction = min(previous->nominal_speed,block->nominal_speed);
} }
} }
block->max_entry_speed = vmax_junction; block->max_entry_speed = vmax_junction;
block->entry_speed = 0.0; block->entry_speed = vmax_junction;
} else { } else {
block->initial_rate = block->nominal_rate; block->initial_rate = block->nominal_rate;
block->final_rate = block->nominal_rate; block->final_rate = block->nominal_rate;