G-code and PH curves in CNC Manufacturing Zbyněk Šír Institute of Applied Geometry, JKU Linz The research was supported through grant P17387-N12 of the Austrian Science Fund (FWF).
Talk overview Motivation G 1 Hermite interpolation by biarcs Conversion of curves into arc splines Basics of Pythagorean Hodograph curves Curve conversion and rounding G-code with PH curves Conclusion 2
Motivation In the CNC machining the speed must be controlled very precisely we need the arc-length function of the tool path. 3
Motivation In the CNC machining the speed must be controlled very precisely we need the arc-length function of the tool path. The arc-length function is typically not nice: x (t) 2 + y (t) 2 dt. 3-a
Motivation In the CNC machining the speed must be controlled very precisely we need the arc-length function of the tool path. The arc-length function is typically not nice: x (t) 2 + y (t) 2 dt. So called G-code became an industrial standard - piecewise curves composed of line and circular segments. 3-b
Motivation In the CNC machining the speed must be controlled very precisely we need the arc-length function of the tool path. The arc-length function is typically not nice: x (t) 2 + y (t) 2 dt. So called G-code became an industrial standard - piecewise curves composed of line and circular segments. Only a G 1 (C 1 ) continuity is possible using G-code. 3-c
Motivation In the CNC machining the speed must be controlled very precisely we need the arc-length function of the tool path. The arc-length function is typically not nice: x (t) 2 + y (t) 2 dt. So called G-code became an industrial standard - piecewise curves composed of line and circular segments. Only a G 1 (C 1 ) continuity is possible using G-code. We need conversion/construction methods. 3-d
Example Curve composed of 16 circular arcs. 4
G 1 biarc interpolation c1 c0 C J P0 P1 U1 U0 5 replacements
G 1 biarc interpolation c 1 c 0 C J replacements P 0 P 1 U 1 U 0 5-a
G 1 biarc interpolation c 1 c 0 C J replacements P 0 P 1 U 1 U 0 5-b
G 1 biarc interpolation c 1 c 0 C J replacements P 0 P 1 U 1 U 0 5-c
G 1 biarc interpolation c 1 c 0 C J replacements P 0 P 1 U 1 U 0 5-d
G 1 biarc interpolation c 1 c 0 C J replacements P 0 P 1 U 1 U 0 5-e
frag replacements Characteristic circle of joints C Define C as unique circle passing through the points P 0, P 1 and having the same (oriented) angles with the vectors U 0 and U 1. c 1 P 0 P 1 J It is obtained as the trajectory of the point P 0 under the unique rotation transforming data P 0, U 0 to the data P 1, U 1. U 1 U 0 c 0 6
frag replacements Characteristic circle of joints C For any point J in the plane there is precisely one arc c 0 interpolating P 0, U 0 and one arc c 1 interpolating P 1, U 1. c 1 J We claim, that these two arcs have a common tangent at J if and only if J C. P 0 P 1 U 1 U 0 c 0 6-a
frag replacements Characteristic circle of joints C In fact, if J C then the angle between the circle C and the arc c 0 at the point J is the same as the angle between the circle C and the vector U 0. The same for c 2. c 1 P 0 P 1 J Since the circle C has by construction same angle with U 0 and U 1, the two arcs c 0, c 1 join with G 1 continuity at J. U 1 U 0 c 0 6-b
frag replacements Characteristic circle of joints C c 1 P 0 P 1 J Suppose, on the other hand, that a G 1 interpolating biarc is constructed. The circle passing through the points P 0, J and P 1 must have the same angle with the both circular arcs c 0, c 1 and therefore also with the vectors U 0, U 1. It is hence identical with the circle C and J C. U 1 U 0 c 0 6-c
Choosing the biarc Equal chords Parallel tangent New method 7
Choosing the biarc Equal chords Parallel tangent New method 8
Choosing the biarc Equal chords Parallel tangent New method 9
+ and of the new methods Better approximation of the curve shape - smaller error. The joints lie on the curve - true arc conversion - easier evaluation of the error. The construction is G-code preserving. The construction is invariant under the Möbilus group. The position of the joint must be computed numerically. but it is only one (polynomial) equation on a closed interval 10
Conversion of continuous curves Sample G 1 data from given curve. If the error is too big, subdivide (possibly adaptively). 11
Asymptotical behaviour of the Biarc conversion Error Ratio Error Ratio 1 4.97 2 2.23 2.233 256 3.32 10 5 5.552 4 3.98 10 1 5.594 512 4.32 10 6 7.699 8 1.89 10 1 2.110 1024 5.45 10 7 7.928 16 4.02 10 2 4.697 2048 6.82 10 8 7.988 32 5.93 10 3 6.780 4096 8.57 10 9 7.956 64 1.03 10 3 5.767 8192 1.07 10 9 7.979 128 1.85 10 4 5.568 16384 1.34 10 10 8.009 Theorem: Approximation order is 3 and can not be improved. 12
Pythagorean Hodograph curves A Bézier curve is called Pythagorean Hodograph if the length of its tangent vector, taken in an appropriate metric, depends in a polynomial way on the parameter. 13
Pythagorean Hodograph curves A Bézier curve is called Pythagorean Hodograph if the length of its tangent vector, taken in an appropriate metric, depends in a polynomial way on the parameter. planar PH curve (Farouki, Sakkalis 1990) if there exists a polynomial σ(t) such that x (t) 2 + y (t) 2 = σ 2 (t) 13-a
Pythagorean Hodograph curves A Bézier curve is called Pythagorean Hodograph if the length of its tangent vector, taken in an appropriate metric, depends in a polynomial way on the parameter. planar PH curve (Farouki, Sakkalis 1990) if there exists a polynomial σ(t) such that x (t) 2 + y (t) 2 = σ 2 (t) Euclidean space PH curve (Farouki, Sakkalis 1994) if there exists a polynomial σ(t) such that x (t) 2 + y (t) 2 + z (t) 2 = σ 2 (t) 13-b
Pythagorean Hodograph curves A Bézier curve is called Pythagorean Hodograph if the length of its tangent vector, taken in an appropriate metric, depends in a polynomial way on the parameter. planar PH curve (Farouki, Sakkalis 1990) if there exists a polynomial σ(t) such that x (t) 2 + y (t) 2 = σ 2 (t) Euclidean space PH curve (Farouki, Sakkalis 1994) if there exists a polynomial σ(t) such that x (t) 2 + y (t) 2 + z (t) 2 = σ 2 (t) Minkowski space PH curve (Moon 1998) if there exists a polynomial σ(t) such that x (t) 2 + y (t) 2 z (t) 2 = σ 2 (t) 13-c
Properties of Euclidean PH curves Compared to ordinary Bézier curves, Euclidean PH curves have two important additional properties. 14
Properties of Euclidean PH curves Compared to ordinary Bézier curves, Euclidean PH curves have two important additional properties. The arc length is (piecewise) polynomial s(t) = σ(t) dt. 14-a
Properties of Euclidean PH curves Compared to ordinary Bézier curves, Euclidean PH curves have two important additional properties. The arc length is (piecewise) polynomial s(t) = σ(t) dt. The offsets of planar PH curves are rational parametric curves. The offset at the distance d has the equation [ ] o d (t) = x(t) d x (t) σ(t), y(t) + (t) dy. σ(t) Spatial PH curves have rational frames. 14-b
Characterization of planar PH curves We can consider the Diophantine equation (x ) 2 + (y ) 2 = σ 2 as an implicit constraint, we want an explicit representation. 15
Characterization of planar PH curves We can consider the Diophantine equation (x ) 2 + (y ) 2 = σ 2 as an implicit constraint, we want an explicit representation. Theorem (Kubota 1972): Polynomials x, y, σ satisfy (x ) 2 + (y ) 2 = σ 2 if and only if there exist polynomials u, v, w such that x = w(u 2 v 2 ), y = w(2uv), σ = w(u 2 + v 2 ). 15-a
Characterization of planar PH curves We can consider the Diophantine equation (x ) 2 + (y ) 2 = σ 2 as an implicit constraint, we want an explicit representation. Theorem (Kubota 1972): Polynomials x, y, σ satisfy (x ) 2 + (y ) 2 = σ 2 if and only if there exist polynomials u, v, w such that x = w(u 2 v 2 ), y = w(2uv), σ = w(u 2 + v 2 ). Starting with any polynomial curve (u, v) we obtain a PH curve applying u χ u2 v 2 = x x v 2uv y y preimage hodograph P Hcurve χ z z 2 p Using complex representation: z(t) = u(t) + iv(t). 15-b
Characterization of space PH curves Theorem (Dietz, Hoschek, Jüttler 1993; V.A. Lebesgue 1868): Polynomials x, y, z, σ satisfy (x ) 2 + (y ) 2 + (z ) 2 = σ 2 if and only if x = w(u 2 + v 2 p 2 q 2 ), y = w(2up + 2vq) z = w(2uq 2vp), σ = w(u 2 + v 2 + p 2 + q 2 ). 16
Characterization of space PH curves Theorem (Dietz, Hoschek, Jüttler 1993; V.A. Lebesgue 1868): Polynomials x, y, z, σ satisfy (x ) 2 + (y ) 2 + (z ) 2 = σ 2 if and only if x = w(u 2 + v 2 p 2 q 2 ), y = w(2up + 2vq) z = w(2uq 2vp), σ = w(u 2 + v 2 + p 2 + q 2 ). Starting with any polynomial curve (u, v) we obtain a PH curve applying u u 2 + v 2 p 2 q 2 x x v χ 2up + 2vq p = y y 2uq 2vp z z q preimage hodograph P Hcurve χ A AiA p Using quaternion representation A(t) = u(t) + iv(t) + jp(t) + kq(t). 16-b
C 2 Hermite interpolation - conversion of curves 2 1 0 0.5 1 1.5 2 2.5 3 1 2 17
C 2 Hermite interpolation - conversion of curves 2 1 0 0.5 1 1.5 2 2.5 3 1 2 17-a
C 2 Hermite interpolation - conversion of curves 2 1 0 0.5 1 1.5 2 2.5 3 1 2 17-b
C 2 Hermite interpolation - conversion of curves 2 1 0 0.5 1 1.5 2 2.5 3 1 2 17-c
C 2 Hermite interpolation - conversion of curves 2 1 0 0.5 1 1.5 2 2.5 3 1 2 17-d
C 2 Hermite interpolation - rounding the G-code Replacing the circle joint by a small piece of PH curve. 0.6 0.4 0.2 0 0.2 0.4 0.6 0.6 0.4 0.2 0 0.2 0.4 0.6 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 0.6 0.4 0.2 0 0.2 0.4 0.6 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 18
C 2 Hermite interpolation in the plane preimage hodograph P Hcurve z(t) χ z 2 (t) = p (t) p(t) find conditions { P 0, V 0, A 0 } P 1, V 1, A 1 Given: 6 conditions (complex valued). We can choose the integration constant (responsible for p(0) = P 0 ). z(t) must have 5 degrees of freedom polynomial of degree 4. We will use the Bernstein basis on the interval t [0, 1] z(t) = 4 z i Bi 4 (t), where z i C and Bi n = i=0 ( ) n t i (1 t) n i. i 19
C 2 Hermite interpolation in the plane Conditions for the preimage: z(t) = 4 z i Bi 4 (t) i=0 z 2 0 = V 0, z 2 4 = V 1, 8z 0 (z 1 z 0 ) = A 0, 8z 4 (z 4 z 3 ) = A 1, and (12z 2 + 10z 1 + 5z 0 + 5z 4 + 10z 3 ) 2 = 2520(P 1 P 0 ) 435(V 1 + V 0 ) + 45 2 (A 1 A 0 ) (60z 2 1 60z 0 z 3 60z 1 z 4 + 60z 2 3 42z 0 z 4 72z 1 z 3 ). We can solve successively quadratic and linear equation in C obtaining 8 different preimages z(t) and 4 different interpolants p(t). (±z(t) give the same curve). 20
Example Four interpolants to the C 2 data P 0 = 0, V 0 = 1, A 0 = i P 1 = 1 + i, V 1 = 1, A 1 = i. 1 1 1 1 0.8 0.8 0.8 0.8 0.6 0.6 0.6 0.6 0.4 0.4 0.4 0.4 0.2 0.2 0.2 0.2 0 0 0 0 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 There are also four quintic PH interpolants to any C 1 data. In the space - infinite systems of interpolants. 21
Choosing the best solution Three approaches: Aposteriori evaluation of some measure (bending energy, etc.) Apriori analysis: Absolute - only available for C 1 interpolation in the plane using the winding number (Moon, Farouki, Choi 2001) Asymptotical - can be applied quite generally 22
Problems with labeling The notion of best solution and even the labeling of the four solutions can not be continuous for all data. 23
Problems with labeling 1.2 1 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 1.2 23-a
Problems with labeling 1.2 1 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 1.2 23-b
Problems with labeling 1.2 1 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 1.2 23-c
Problems with labeling 1.2 1 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 1.2 23-d
Problems with labeling 1.2 1 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 1.2 23-e
Problems with labeling 1.2 1 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 1.2 23-f
Problems with labeling 1.2 1 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 1.2 23-g
Problems with labeling 1.2 1 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 1.2 23-h
Approximation order Theorem: The error of the PH interpolation max c(t) p(t) t [0,1] converges to 0 as O(h 6 ) only for the first solution, otherwise it converges to 0 only as O(h 1 ). Numerical Example: curve C(t) = (1.5 sin(7.2t), cos(9t), e cos(1.8t) ). #Segments Error Ratio #Segments Error Ratio 1 1.449 32 1.144 10 5 27.33 2 8.816 10 1 1.643 64 2.287 10 7 50.04 4 6.963 10 2 12.66 128 3.770 10 9 60.65 8 7.243 10 3 9.613 256 6.027 10 11 62.56 16 3.128 10 4 23.16 512 9.436 10 13 63.87 24
Asymptotical shapes of C 1 interpolants Asymptotical shape of the first interpolant is smooth, the other limit shapes have singularities within the interval [0, 1]. 0.1 0.1 0.1 0.1 0 0 0 0 0.1 0.1 0.1 0.1 ts ps 0.2 PSfrag replacements cusps 0.2 PSfrag replacements cusps sp 0.3 0 0.2 0.4 0.6 0.8 1 cusp 0.3 0 0.2 0.4 0.6 0.8 1 cusp 0.3 0 0.2 0.4 0.6 0.8 1 cusp 0.3 0.2 PSfrag replacements cusps 0.2 0 0.2 0.4 0.6 0.8 1 1 1 1 1 0.5 0.5 0.5 0.5 0 0 0 0 ts ps sp 0.5 1 PSfrag replacements cusps 0 0.5 1 1.5 2 cusp 0.5 1 PSfrag replacements cusps 0 0.5 1 1.5 2 cusp 0.5 1 PSfrag replacements cusps 0 0.5 1 1.5 2 cusp 0.5 1 0 0.5 1 1.5 2 25
Rounding the G-code 0.6 0.6 0.4 0.4 0.2 0.2 0 0 0.2 0.2 0.4 0.4 0.6 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 0.6 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 Suppose given a G 1 continuous biarc with the radii R l, R r and the angle between the planes of arcs is α. If h < 1 3 π min( R l, R r ), then the error of replacing the segment joint by the interpolant p 0,0,0,0 to the points at arc-length distance h from the joint is bounded by ( 0.016 Rl R r + R r R l 2 cos(α) ) h 2 + 0.004 (R l + R r ) 5 h6. (1) 26
Future work Industrial implementation and related problems - under way in cooperation with Dr. Elmar Wings, ProCom GmbH (Aachen, Germany). 27
Future work Industrial implementation and related problems - under way in cooperation with Dr. Elmar Wings, ProCom GmbH (Aachen, Germany). C 1 boundary conditions: (Farouki & Neff, 1995) in the plane, (Farouki, al-kandari, Sakkalis, 2002) in the space. C 2 boundary conditions: (Z. Š. & B.J. 2005) From the C 2 interpolation follows the C k interpolation in general 27-a
Future work Industrial implementation and related problems - under way in cooperation with Dr. Elmar Wings, ProCom GmbH (Aachen, Germany). C 1 boundary conditions: (Farouki & Neff, 1995) in the plane, (Farouki, al-kandari, Sakkalis, 2002) in the space. C 2 boundary conditions: (Z. Š. & B.J. 2005) From the C 2 interpolation follows the C k interpolation in general C k Hermite interpolation by PH curves, Z. Š & B.J., 2003 + k 27-b
Future work Industrial implementation and related problems - under way in cooperation with Dr. Elmar Wings, ProCom GmbH (Aachen, Germany). C 1 boundary conditions: (Farouki & Neff, 1995) in the plane, (Farouki, al-kandari, Sakkalis, 2002) in the space. C 2 boundary conditions: (Z. Š. & B.J. 2005) From the C 2 interpolation follows the C k interpolation in general C k Hermite interpolation by PH curves, Z. Š & B.J., 2003 + k Approximation with PH curves. 27-c
Future work Industrial implementation and related problems - under way in cooperation with Dr. Elmar Wings, ProCom GmbH (Aachen, Germany). C 1 boundary conditions: (Farouki & Neff, 1995) in the plane, (Farouki, al-kandari, Sakkalis, 2002) in the space. C 2 boundary conditions: (Z. Š. & B.J. 2005) From the C 2 interpolation follows the C k interpolation in general C k Hermite interpolation by PH curves, Z. Š & B.J., 2003 + k Approximation with PH curves. Surfaces with rational unit normal field. 27-d
Thank you for your attention!