From 60f417b57021d5d72ca1fd3cb8fa936b842f96e0 Mon Sep 17 00:00:00 2001 From: Simen Svale Skogsrud Date: Wed, 23 Feb 2011 20:06:55 +0100 Subject: [PATCH] =?UTF-8?q?fixed=20a=20double=20rounding=20error=20compens?= =?UTF-8?q?ation=20bug=20in=20mc=5Farc=20thanks=20to=20Etienne=20Chov?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- motion_control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/motion_control.c b/motion_control.c index ebef597..e51d519 100644 --- a/motion_control.c +++ b/motion_control.c @@ -52,7 +52,7 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_tr plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc double millimeters_of_travel = hypot(angular_travel*radius, labs(linear_travel)); if (millimeters_of_travel == 0.0) { return; } - uint16_t segments = ceil(millimeters_of_travel/settings.mm_per_arc_segment); + uint16_t segments = round(millimeters_of_travel/settings.mm_per_arc_segment); // Multiply inverse feed_rate to compensate for the fact that this movement is approximated // by a number of discrete segments. The inverse feed_rate should be correct for the sum of // all segments. @@ -69,7 +69,7 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_tr int i; // Initialize the linear axis target[axis_linear] = position[axis_linear]; - for (i=0; i<=segments; i++) { + for (i=0; i