float travel_max; // max work envelope for soft limits
float travel_min; // min work envelope for soft limits
float jerk_max; // max jerk (Jm) in km/min^3
- float recip_jerk; // reciprocal of current jerk in min^3/mm
+ float recip_jerk; // reciprocal of current jerk in min^3/km
float radius; // radius in mm for rotary axes
float search_velocity; // homing search velocity
float latch_velocity; // homing latch velocity
/// Sets jerk and its reciprocal for axis
void axis_set_jerk_max(int axis, float jerk) {
axes[axis].jerk_max = jerk;
- axes[axis].recip_jerk = 1 / (jerk * JERK_MULTIPLIER);
+ axes[axis].recip_jerk = 1.0 / jerk;
}
for (int axis = 0; axis < AXES; axis++)
if (axis_square[axis]) { // Do not use fp_ZERO here
// Squaring axis_length ensures it's positive
- C = axis_square[axis] * axis_get_recip_jerk(axis);
+ C = axis_square[axis] / axis_get_jerk_max(axis);
if (maxC < C) {
maxC = C;
static float _calc_jerk(const float axis_square[], const float unit[]) {
int axis = mp_find_jerk_axis(axis_square);
+ ASSERT(isfinite(unit[axis]) && unit[axis]);
+
// Finally, the selected jerk term needs to be scaled by the
// reciprocal of the absolute value of the axis's unit
// vector term. This way when the move is finally decomposed into
float naive_move_time =
2 * bf->length / (bf->entry_velocity + bf->exit_velocity); // average
- if (naive_move_time < SEGMENT_TIME) {
+ if (isfinite(naive_move_time) && naive_move_time < SEGMENT_TIME) {
bf->cruise_velocity = bf->length / SEGMENT_TIME;
bf->exit_velocity =
max(0, min(bf->cruise_velocity, (bf->entry_velocity - bf->delta_vmax)));
}
// B" case: Block is short, but fits into a single body segment
- if (naive_move_time <= SEGMENT_TIME) {
+ if (isfinite(naive_move_time) && naive_move_time <= SEGMENT_TIME) {
bf->entry_velocity = mp_buffer_prev(bf)->exit_velocity;
if (!fp_ZERO(bf->entry_velocity)) {
} else break;
- } while ((fabs(bf->cruise_velocity - computed_velocity) /
- computed_velocity) > TRAPEZOID_ITERATION_ERROR_PERCENT);
+ } while (TRAPEZOID_ITERATION_ERROR_PERCENT <
+ (fabs(bf->cruise_velocity - computed_velocity) /
+ computed_velocity));
// set velocity and clean up any parts that are too short
bf->cruise_velocity = computed_velocity;
#if 0
void mp_print_buffer(mp_buffer_t *bp) {
- printf_P(PSTR("{\"msg\":\"%d,0x%04lx,"
- "%0.2f,%0.2f,%0.2f,%0.2f,"
- "%0.2f,%0.2f,%0.2f,%0.2f,"
- "%0.2f,%0.2f,%0.2f\"}\n"),
- bp->flags & BUFFER_REPLANNABLE, (intptr_t)bp->cb,
- bp->length, bp->head_length, bp->body_length, bp->tail_length,
- bp->entry_velocity, bp->cruise_velocity, bp->exit_velocity,
- bp->braking_velocity,
- bp->entry_vmax, bp->cruise_vmax, bp->exit_vmax);
+ printf_P(PSTR("{\"msg\":\""));
+ printf_P(PSTR("%d,"), bp->flags & BUFFER_REPLANNABLE);
+ printf_P(PSTR("0x%04lx,"), (intptr_t)bp->cb);
+ printf_P(PSTR("%0.2f,"), bp->length);
+ printf_P(PSTR("%0.2f,"), bp->head_length);
+ printf_P(PSTR("%0.2f,"), bp->body_length);
+ printf_P(PSTR("%0.2f,"), bp->tail_length);
+ printf_P(PSTR("%0.2f,"), bp->entry_velocity);
+ printf_P(PSTR("%0.2f,"), bp->cruise_velocity);
+ printf_P(PSTR("%0.2f,"), bp->exit_velocity);
+ printf_P(PSTR("%0.2f,"), bp->braking_velocity);
+ printf_P(PSTR("%0.2f,"), bp->entry_vmax);
+ printf_P(PSTR("%0.2f,"), bp->cruise_vmax);
+ printf_P(PSTR("%0.2f"), bp->exit_vmax);
+ printf_P(PSTR("\"}\n"));
while (!usart_tx_empty()) continue;
}