Skip to content

Commit

Permalink
Merge pull request Smoothieware#944 from Zaaphod/edge
Browse files Browse the repository at this point in the history
Feature: Interpolate Arcs based on Maximum Error
  • Loading branch information
wolfmanjm committed Jun 16, 2016
2 parents 8f06510 + 417d868 commit d3bc6d2
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 15 deletions.
5 changes: 4 additions & 1 deletion ConfigSamples/AzteegX5Mini.delta/Version2/config
Expand Up @@ -6,7 +6,10 @@ arm_radius 203.00 # this is the hori

default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves
default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves
mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation
mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable
mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable
# note it is invalid for both the above be 0
# if both are used, will use largest segment length based on radius
#mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots ).
delta_segments_per_second 100 # segments per second used for deltas

Expand Down
5 changes: 4 additions & 1 deletion ConfigSamples/AzteegX5Mini.delta/config
Expand Up @@ -6,7 +6,10 @@ arm_radius 203.00 # this is the hori

default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves
default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves
mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation
mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable
mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable
# note it is invalid for both the above be 0
# if both are used, will use largest segment length based on radius
#mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots ).
delta_segments_per_second 100 # segments per second used for deltas

Expand Down
5 changes: 4 additions & 1 deletion ConfigSamples/AzteegX5Mini/Version2/config
@@ -1,7 +1,10 @@
# Robot module configurations : general handling of movement G-codes and slicing into moves
default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves
default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves
mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation
mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable
mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable
# note it is invalid for both the above be 0
# if both are used, will use largest segment length based on radius
#mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots ).

# Arm solution configuration : Cartesian robot. Translates mm positions into stepper positions
Expand Down
5 changes: 4 additions & 1 deletion ConfigSamples/AzteegX5Mini/config
@@ -1,7 +1,10 @@
# Robot module configurations : general handling of movement G-codes and slicing into moves
default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves
default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves
mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation
mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable
mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable
# note it is invalid for both the above be 0
# if both are used, will use largest segment length based on radius
#mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots ).

# Arm solution configuration : Cartesian robot. Translates mm positions into stepper positions
Expand Down
7 changes: 4 additions & 3 deletions ConfigSamples/Smoothieboard.delta/config
Expand Up @@ -2,9 +2,10 @@
# Robot module configurations : general handling of movement G-codes and slicing into moves
default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves
default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves
mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for
# these segments. Smaller values mean more resolution,
# higher values mean faster computation
mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable
mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable
# note it is invalid for both the above be 0
# if both are used, will use largest segment length based on radius
#mm_per_line_segment 0.5 # Lines can be cut into segments ( not useful with cartesian
# coordinates robots ).
delta_segments_per_second 100 # for deltas only same as in Marlin/Delta, set to 0 to disable
Expand Down
7 changes: 4 additions & 3 deletions ConfigSamples/Smoothieboard/config
Expand Up @@ -2,9 +2,10 @@
## Robot module configurations : general handling of movement G-codes and slicing into moves
default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves
default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves
mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for
# these segments. Smaller values mean more resolution,
# higher values mean faster computation
mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable
mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable
# note it is invalid for both the above be 0
# if both are used, will use largest segment length based on radius
#mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian
# coordinates robots ).

Expand Down
7 changes: 4 additions & 3 deletions ConfigSamples/rotary.delta/config
Expand Up @@ -2,9 +2,10 @@
# Robot module configurations : general handling of movement G-codes and slicing into moves
default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves
default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves
mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for
# these segments. Smaller values mean more resolution,
# higher values mean faster computation
mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable
mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable
# note it is invalid for both the above be 0
# if both are used, will use largest segment length based on radius
#mm_per_line_segment 0.5 # Lines can be cut into segments ( not useful with cartesian
# coordinates robots ).
delta_segments_per_second 100 # for deltas only same as in Marlin/Delta, set to 0 to disable
Expand Down
15 changes: 13 additions & 2 deletions src/modules/robot/Robot.cpp
Expand Up @@ -46,6 +46,7 @@ using std::string;
#define mm_per_line_segment_checksum CHECKSUM("mm_per_line_segment")
#define delta_segments_per_second_checksum CHECKSUM("delta_segments_per_second")
#define mm_per_arc_segment_checksum CHECKSUM("mm_per_arc_segment")
#define mm_max_arc_error_checksum CHECKSUM("mm_max_arc_error")
#define arc_correction_checksum CHECKSUM("arc_correction")
#define x_axis_max_speed_checksum CHECKSUM("x_axis_max_speed")
#define y_axis_max_speed_checksum CHECKSUM("y_axis_max_speed")
Expand Down Expand Up @@ -180,7 +181,8 @@ void Robot::load_config()
this->seek_rate = THEKERNEL->config->value(default_seek_rate_checksum )->by_default( 100.0F)->as_number();
this->mm_per_line_segment = THEKERNEL->config->value(mm_per_line_segment_checksum )->by_default( 0.0F)->as_number();
this->delta_segments_per_second = THEKERNEL->config->value(delta_segments_per_second_checksum )->by_default(0.0f )->as_number();
this->mm_per_arc_segment = THEKERNEL->config->value(mm_per_arc_segment_checksum )->by_default( 0.5f)->as_number();
this->mm_per_arc_segment = THEKERNEL->config->value(mm_per_arc_segment_checksum )->by_default( 0.0f)->as_number();
this->mm_max_arc_error = THEKERNEL->config->value(mm_max_arc_error_checksum )->by_default( 0.01f)->as_number();
this->arc_correction = THEKERNEL->config->value(arc_correction_checksum )->by_default( 5 )->as_number();

this->max_speeds[X_AXIS] = THEKERNEL->config->value(x_axis_max_speed_checksum )->by_default(60000.0F)->as_number() / 60.0F;
Expand Down Expand Up @@ -1018,9 +1020,18 @@ bool Robot::append_arc(Gcode * gcode, const float target[], const float offset[]
// Mark the gcode as having a known distance
this->distance_in_gcode_is_known( gcode );

// limit segments by maximum arc error
float arc_segment = this->mm_per_arc_segment;
if ((this->mm_max_arc_error > 0) && (2 * radius > this->mm_max_arc_error)) {
float min_err_segment = 2 * sqrtf((this->mm_max_arc_error * (2 * radius - this->mm_max_arc_error)));
if (this->mm_per_arc_segment < min_err_segment) {
arc_segment = min_err_segment;
}
}
// Figure out how many segments for this gcode
uint16_t segments = floorf(gcode->millimeters_of_travel / this->mm_per_arc_segment);
uint16_t segments = ceilf(gcode->millimeters_of_travel / arc_segment);

//printf("Radius %f - Segment Length %f - Number of Segments %d\r\n",radius,arc_segment,segments); // Testing Purposes ONLY
float theta_per_segment = angular_travel / segments;
float linear_per_segment = linear_travel / segments;

Expand Down
1 change: 1 addition & 0 deletions src/modules/robot/Robot.h
Expand Up @@ -107,6 +107,7 @@ class Robot : public Module {
float feed_rate; // Current rate for feeding moves ( mm/min )
float mm_per_line_segment; // Setting : Used to split lines into segments
float mm_per_arc_segment; // Setting : Used to split arcs into segments
float mm_max_arc_error; // Setting : Used to limit total arc segments to max error
float delta_segments_per_second; // Setting : Used to split lines into segments for delta based on speed
float seconds_per_minute; // for realtime speed change

Expand Down

0 comments on commit d3bc6d2

Please sign in to comment.