diff options
author | FormerLurker <hochgebe@gmail.com> | 2020-11-28 03:20:29 +0300 |
---|---|---|
committer | FormerLurker <hochgebe@gmail.com> | 2020-11-28 03:20:29 +0300 |
commit | 7da85eb0a6d659885b4a16fce7a0ba15ecbe0e39 (patch) | |
tree | 113b82b09851a545fd5666deab1b790cc52635d0 /ArcWelderInverseProcessor | |
parent | 359b6e92bf252a9ab6485179aee7f3148108aa86 (diff) |
Fix Python unicode logging issues. Add sin approximation to inverse processor. Fix log levels and progress output. Add firmware compensation statistics.
Diffstat (limited to 'ArcWelderInverseProcessor')
-rw-r--r-- | ArcWelderInverseProcessor/inverse_processor.cpp | 31 | ||||
-rw-r--r-- | ArcWelderInverseProcessor/inverse_processor.h | 3 |
2 files changed, 30 insertions, 4 deletions
diff --git a/ArcWelderInverseProcessor/inverse_processor.cpp b/ArcWelderInverseProcessor/inverse_processor.cpp index d82568c..f40a66b 100644 --- a/ArcWelderInverseProcessor/inverse_processor.cpp +++ b/ArcWelderInverseProcessor/inverse_processor.cpp @@ -347,16 +347,39 @@ void inverse_processor::mc_arc(float* position, float* target, float* offset, fl if (segments > 1) { // Initialize the extruder axis - - float cos_T = cos(theta_per_segment); - float sin_T = sin(theta_per_segment); + float cos_T, sin_T, sin_Ti, cos_Ti; + //float cos_T = cos(theta_per_segment); + //float sin_T = sin(theta_per_segment); + float sq_theta_per_segment = theta_per_segment * theta_per_segment; + sin_T = theta_per_segment - sq_theta_per_segment * theta_per_segment / 6; + cos_T = 1 - 0.5f * sq_theta_per_segment; // Small angle approximation + + //cos_T = 1 - 0.5 * theta_per_segment * theta_per_segment; // Small angle approximation + //sin_T = theta_per_segment; float r_axisi; uint16_t i; - + int8_t count = 0; for (i = 1; i < segments; i++) { // Increment (segments-1) + + if (count < cs_.n_arc_correction) { + // Apply vector rotation matrix r_axisi = r_axis_x * sin_T + r_axis_y * cos_T; r_axis_x = r_axis_x * cos_T - r_axis_y * sin_T; r_axis_y = r_axisi; + count++; + } + else { + // Arc correction to radius vector. Computed only every N_ARC_CORRECTION increments. + // Compute exact location by applying transformation matrix from initial radius vector(=-offset). + cos_Ti = cos(i * theta_per_segment); + sin_Ti = sin(i * theta_per_segment); + r_axis_x = -offset[X_AXIS] * cos_Ti + offset[Y_AXIS] * sin_Ti; + r_axis_y = -offset[X_AXIS] * sin_Ti - offset[Y_AXIS] * cos_Ti; + count = 0; + + } + + // Update arc_target location p_x = center_axis_x + r_axis_x; diff --git a/ArcWelderInverseProcessor/inverse_processor.h b/ArcWelderInverseProcessor/inverse_processor.h index a5f7184..6762953 100644 --- a/ArcWelderInverseProcessor/inverse_processor.h +++ b/ArcWelderInverseProcessor/inverse_processor.h @@ -45,6 +45,7 @@ enum AxisEnum { X_AXIS = 0, Y_AXIS= 1, Z_AXIS = 2, E_AXIS = 3, X_HEAD = 4, Y_HEA #define DEFAULT_MIN_ARC_SEGMENTS 0 // OPTIONAL - The enforced minimum segments in a full circle of the same radius. #define DEFAULT_ARC_SEGMENTS_PER_SEC 0 // OPTIONAL - Use feedrate to choose segment length. // approximation will not be used for the first segment. Subsequent segments will be corrected following DEFAULT_N_ARC_CORRECTION. +#define DEFAULT_N_ARC_CORRECTIONS 24 struct ConfigurationStore { ConfigurationStore() { @@ -52,11 +53,13 @@ struct ConfigurationStore { min_mm_per_arc_segment = DEFAULT_MIN_MM_PER_ARC_SEGMENT; min_arc_segments = DEFAULT_MIN_ARC_SEGMENTS; arc_segments_per_sec = DEFAULT_ARC_SEGMENTS_PER_SEC; + n_arc_correction = DEFAULT_N_ARC_CORRECTIONS; } float mm_per_arc_segment; // This value is ALWAYS used. float min_mm_per_arc_segment; // if less than or equal to 0, this is disabled int min_arc_segments; // If less than or equal to zero, this is disabled double arc_segments_per_sec; // If less than or equal to zero, this is disabled + int n_arc_correction; }; class inverse_processor { |