bug fix, changes with arc error, test output
authorZaaphod <zaaphod@productionautomation.net>
Wed, 8 Jun 2016 21:23:03 +0000 (17:23 -0400)
committerZaaphod <zaaphod@productionautomation.net>
Wed, 8 Jun 2016 21:23:03 +0000 (17:23 -0400)
Fixed a bug on line 185 so mm_max_arc_error now is correctly read in from config file

Changed line 1025 so setting mm_max_arc_error = 0 will disable the new calculation.
Setting mm_per_arc_segment = 0 will run only new calculation
setting both will use whichever value is larger

changed formula on line 1032 to more accurately divide segments.  This prevents the error from ever being greater than the specified arc error. It is taking into account the start point that the original formula was ignoring.

added a printf to output relevant data to serial port for calculation verification testing purposes only

src/modules/robot/Robot.cpp

index 2fc0fcd..18bf1c6 100644 (file)
@@ -182,7 +182,7 @@ void Robot::load_config()
     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_max_arc_error    = THEKERNEL->config->value(mm_max_arc_error             )->by_default(   0.01f)->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;
@@ -1022,15 +1022,16 @@ bool Robot::append_arc(Gcode * gcode, const float target[], const float offset[]
 
     // limit segments by maximum arc error
     float arc_segment = this->mm_per_arc_segment;
-    if (2 * radius > this->mm_max_arc_error) {
+    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 / arc_segment);
+    uint16_t segments = floorf((gcode->millimeters_of_travel / arc_segment)+1);
 
+    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;