diff options
author | Robert W. Ellenberg <rwe24g@gmail.com> | 2013-11-11 00:34:21 -0500 |
---|---|---|
committer | Chris Radek <chris@timeguy.com> | 2014-06-11 14:43:39 -0500 |
commit | 4933a71cecbb47cb349608d3ac2bff34b315e79c (patch) | |
tree | cbb6ddb0900e078706d934525d58e3c2c11c561e | |
parent | cc3a45a778b03b3cfdc538933e9d6d24d7aafbc1 (diff) | |
download | linuxcnc-4933a71cecbb47cb349608d3ac2bff34b315e79c.tar.gz linuxcnc-4933a71cecbb47cb349608d3ac2bff34b315e79c.zip |
Fixed a few arc blend bugs
Removed optimization bug that was causing large overshoots and
some acceleration spikes.
Remaining issues:
* infinity norm is used to calculate limiting acceleration for a given TC.
The trajectory planner needs to know machine limits if it is to
compensate.
* Occasional segfault appears on load after a clean shutdown. No issues
while running so far.
-rw-r--r-- | nc_files/blend_tests/square_spiral.ngc | 3 | ||||
-rw-r--r-- | src/emc/kinematics/tp.c | 29 |
2 files changed, 19 insertions, 13 deletions
diff --git a/nc_files/blend_tests/square_spiral.ngc b/nc_files/blend_tests/square_spiral.ngc index 2cbc2a819..a2c5e851a 100644 --- a/nc_files/blend_tests/square_spiral.ngc +++ b/nc_files/blend_tests/square_spiral.ngc @@ -1,7 +1,8 @@ +G20 G90 G64 G0 X0 Y0 Z0 G1 Z-.19 F5 -G1 X0.01 F25 +G0 X0.01 Y[0.01*2] X[-0.01*2] Y[-0.01*2] diff --git a/src/emc/kinematics/tp.c b/src/emc/kinematics/tp.c index 85d97371c..a8cb4735f 100644 --- a/src/emc/kinematics/tp.c +++ b/src/emc/kinematics/tp.c @@ -29,7 +29,7 @@ static inline double fmin(double a, double b) { return (a) < (b) ? (a) : (b); } #endif #define TP_DEBUG -#define TC_DEBUG +/*#define TC_DEBUG*/ #include "tp_debug.h" #define TP_ARC_BLENDS @@ -662,7 +662,7 @@ STATIC int tpCreateBlendArc(TP_STRUCT const * const tp, TC_STRUCT * const prev_t double d_tol=Ctheta*h_tol; // Limit amount of line segment to blend so that we don't delete the line - const double blend_ratio = 0.33333; + const double blend_ratio = 0.5; //HACK Assume that we are not working on segments already traversed for now double L1 = prev_tc->target; @@ -713,16 +713,16 @@ STATIC int tpCreateBlendArc(TP_STRUCT const * const tp, TC_STRUCT * const prev_t // we have short segments, and need to compromise on segment length to // avoid degeneracy. if (L_prev > 0.0) { - double v_sample = phi * d_upper * Ttheta / tp->cycleTime; + double v_sample = 0.5 * phi * d_upper * Ttheta / tp->cycleTime; // The blend velocity we can actually get is limited by the sample rate v_upper = fmin(v_upper,v_sample); // d required to meet v_upper - double d_sample = v_upper * tp->cycleTime / (phi * Ttheta); + double d_sample = 2.0 * v_upper * tp->cycleTime / (phi * Ttheta); double d_req1 = fmax(d_sample,d_upper); - double v1_sample = (L1-d_req1) / tp->cycleTime; + double v1_sample = 0.5 * (L1-d_req1) / tp->cycleTime; //If we take too big a bite out of the previous line, we won't be able //to move fast enough through the segment to reach v_upper anyway. @@ -753,10 +753,11 @@ STATIC int tpCreateBlendArc(TP_STRUCT const * const tp, TC_STRUCT * const prev_t tpComputeBlendVelocity(tp, prev_tc, tc, &v_parabolic); tp_debug_print("Speed Comparison: v_arc %f, v_para %f\n",v_upper,v_parabolic); - if (v_upper < v_parabolic) { - tp_debug_print("v_arc lower, abort arc creation\n"); - return TP_ERR_FAIL; - } + //Temporarily surpress fallback + /*if (v_upper < v_parabolic) {*/ + /*tp_debug_print("v_arc lower, abort arc creation\n");*/ + /*return TP_ERR_FAIL;*/ + /*}*/ //If for some reason we get too small a radius, the blend will fail. This //shouldn't happen if everything upstream is working. @@ -1034,12 +1035,16 @@ STATIC int tpRunOptimization(TP_STRUCT * const tp) { //Calculate the maximum starting velocity vs of segment tc, given the //trajectory parameters double acc = tpGetScaledAccel(tp,tc); - vs = pmSqrt(pmSq(tc->finalvel) + 2 * acc * tc->target); + vs = pmSqrt(pmSq(tc->finalvel) + 2.0 * acc * tc->target); tp_debug_print(" vs = %f, reqvel = %f\n",vs,tc->reqvel); - if (vs > tc->maxvel) { + + //TODO incoporate max feed override? now we assume 120% is max + double goal_vel = fmin(tc->maxvel, tc->reqvel * 1.2); + + if (vs > goal_vel) { //Found a peak - vs = tc->maxvel; + vs = goal_vel; prev_tc->finalvel = vs; prev_tc->atpeak=1; tp_debug_print("found peak\n"); |