## 1 Introduction
In order to improve the machining precision more effectively, the error compensation system needs to possess the capability to deal with this combination of error sources rather than a single one [16]. It is obvious that the complexity of this work would be multiplied. Apart from the above error compensation methods, there is another kind of method, which actively compensate errors from data analysis. For example, dimensional error of workpiece is the result of various error sources. The authors of [17] presented an intelligent pre-compensation method for dimensional error. A PD-type rule library is set up to compute the compensation of next workpiece according to the previous workpieces' dimensions. Similarly, a P-type self-learning updating law is proposed to compute compensation according to the previous dimension error in [18]. Both methods have set up the iterative updating law with the previous three-dimensional errors or just the previous one. The form of the two updating laws is similar to proportion integration differentiation (PID) control law. Our work focuses on the problem of dimensional error compensation in real CNC batch grinding, which is a meaningful and practical issue. For the data-driven methods, especially sliding mode terminal iterative learning methods, it is the first time they have been introduced in a CNC error compensation field. As the above mentioned, error sources are various and complex; furthermore, they are coupled to each other. Completely separating every error source is unrealistic. It is difficult to sense and model all error sources and model parameter identification is not easy. Its costs, including time and money, are very high. In CNC batch grinding, workpieces are grinded one by one, and terminal dimension data are easily obtained. With the data-driven compensation method, only one grating displacement sensor is used to measure the dimension, which does not need so many various sensors. Moreover, it does not need complex modeling and parameter identification. In practical application, the compensation is also easier to implement. Whether or not compensation is needed is determined before the workpiece machined. If it needs compensation, the compensation module is introduced and the compensated NC program is executed. Thus, it can be seen that compared with conventional compensation methods, data-driven compensation method has numerous advantages. The terminal iterative learning control (TILC) as a data-driven algorithm can converge to the desired output. It does not need to track the entire output trajectory in the finite time, only the terminal output needs to be tracked [19; 20]. Moreover, in view of its simple algorithm, strong robustness, and fast response, the sliding mode control (SMC) hasreceived more and more attention [21; 22]. Therefore, it is necessary to apply the two control strategies into batch grinding to improve dimension precision. This paper presents a dimensional error compensation method based on sliding mode terminal ILC under the data-driven design framework. Different from the upper methods in [17; 18], this method introduces a sliding surface, which is designed by the previous two-dimensional error. With the sliding surface, the dimensional error will quickly converge to zero after a number of iteration cycles. Consider the batch grinding system as a single input single output (SISO) nonlinear discrete-time system. Firstly, the nonlinear system is transferred into a linear system by using the dynamic linearization (DL) method [23]. Secondly, under the defined sliding surface, the terminal iterative learning law [24; 25; 26] is derived for the compensation system. Measurements of dimensions are used to compute compensation value according to the learning law. Finally, the NC program is modified to compensate the subsequent machining cycle. With this data-driven compensation method, the dimensional accuracy will be improved. The organization of the paper is shown as follows. Section 2 presents the grinding protocol and problem formulation.