Merge pull request #8865 from thinkyhead/bf2_more_scara_scaling
[2.0.x] SCARA Feedrate Scaling for G2/G3 - using HYPOT
This commit is contained in:
@ -121,7 +121,7 @@ void recalc_delta_settings() {
|
||||
}while(0)
|
||||
|
||||
void inverse_kinematics(const float raw[XYZ]) {
|
||||
DELTA_RAW_IK();
|
||||
DELTA_IK(raw);
|
||||
// DELTA_DEBUG();
|
||||
}
|
||||
|
||||
|
@ -76,17 +76,17 @@ void recalc_delta_settings();
|
||||
#endif
|
||||
|
||||
// Macro to obtain the Z position of an individual tower
|
||||
#define DELTA_Z(T) raw[Z_AXIS] + _SQRT( \
|
||||
delta_diagonal_rod_2_tower[T] - HYPOT2( \
|
||||
delta_tower[T][X_AXIS] - raw[X_AXIS], \
|
||||
delta_tower[T][Y_AXIS] - raw[Y_AXIS] \
|
||||
) \
|
||||
#define DELTA_Z(V,T) V[Z_AXIS] + _SQRT( \
|
||||
delta_diagonal_rod_2_tower[T] - HYPOT2( \
|
||||
delta_tower[T][X_AXIS] - V[X_AXIS], \
|
||||
delta_tower[T][Y_AXIS] - V[Y_AXIS] \
|
||||
) \
|
||||
)
|
||||
|
||||
#define DELTA_RAW_IK() do { \
|
||||
delta[A_AXIS] = DELTA_Z(A_AXIS); \
|
||||
delta[B_AXIS] = DELTA_Z(B_AXIS); \
|
||||
delta[C_AXIS] = DELTA_Z(C_AXIS); \
|
||||
#define DELTA_IK(V) do { \
|
||||
delta[A_AXIS] = DELTA_Z(V, A_AXIS); \
|
||||
delta[B_AXIS] = DELTA_Z(V, B_AXIS); \
|
||||
delta[C_AXIS] = DELTA_Z(V, C_AXIS); \
|
||||
}while(0)
|
||||
|
||||
void inverse_kinematics(const float raw[XYZ]);
|
||||
|
@ -587,7 +587,7 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
|
||||
// SERIAL_ECHOPAIR(" seconds=", seconds);
|
||||
// SERIAL_ECHOLNPAIR(" segments=", segments);
|
||||
|
||||
#if IS_SCARA && ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
#if ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
// SCARA needs to scale the feed rate from mm/s to degrees/s
|
||||
const float inv_segment_length = min(10.0, float(segments) / cartesian_mm), // 1/mm/segs
|
||||
inverse_secs = inv_segment_length * _feedrate_mm_s;
|
||||
@ -611,38 +611,29 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
|
||||
}
|
||||
|
||||
LOOP_XYZE(i) raw[i] += segment_distance[i];
|
||||
|
||||
#if ENABLED(DELTA)
|
||||
DELTA_RAW_IK(); // Delta can inline its kinematics
|
||||
DELTA_IK(raw); // Delta can inline its kinematics
|
||||
#else
|
||||
inverse_kinematics(raw);
|
||||
#endif
|
||||
|
||||
ADJUST_DELTA(raw); // Adjust Z if bed leveling is enabled
|
||||
|
||||
#if IS_SCARA && ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
#if ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
// For SCARA scale the feed rate from mm/s to degrees/s
|
||||
// Use ratio between the length of the move and the larger angle change
|
||||
const float adiff = abs(delta[A_AXIS] - oldA),
|
||||
bdiff = abs(delta[B_AXIS] - oldB);
|
||||
planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], max(adiff, bdiff) * inverse_secs, active_extruder);
|
||||
oldA = delta[A_AXIS];
|
||||
oldB = delta[B_AXIS];
|
||||
// i.e., Complete the angular vector in the given time.
|
||||
planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder);
|
||||
oldA = delta[A_AXIS]; oldB = delta[B_AXIS];
|
||||
#else
|
||||
planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], _feedrate_mm_s, active_extruder);
|
||||
planner.buffer_line(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], _feedrate_mm_s, active_extruder);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Since segment_distance is only approximate,
|
||||
// the final move must be to the exact destination.
|
||||
|
||||
#if IS_SCARA && ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
// For SCARA scale the feed rate from mm/s to degrees/s
|
||||
// With segments > 1 length is 1 segment, otherwise total length
|
||||
// Ensure last segment arrives at target location.
|
||||
#if ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
inverse_kinematics(rtarget);
|
||||
ADJUST_DELTA(rtarget);
|
||||
const float adiff = abs(delta[A_AXIS] - oldA),
|
||||
bdiff = abs(delta[B_AXIS] - oldB);
|
||||
planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], max(adiff, bdiff) * inverse_secs, active_extruder);
|
||||
planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], rtarget[Z_AXIS], rtarget[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder);
|
||||
#else
|
||||
planner.buffer_line_kinematic(rtarget, _feedrate_mm_s, active_extruder);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user