1 Introduction

Linear tool path is the most widespread tool path representation form to approximate the complicated surface in machining; however, it introduces both the tangent and curvature discontinuities at the segment junctions. The inherent shortcomings are the most important sources of feed fluctuation. With the development of machining technology in modern industry, CNC machine tools ask for high interpolation technology, but linear tool path cannot satisfy the requirements of high-speed and high-accuracy machining. Though look-ahead scheme has been integrated in current CNC systems to alleviate the frequent start and stop, the discontinuous still cause the fluctuations of feed speed and acceleration [1, 2]. Smoothing the linear tool path with parametric curves is an important way to reduce the feed fluctuation and improve the machining efficiency.

To achieve the smoothness of the linear tool path, two major approaches, i.e., curve fitting ones and transition ones, have been proposed in the previous studies to convert the linear segments to parametric splines. The fitting methods, including approximation algorithms and interpolation algorithms, are adopted by some advanced CNC systems. Local transition is mainly through the use of other curves to replace the original linear trajectory in the corner to achieve the purpose of smoothness [3,4,5,6,7,8,9,10,11]. Zhang et al. [3], proposed a transition algorithm for two continuous linear segments based on the cubic Hermite curve fitting approach. This algorithm guaranteed the tangent continuity of the new tool path. Bi et al. [4, 5], applied a cubic Bézier curve, whose middle two control points are identical, to realize continuous-curvature path-smoothing. An optimization problem needs to be solved to estimate the proper transition lengths. Zhao et al. [6] proposed a method for smoothing the linear tool path by using two transition cubic Bézier curves. One cubic Bézier curve smoothes the tool tip position path, and the other smoothes the orientation vector of tool axis. Zhao et al. [7], Sneha et al. [8] and Sun et al. [9] used a B-spline to round the corner. The approximation error at the rounded corner can be exactly controlled by the distribution of the control points. Shi et al. [10, 11], proposed a corner smoothing method for linear tool path based on quintic PH curve, which can restrict the approximation error exactly. Although the above transition methods can smooth the linear path, they increased the amount of data, shortened the lengths of the segments, and aggravated the computation burden of the system. Another solution is the global smoothing, which can fit a series of given points into a smooth parametric curve and can compress the data of the linear tool path. B-spline and NURBS, which have good smoothness characteristic and compression ratio, have received the widespread attention [12,13,14,15,16,17,18,19]. Yau and Kuo [12] proposed an offline NURBS fitting algorithm based on least square method. Wang and Yau [13] proposed a real-time look-ahead NURBS interpolation method. This method can fit consecutive short segments into NURBS online and can guarantee the C2 continuity. Yeh and Su [14] designed an optimization search method to determine the NURBS order and the number of basis functions. Zhang et al. [15] adopts adaptive method to look for geometric feature points, and group a series of given points according to the feature points. This method improves the fitting efficiency. However, NURBS fitting methods have the following deficiencies: 1) heavy computational complexity of recursive algorithm, which is difficult to meet the real-time requirements of system; 2) inevitable errors introduced by employing a truncated Taylor series. In addition, some researchers have proposed the other parametric curves. Yau and Wang [16] proposed a real-time fast Bézier interpolation method. Its compression ratio is low, and tangency and curvature of the junction between adjacent curves are discontinuous. Wang et al. [17] presented an Akima curve fitting method, but it had large amount of calculation to obtain the slope vector of Akima curve. Tasi et al. [18] proposed a C2 continuous Bézier fitting method, but this method increased the amount of data. Zhang et al. [19] presented a five-order polynomial to ensure machining path of C2 continuity, but it had large amount of calculation and poor real-time performance.

In this paper, an optimal feed interpolator based on G2 Bézier transition algorithm is proposed to fit the linear tool path, which can satisfy the following requirements: 1) G2 continuity; 2) data compression; 3) approximation control; 4) real-time performance. The remainder of this paper is organized as follows: Section 2 presents the G2 continuous Bézier fitting algorithm based on least square method. Section 3 describes the proposed interpolator. Section 4 provides the simulation and experiment. Section 5 concludes the paper.

2 G2 Continuity Bézier Fitting Method

In this section, a G2 continuous Bézier fitting algorithm based on least square method is deduced. Firstly, several basic concepts, such as geometric continuity, cubic Bézier, consecutive short segment and breakpoint, are described. Then, a cubic Bézier curve is used to approximate the consecutive short segments based on Least Squares method, and the approximation error is calculated and restricted within a given tolerance. At last, the linear tool path is transformed to a G2 continuous path.

2.1 Definitions of G2 Continuity and Cubic Bézier

Continuity is basically a measure of the smoothness of a piecewise curve at its joining points. DeRose and Barsky [20] defined the order of smoothness by parametric and geometric continuity. Here geometric continuity is used to smooth the piecewise linear tool path. G1 continuity is the first-order geometric continuity, which refers to continuity of the unit tangent, and G2 continuity is the second-order geometric continuity, which refers to continuity of the curvature vectors at the joint.

In this research, a cubic Bézier curve, which is G2 continuous, is adopted to fit consecutive short segments (CSSs) together. The cubic Bézier is given by Farin [21] as:

$$C\left( t \right) = \sum\limits_{0}^{3} {\left( {\begin{array}{*{20}c} 3 \\ i \\ \end{array} } \right)} B_{i} t^{i} \left( {1 - t} \right)^{3 - i} ,\quad 0 \le t \le 1,$$
(1)

where t is the curve parameter and {Bi} are the control points.

Assuming that the two middle control points are the same, B1=B2=B12, the cubic Bézier is simplified as:

$$C\left( t \right) = \left( {1 - t} \right)^{3} B_{0} + 3t\left( {1 - t} \right)B_{12} + t^{3} B_{3} ,\quad \left( {0 \le t \le 1} \right) ,$$
(2)

The first and second derivatives of the Bézier curve at t= 0 and t= 1 are calculated as follows:

$$C^{\prime}\left( 0 \right) = 3\left( {B_{12} - B_{0} } \right),\quad C^{\prime}\left( 1 \right) = 3\left( {B_{3} - B_{12} } \right),$$
(3)
$$C^{\prime\prime}\left( 0 \right) = 6\left( {B_{0} - B_{12} } \right),\quad C^{\prime\prime}\left( 1 \right) = 6\left( {B_{3} - B_{12} } \right).$$
(4)

Then, the curvatures of the Bézier curve at t= 0 and t= 1 are obtained:

$$\kappa \left( t \right) = \frac{{\left\| {C^{\prime}\left( t \right) \times C^{\prime\prime}\left( t \right)} \right\|}}{{\left\| {C^{\prime}\left( t \right)} \right\|^{3} }}.$$
(5)

Substituting Eqs. (3) and (4) into Eq. (5), \(\kappa \left( 0 \right) = \kappa \left( 1 \right) = 0\). The curvature is continuous and there is only one curvature extremum in the Bézier curve.

2.2 Definitions of Consecutive Short Segment and Breakpoint

In order to obtain good accuracy, the corner constraint and the bi-chord error constraint must be taken into consideration before least square curve approximation is used to fit linear segments. Yau and Wang [16] proposed an isosceles triangle method to compute the bi-chord errors, which are illustrated in Figure 1.

Figure 1
figure 1

An isosceles triangle method to compute the bi-chord errors

The corner of the two adjacent line segments \(Q_{k - 1} Q_{k}\) and \(Q_{k} Q_{k + 1}\) is calculated as:

$$\theta_{k} = \arccos \left( {\frac{{\overrightarrow {{Q_{k - 1} Q_{k} }} \cdot \overrightarrow {{Q_{k} Q_{k + 1} }} }}{{\left\| {\overrightarrow {{Q_{k - 1} Q_{k} }} } \right\| \cdot \left\| {\overrightarrow {{Q_{k} Q_{k + 1} }} } \right\|}}} \right).$$
(6)

The bi-chord errors \(\delta_{1}\) and \(\delta_{2}\) are calculated as follows:

$$\delta_{1} = R\left( {1 - \cos \phi_{1} } \right),$$
(7)
$$\delta_{2} = R\left( {1 - \cos \phi_{2} } \right) = R\left( {1 - \cos \left( {\theta_{k} - \phi_{1} } \right)} \right),$$
(8)

where, \(l_{k} = \left\| {Q_{k - 1} Q_{k} } \right\|\), \(l_{k + 1} = \left\| {Q_{k} Q_{k + 1} } \right\|\), \(\phi_{1} + \phi_{2} = \theta_{k}\), \(R = \frac{{l_{k} }}{{2\sin \phi_{1} }}\), \(\phi_{1} = \arctan \left( {\frac{{l_{k} \sin \theta_{k} }}{{l_{k + 1} + l_{k} \cos \theta_{k} }}} \right).\)

The criterions of the corner constraint and the bi-chord error constraint are set to \(\theta_{\text{max} }\) and \(\varepsilon_{\text{max} }\). If \(\theta_{k} \le \theta_{\text{max} }\), and \(\delta_{1} \le \varepsilon_{\text{max} }\), and \(\delta_{2} \le \varepsilon_{\text{max} }\), the adjacent line segments \(Q_{k - 1} Q_{k}\) and \(Q_{k} Q_{k + 1}\) are CSSs and can be fitted into Bézier; otherwise, the given point \(Q_{k}\) is set to be a breakpoint.

2.3 Bézier Curve Fitting Based on Least Squares (LS) Method

To achieve the smoothness of the linear tool path, there are two major approaches, i.e., interpolation and approximation. In interpolation a curve which satisfies the given data precisely is constructed. The curve passes through all the given points. In approximation a curve which does not necessarily satisfy the given data precisely is constructed.

In this section, the LS fitting method is used to approximate the consecutive short segments. Compared with the interpolation curve, the curvature changes of the approximation curve are less. Moreover, it has a higher compression ratio.

As shown in Figure 2, \(\{ Q_{i} \} (i = 0,1, \ldots ,m)\) are the given points generated by CAM software and meet the criterions of the corner constraint and the bi-chord error constraint. These points can be fitted into a cubic Bézier curve \(C\left( t \right)\) by using LS method. \(\{ B_{i} \} (i = 0,1,2,3)\) are the four corresponding control points. Assuming that \(B_{0} = Q_{0}\), \(B_{ 3} = Q_{m}\), \(B_{ 1} = B_{ 2} = B_{12}\), only the point \(B_{ 1 2}\) needs to be determined.

Figure 2
figure 2

Get Bézier curve by the least square fitting method

Supposing that:

$$F(B_{12} ) = \sum\limits_{i = 0}^{m} {(C(t_{i} )} - Q_{i} )^{2} ,$$

where \(C\left( {t_{i} } \right)(i = 0,1, \ldots ,m)\) are the points on the curve corresponding to \(Q_{i}\). Parameters \(\left\{ {t_{i} } \right\}\) are computed by chord length parameterization method [22]:

$$\left\{ \begin{aligned} & t_{0} = 0, \hfill \\ & t_{m} = 1, \hfill \\ & t_{i} = t_{i - 1} + \frac{{\left\| {Q_{i} - Q_{i - 1} } \right\|}}{L}, \hfill \\& L = \sum\limits_{i = 1}^{m} {\left\| {Q_{i} - Q_{i - 1} } \right\|} , \hfill \\ \end{aligned} \right.\quad i = 1,2, \ldots ,m.$$
(9)

According to the extreme conditions of continuous function, when \(\text{d}F/\text{d}B_{12} = 0,\) \(F(B_{12} )\) achieves the minimum:

$$\frac{{{\text{d}}F}}{{{\text{d}}B_{12} }} = \sum\limits_{i = 0}^{m} {[6t_{i} (1 - t_{i} )(C(t_{i} ) - Q_{i} )] = 0} .$$
(10)

Thus, B12 can be formulated as follows:

$$B_{12} = \frac{{\sum\limits_{i = 0}^{m} {\left( {t_{i} \left( {1 - t_{i} } \right)Q_{i} - t_{i} \left( {1 - t_{i} } \right)^{4} B_{0} - t_{i}^{4} \left( {1 - t_{i} } \right)B_{3} } \right)} }}{{3\sum\limits_{i = 0}^{m} {t_{i}^{2} \left( {1 - t_{i} } \right)^{2} } }}.$$
(11)

2.4 Approximation Error Control

Restricting the approximation error within a given tolerance is a key problem in tool path fitting process. Thus, it is of great importance to analyze and restrict the deviations between the original and fitted tool path. When \(\varepsilon \left( {Q_{i} } \right)\) denotes the approximation error of \(C\left( t \right)\) with respect to \(Q_{i}\), the common computation methods are as follows.

  1. (1)

    \(\varepsilon \left( {Q_{i} } \right)\) denotes the distance between \(Q_{i}\) and \(C(t)\). \(\varepsilon \left( {Q_{i} } \right)\) is calculated by iterative algorithm as there is no analytical solution. It is difficult to satisfy the real-time computing in the CNC system.

  2. (2)

    Define that \(\left\| {Q_{i} - C\left( {t_{i} } \right)} \right\| = \varepsilon \left( {Q_{i} } \right)\), but \(C(t_{i} )\) may not the nearest point on \(C(t)\) with respect to \(Q_{i}\). This definition cannot meet the accurate requirement of CNC system.

In this paper, the method developed by Zhu et al. [23] is adopted to calculate \(\varepsilon \left( {Q_{i} } \right)\).

As shown in Figure 3, \(Q_{i}\) is the given point, and \(C(t_{i} )\) is the point on the curve corresponding to \(Q_{i}\). \(t_{i}\) is calculated by Eq. (9). \(\varvec{D} = Q_{i} - C(t_{i} )\). T is the unit tangent vector at position \(C(t_{i} )\). C is the projection on the main plan of D at \(C(t_{i} )\). \(C(t^{\prime}_{i} )\) is the nearest point on \(C(t)\) with respect to \(Q_{i}\). \(\varepsilon \left( {Q_{i} } \right) = \left\| {Q_{i} - C\left( {t^{\prime}_{i} } \right)} \right\|\).

Figure 3
figure 3

Control of the fitting error

According to Ref. [24], \(\varepsilon (Q_{i} )\) is formulated as:

$$\varepsilon (Q_{i} ) = D_{C} - \frac{{\kappa (D_{T} )^{2} \varvec{C} \cdot \varvec{N}}}{{2(1 - \kappa D_{C} \varvec{C} \cdot \varvec{N})}} + o^{3} (D_{T} ),$$
(12)

where κ is the curvature at \(C(t_{i} )\), DT and DC are the projection lengths of D on T and C respectively:

$$D_{T} = \varvec{D} \cdot \varvec{T} ,$$
(13)
$$D_{C} = \frac{{\varvec{D} \cdot \varvec{C}}}{{\left\| \varvec{C} \right\|}}.$$
(14)

\(C(t)\), κ, T, N and C can be computed by analytical formulations. The equations are all established with respect to parameter \(t \in [0,1]\). κ is calculated by Eq. (5), and T is calculated by:

$$\varvec{T} = \frac{{\varvec{C^{\prime}}\text{(}t\text{)}}}{{\left\| {\varvec{C^{\prime}}\text{(}t\text{)}} \right\|}}.$$
(15)

Based on Frenet moving frame and Gramm–Schmidt orthogonalization, N and C are formulated:

$$\varvec{N} = \frac{{{\varvec{C^{\prime\prime}}(t)} - (\varvec{C^{\prime \prime}}(t) \cdot \varvec{T})\varvec{T}}}{{\left| {\varvec{C^{\prime\prime}}(t) - (\varvec{C^{\prime \prime}}(t) \cdot \varvec{T})\varvec{T}} \right|}},$$
(16)
$$\varvec{C} = \frac{{\varvec{D} - D_{T} \varvec{T}}}{{D_{C} }},$$
(17)

where \(\varvec{C^{\prime}}(t)\) and \(\varvec{C^{\prime\prime}}(t)\) are the first and second order derivatives of \(C(t)\).

Substituting Eqs. (13)‒(17) into Eq. (12), the approximation errors \(\left\{ {\varepsilon (Q_{i} )} \right\}\) can be obtained. If \(\left\{ {\varepsilon (Q_{i} )} \right\}\) are all smaller than the given tolerance \(\varepsilon_{\text{max} }\), the fitting curve is obtained; otherwise, if \(\varepsilon (Q_{i} ) > \varepsilon_{\text{max} }\), the given point \(Q_{i}\) is set to be a breakpoint, and the points between two adjacent breakpoints are fitted into a new Bézier curve again.

2.5 G2 Continuous Path Construction

Through the above method, a series of cubic Bézier curves are generated. However, the junction between adjacent Bézier curves is only G0 continuous. In order to construct a whole G2 continuous tool path, the junction between adjacent Bézier curves should be smoothed.

As shown in Figure 4(a), assuming that \(C_{1} \left( t \right)\) and \(C_{2} \left( t \right)\) are two neighboring Bézier curves, and their control points are \(\left\{ {P_{i}^{1} } \right\}\) and \(\left\{ {P_{i}^{2} } \right\}\) respectively, \(P_{3}^{1}\) is consistent with \(P_{0}^{2}\) at the point \(Q_{k}\). \(C_{1} \left( t \right)\) and \(C_{2} \left( t \right)\) just touch at the join point.

Figure 4
figure 4

Continuity of connected Bézier curves

As shown in Figure 4(b), \(P_{3}^{1}\) is inconsistent with \(P_{0}^{2}\), \(P_{3}^{1} = Q_{k}\), \(P_{0}^{2} = Q_{k + 1}\). A cubic Bézier transition curve \(C_{12} \left( t \right)\) is constructed between the \(Q_{k}\) and \(Q_{k + 1}\). Its control points are \(\left\{ {P_{i}^{12} } \right\}\), \(P_{0}^{12} = Q_{k}\), \(P_{3}^{12} = Q_{k + 1}\), \(P_{1}^{12} = P_{2}^{12} = P_{12}^{12}\). \(P_{12}^{12}\) is the intersection of line \(P_{12}^{1} P_{3}^{1}\) extension and line \(P_{12}^{2} P_{0}^{2}\) extension. The proof for G2 continuity between \(C_{1} \left( t \right)\) and \(C_{12} \left( t \right)\) is shown as follows.

(1) G0 continuity:

$$C_{1} \left( 1 \right) = C_{12} \left( 0 \right) = Q_{k} .$$

(2) G1 continuity:

$$\left. {\begin{array}{*{20}c} {C^{\prime}_{1} (1) = 3(P_{3}^{1} - P_{12}^{1} )} \\ {C^{\prime}_{12} (0) = 3(P_{12}^{12} - P_{0}^{12} )} \\ \end{array} } \right\} \Rightarrow C^{\prime}_{1} (1)//C^{\prime}_{12} (0).$$

(3) G2 continuity:

$$\left. {\begin{array}{*{20}c} {C^{\prime\prime}_{1} (1) = 6(P_{3}^{1} - P_{12}^{1} )} \\ {C^{\prime\prime}_{12} (0) = 6(P_{0}^{12} - P_{12}^{12} )} \\ \end{array} } \right\} \Rightarrow \kappa^{1} (1) = \kappa^{12} (0) = 0.$$

Thus, \(C_{1} \left( t \right)\) touches \(C_{12} \left( t \right)\) with G2 continuity. In the same way, \(C_{2} \left( t \right)\) touches \(C_{12} \left( t \right)\) with G2 continuity. The whole tool path is G2 continuous.

At the same time, the approximation of the transition curve \(C_{12} \left( t \right)\) should be checked. According to Ref. [4], \(C_{12} \left( {0.5} \right)\) is the farthest point from curve \(C_{12} \left( t \right)\) to line \(Q_{k} Q_{k + 1}\). The distance from \(C_{12} \left( {0.5} \right)\) to \(Q_{k} Q_{k + 1}\) is the maximum deviation from \(C_{12} \left( t \right)\) to \(Q_{k} Q_{k + 1}\). If the deviation error is bigger than \(\varepsilon_{\text{max} }\), the transition curve \(C_{12} \left( t \right)\) is cancelled and the line \(Q_{k} Q_{k + 1}\) is used to connect \(Q_{k}\) and \(Q_{k + 1}\).

3 Optimal Feed Interpolation Algorithm

For interpolating the smoothed tool path, a real-time adaptive feedrate scheduling method considering the comprehensive constraints is proposed. Firstly, the comprehensive constraints (such as the chord error constraint, the maximum normal acceleration, servo capacity of each axis) are deduced to obtain the maximum feed and feasible acceleration range. On this basis, the optimal feed interpolator is introduced.

3.1 Comprehensive Constrains

3.1.1 Constraint of Chord Error

As shown in Figure 5, when a cutting tool moves linearly between contiguous interpolated points of the ith Bézier curve \(C_{i} \left( t \right)\), contour error may occur. The chord error is the maximum distance between the curve segment and the chord. To confine the chord error within a given tolerance value εmax, the feedrate is determined with an arc approximation method [25].

Figure 5
figure 5

Chord error on the Bézier curve

$$f_{i} \left( t \right) \le f_{ch} \left( t \right) = \frac{2}{{T_{s} }}\sqrt {\rho_{i}^{2} \left( t \right) - \left( {\rho_{i} \left( t \right) - \varepsilon_{\text{max} } } \right)^{2} } ,$$
(18)

where Ts is the interpolation period of CNC system, and ρi(t) is called the radius of curvature.

3.1.2 Constraint of Maximum Normal Acceleration

The feedrate is also limited by the maximum normal acceleration Amax of the machine tool:

$$f_{i} \left( t \right) \le f_{An} \left( t \right) = \sqrt {\rho_{i} \left( t \right)A_{\text{max} } } .$$
(19)

3.1.3 Constraint of Servo Capacity of Each Axis

One important error source in high-speed contouring is the error that results when the command input for each axis exceeds the acceleration/deceleration capacity of the servo system. To decrease this kind of error, the machine dynamics [26], including the constraints of velocity and acceleration represented by upper bounds for each axis, are taken into account.

Now suppose the feedrate of the tool tip is denoted as fi(t) and the displacement of the axis Λ (Λ=X, Y, Z) is denoted as θΛ,i(t). The feed of the axis Λ can be expressed as:

$$v_{\varLambda ,i} \left( t \right) = \dot{\theta }_{\varLambda ,i} \left( t \right){\kern 1pt} = \frac{1}{{\sigma_{i} \left( t \right)}}\theta^{\prime}_{\varLambda ,i} \left( t \right)f_{i} \left( t \right) = k_{v\varLambda i} f_{i} \left( t \right),$$
(20)

where \(k_{v\varLambda i} = \theta^{\prime}_{\varLambda ,i} \left( t \right)/\sigma_{i} \left( t \right)\). \(\sigma_{i} \left( t \right)\) is the arc-length of tool tip point curve \(C_{i} \left( t \right)\) at parameter t\(\sigma_{i} \left( t \right) = s_{i}^{\prime } = \left| {C_{i}^{\prime } \left( t \right)} \right|\).

The velocity limit of the axis Λ is denoted as VΛm. The velocity of the axis Λ should be restricted by:

$$\left| {v_{\varLambda ,i} \left( t \right)} \right| = \left| {k_{v\varLambda i} f_{i} \left( t \right)} \right| = \left| {k_{v\varLambda i} } \right|f_{i} \left( t \right) \le V_{\varLambda m} .$$
(21)

Then, the feedrate of the tool tip is restricted by:

$$f_{i} \left( t \right) \le f_{vm} \left( t \right) = \mathop {\text{min} }\limits_{\varLambda = X,Y,Z} \left\{ {\frac{{V_{\varLambda m} }}{{\left| {k_{v\varLambda i} } \right|}}} \right\}.$$
(22)

Next, the acceleration of the axis Λ along the curve can be calculated by taking the derivative with respect to time of Eq. (20):

$$a_{\varLambda ,i} \left( t \right) = \dot{v}_{\varLambda ,i} \left( t \right) = k_{aa\varLambda i} a_{ti} \left( t \right) + k_{av\varLambda i} f_{i} \left( t \right)^{2} ,$$
(23)

where \(k_{aa\varLambda i} = \frac{{\theta^{\prime}_{\varLambda ,i} \left( t \right)}}{{\sigma_{i} \left( t \right)}}\), \(k_{av\varLambda i} = \frac{{\sigma_{i} \left( t \right)\theta^{\prime\prime}_{\varLambda ,i} \left( t \right) - \sigma^{\prime}_{i} \left( t \right)\theta^{\prime}_{\varLambda ,i} \left( t \right)}}{{\sigma_{i} \left( t \right)^{3} }}\).

If the acceleration limit for axis Λ is specified as − aΛm and aΛm, the feed rate fi(t) and tangent acceleration ati(u) can be constrained as:

$$\begin{aligned} & f_{i} \left( t \right) \le f_{am} \left( t \right) \\ & = \mathop {\text{max} }\limits_{i \ne j \ne k}^{{i,j,k \in \left\{ {X,Y,Z} \right\}}} \left\{ {f\left( {i,j} \right)\left| { - a_{km} \le k_{aak} a_{f} \left( {i,j} \right) + k_{avk} f^{2} \left( {i,j} \right) \le a_{km} } \right.} \right\}, \\ \end{aligned}$$
(24)
$$a_{f\text{min} } \left( {t,f} \right) \le a_{f} \le a_{f\text{max} } \left( {t,f} \right),$$
(25)

where

$$a_{f\text{max} } \left( {t,f} \right) = \text{min} \left\{ \begin{aligned} \mathop {\text{min} }\limits_{\varLambda = X,Y,Z} \left\{ {\frac{{a_{\varLambda m} - k_{av\varLambda } f^{2} }}{{k_{aa\varLambda } \left( t \right)}}\left| {k_{av\varLambda } > 0} \right.} \right\}, \hfill \\ \mathop {\text{min} }\limits_{\varLambda = X,Y,Z} \left\{ {\frac{{ - a_{\varLambda m} - k_{av\varLambda } f^{2} }}{{k_{aa\varLambda } \left( t \right)}}\left| {k_{av\varLambda } < 0} \right.} \right\} \hfill \\ \end{aligned} \right\},$$
(26)
$$a_{f\text{min} } \left( {t,f} \right) = \text{min} \left\{ \begin{aligned} \mathop {\text{max} }\limits_{\varLambda = X,Y,Z} \left\{ {\frac{{ - a_{\varLambda m} - k_{av\varLambda } f^{2} }}{{k_{aa\varLambda } \left( t \right)}}\left| {k_{av\varLambda } > 0} \right.} \right\} \hfill \\ \mathop {\text{max} }\limits_{\varLambda = X,Y,Z} \left\{ {\frac{{a_{\varLambda m} - k_{av\varLambda } f^{2} }}{{k_{aa\varLambda } \left( t \right)}}\left| {k_{av\varLambda } < 0} \right.} \right\} \hfill \\ \end{aligned} \right\}.$$
(27)

3.1.4 The Maximum Feed Restricted by Comprehensive Constraints

Considering the command feed rate Fcmd at the same time, the maximum feasible feed flim(t) is obtained as follows:

$$f_{i} \left( t \right) \le f_{\lim } \left( t \right) = \text{min} \left\{ {f_{ch} ,f_{An} ,f_{vm} ,f_{am} ,F_{cmd} } \right\}.$$
(28)

3.2 Optimal Feed Interpolator

The proposed interpolator respects both tool path contour constraints and machine dynamics constraints. A look-ahead scheme is utilized to improve the calculation performance for real-time application [27]. The proposed interpolator includes four tasks: fitting the linear tool path with a series of cubic Bézier curves, obtaining limit feed profile, generating optimal feedrate profile using jerk-limited acceleration method [28], and generating the interpolating point. The detailed procedures for the proposed interpolator are shown in Figure 6.

Figure 6
figure 6

Flow chart for the proposed interpolator

  • Task 1: The first task of the proposed interpolator is to look-ahead N segments into FIFO (First-In First-Out) buffer, and fit the linear tool path with a series of G2 cubic Bézier curves.

  • Task 2: The second task of the proposed interpolator is to comprehensive constraints and obtain limit feed profile.

    $$f_{\lim } \left( t \right) = \text{min} \left\{ {f_{ch} ,f_{An} ,f_{vm} ,f_{am} ,F_{cmd} } \right\}.$$
  • Task 3: The third task of the proposed interpolator is to generate optimal feedrate profile using jerk-limited acceleration method. While the ith curve is being interpolated, the parameter, the feed and the acceleration of the jth sampling period are denoted as (t j i , f j i , a j i ). Task 3 includes the following three steps.

    • Step 1. A fixed jerk limit Jm is predefined by CNC system. Jerk-limited acceleration method is utilized to evaluate the feed of the (j+1)th sampling period.

      At the accelerating stage, the acceleration of the (j+1)th sampling period is evaluated as:

      $$a_{i}^{j + 1} = \text{min} \left\{ {a_{f\text{max} } \left( {t,f_{i}^{j} } \right),a_{i}^{j} + J_{m} T_{s} ,A_{\text{max} } } \right\}.$$
      (29)

      At the decelerating stage, the acceleration of the (j+1)th sampling period is evaluated as:

      $$a_{i}^{j + 1} = \text{max} \left\{ {a_{f\text{min} } \left( {t,f_{i}^{j} } \right),a_{i}^{j} - J_{m} T_{s} , - A_{\text{max} } } \right\}.$$
      (30)

      Then, the feed of the (j+1)th sampling period is evaluated as:

      $$f_{i}^{j + 1} = f_{i}^{j} + a_{i}^{j + 1} T_{s} .$$
      (31)
    • Step 2. The parameter t j+1 i is calculated with the first-order Taylor’s expansion.

      $$t_{i}^{j + 1} = t_{i}^{j} + \frac{{f_{i}^{j + 1} T_{s} }}{{\sigma \left( {t_{i}^{j} } \right)}}.$$
      (32)
    • Step 3. The feed limit flim(t j+1 i ) is calculated with Eq. (28). If f j+1 i  ≤ flim(t j+1 i ), the optimal feed is obtained, otherwise, let f j+1 i  = flim(t j+1 i ) and go to Step 2.

  • Task 4: The fourth task of the proposed interpolator is to interpolate the current curve Ci(t). Substituting Eq. (32) into Eq. (2), the interpolating point Ci(t j+1 i ) is obtained. Then the motion command for each axis is updated finally.

4 Simulation and Experiment

In this section, two examples are adopted to demonstrate the advantages of the proposed algorithm. The first example mainly validates the compression effect and the approximation error control effect of the proposed fitting method, while the second example verifies validity of the proposed interpolator to reduce the feed fluctuation and improve the machining efficiency.

4.1 Example 1

A 2-D butterfly shape linear profile is taken for example to the compression effect of proposed algorithm. Its original linear tool path consists of 8799 linear segments. The corner constraint is set to be 20°, and the chord error constraint is set to be 0.01 mm. The verification results are shown in Figure 7. After fitting, 158 Bézier curves are generated and the average compression ratio is 55.6:1.

Figure 7
figure 7

A 2-D butterfly shape for validation

Three different curvature areas are selected and enlarged respectively. As shown in Figure 7(b), when the curvature is 0.52‒0.68 mm−1, the compression ratio is 14:1. As shown in Figure 7(c), when the curvature is 0.05‒0.8 mm−1, the compression ratio can reach 30.5:1. As shown in Figure 7(d), when the curvature is 0.01‒0.018 mm−1, the compression ratio can reach 84:1. Accordingly, the compression ratio of the Bézier curve is associated with curvature. The profile with smaller curvature has higher compression ratio.

As shown in Figure 8, the approximation errors of 158 Bézier curves are all within the given tolerance 0.01 mm.

Figure 8
figure 8

Approximation errors of the Bézier curve

4.2 Example 2

Simulation and experiment are performed on a three-axis XK714 CNC milling machine tool. The in-house-developed research CNC, which is PC-based, has an open architecture, and allows rapid implementation of the proposed interpolation algorithm. The CNC utilizes windows XP operating system embedding Venturecom’s RTX 6.1 which provides the real-time computation and multitasking.

This experiment demonstrates the advantages of the proposed interpolator by machining a scoop, shown in Figure 9. In the experiment, a cuboid stock made of aluminum is used. The command feedrate is set to 3000 mm/min, the maximum acceleration is set to 1.8×106 mm/min2, the maximum jerk is set to 1.35×109 mm/min3, and the sampling period Ts is 0.004 s. The corner constraint is set to be 20°, and the chord error constraint is set to be 0.01 mm. A flat end milling tool of diameter 10 mm is first used for rough machining. Then a 6-mm carbide ball-end cutter is used for finish machining.

Figure 9
figure 9

Machining a scoop mold on three-axis machine tool

There are 158665 segments for finish machining a scoop. A tool path consisted of 1308 linear segments is taken for example, as shown in Figure 10.

Figure 10
figure 10

A tool path for finish machining a scoop

Two interpolation methods are integrated into the open CNC system of the machine tool. Both two methods utilize jerk-limited acceleration method for speed planning. The first method adopts the direct linear interpolation with the look-ahead scheme. In the second method, the linear tool path is first fitted by the proposed algorithm, and then the feedrate is planned with the proposed interpolator.

As shown in Figure 11(a), two feedrate profiles are generated with respect to displacement. When the linear interpolator is used for machining, the feedrate fluctuates severely and the values are far from 3000 mm/min. When the proposed interpolator is used for machining, the feedrate profile is much smoother and closer to 3000 mm/min. The reason is that the proposed algorithm compresses and smooths the linear path effectively. As marked in the Figure 11(a), a mount of segments are compressed and smoothed.

Figure 11
figure 11

Feedrate profiles generated by two different interpolation methods

As shown in Figure 11(b), when the linear interpolator is used for machining, it needs 13610 interpolation periods, 54.44 s. When the proposed interpolator is used for machining, it needs 3337 interpolation periods, 13.348 s. Machining efficiency with the proposed interpolator is four times as it with the method.

The acceleration profiles corresponding to the two interpolation methods are shown in Figure 12. The noise for the first interpolation method is the biggest. The noise is mainly caused by the frequent impact effect because the acceleration and declaration occur in every segment junction. The proposed algorithm is helpful to smooth the normal acceleration. Jerk-limited acceleration method can guarantee the continuity of the tangential acceleration. The acceleration is then finally smoothed by combining the two methods. Figure 12 shows that the acceleration curve of the proposed method is smoother than that of the first method.

Figure 12
figure 12

Acceleration profiles generated by two different interpolation methods

4.3 Discussion

The results of simulation and experiment are similar, which shows that the proposed method can smooth the linear tool path with G2 continuity path and decrease the amount of segments. What’s more, the results of experiment demonstrate that the proposed method can reduce the fluctuations of feedrate and acceleration and improve machining efficiency for CNC machining of short line segments.

5 Summary and Conclusions

  1. (1)

    A G2 continuous Bézier fitting algorithm based on Least Squares method is proposed to smooth the consecutive short segments, and the approximation error is calculated and restricted within a given tolerance.

  2. (2)

    Cubic Bézier curve is used to smooth the junction between adjacent Bézier curves. And the linear tool path is transformed a new G2 continuous tool path.

  3. (3)

    A real-time adaptive feedrate scheduling method considering the comprehensive constraints is proposed to interpolate the new tool path.

  4. (4)

    Simulation and experiment are conducted. With the proposed methodology, the linear tool path can be compressed and fitted into the G2 continuous tool path. And, the feedrate and acceleration with the optimal feed interpolator are both smoothed, and the machining time is reduced.

  5. (5)

    In the future work, the real-time curvature-continuity transition algorithm for five-axis linear tool path will be studied. Besides the constraints of curvature-continuity and approximation error, the parametric synchronization of the position curve and the orientation curve must also be considered in five-axis NC machining.