Compensation of Rotary Encoders Using Fourier Expansion-Back Propagation Neural Network Optimized by Genetic Algorithm

The measurement accuracy of the precision instruments that contain rotation joints is influenced significantly by the rotary encoders that are installed in the rotation joints. Apart from the imperfect manufacturing and installation of the rotary encoder, the variations of ambient temperature could cause the angle measurement error of the rotary encoder. According to the characteristics of the 2π periodicity of the angle measurement at the stationary temperature and the complexity of the effects of ambient temperature changes, the method based on the Fourier expansion-back propagation (BP) neural network optimized by genetic algorithm (FE-GABPNN) is proposed to improve the angle measurement accuracy of the rotary encoder. The proposed method, which innovatively integrates the characteristics of Fourier expansion, the BP neural network and genetic algorithm, has good fitting performance. The rotary encoder that is installed in the rotation joint of the articulated coordinate measuring machine (ACMM) is calibrated by using an autocollimator and a regular optical polygon at ambient temperature ranging from 10 to 40 °C. The contrastive analysis is carried out. The experimental results show that the angle measurement errors decrease remarkably, from 110.2″ to 2.7″ after compensation. The mean root mean square error (RMSE) of the residual errors is 0.85″.


Introduction
The precision measuring instruments such as laser tracker, articulated coordinate measuring machine (ACMM) and total station are widely used in the area of field measurement for its portability. The rotation joint with high-accuracy angle sensor is the core component of these instruments. The angle measurement accuracy of angle sensors has great influence on the measurement performance of these precision instruments. Rotary encoders are widely used as high-accuracy angle sensors in these instruments. The ambient temperature in industrial site varies greatly from place to place. The measurement accuracy of these precision instruments is influenced greatly by ambient temperature. One main reason for this is that the angle measurement error induced by temperature will induce large measurement error of these instruments. Many methods have been developed to improve the angle measurement accuracy of the rotary encoder. The discrete angle measurement error values were obtained by the use of an autocollimator and a regular optical polygon to provide reference angle [1][2][3][4][5]. The eccentricity of the grating disk accounts for the majority of the angle measurement error. An eccentricity error model was built, and angle measurement accuracy was improved by compensating the eccentricity error [1][2][3]. Gao  The main contributions of this work are: (1) Through the experiments, it is found that the variations of ambient temperature could cause the significant angle measurement error of the rotary encoder installed in the ACMM; (2) a novel method based on the FE-GABPNN is proposed to compensate the angle measurement error of the rotary encoder. The Fourier expansion which is from 0 to 11 orders is used to build the error compensation model at the temperature of 20 • C without residual errors based on the character of periodicity of angle measurement errors. The improved BP neural network whose initial parameters are optimized by the genetic algorithm is used to compensate the angle measurement errors caused by ambient temperature ranging from 10 to 40 • C. The proposed method, which innovatively integrates the characteristics of Fourier expansion, BP neural network and genetic algorithm, especially has good performance in compensating the angle measurement errors of rotary encoders when the ambient temperature changes; (3) the method mentioned above has the potential of being applied to other precisions instruments which contain rotation joints, such as a laser tracker.

Rotary Encoder Installed in the Rotation Joint of ACMM
ACMM is a kind of precision measuring instrument in tandem structure and it contains six rotation joints installed with rotary encoders. The structure of the rotation joint is shown in Figure 1.
Sensors 2020, 20, x FOR PEER REVIEW 3 of 15 The main contributions of this work are: (1) Through the experiments, it is found that the variations of ambient temperature could cause the significant angle measurement error of the rotary encoder installed in the ACMM; (2) a novel method based on the FE-GABPNN is proposed to compensate the angle measurement error of the rotary encoder. The Fourier expansion which is from 0 to 11 orders is used to build the error compensation model at the temperature of 20 °C without residual errors based on the character of periodicity of angle measurement errors. The improved BP neural network whose initial parameters are optimized by the genetic algorithm is used to compensate the angle measurement errors caused by ambient temperature ranging from 10 to 40 °C. The proposed method, which innovatively integrates the characteristics of Fourier expansion, BP neural network and genetic algorithm, especially has good performance in compensating the angle measurement errors of rotary encoders when the ambient temperature changes; (3) the method mentioned above has the potential of being applied to other precisions instruments which contain rotation joints, such as a laser tracker.

Rotary Encoder Installed in the Rotation Joint of ACMM
ACMM is a kind of precision measuring instrument in tandem structure and it contains six rotation joints installed with rotary encoders. The structure of the rotation joint is shown in Figure 1. The reading head is installed on the mounting plate of the reading head that is installed on the shaft sleeve, the grating disk is installed on the rotating shaft. The reading head is stationary and the grating disk installed on the rotating shaft is rotated relative to the reading head. The rotary encoder is composed of the reading head and the grating disk. The model of the rotary encoder is the Mercury 3000 (Celera MOTION Company, Bedford, MA, USA, resolution is 0.39″, measuring range is 360°, measurement accuracy is ±2.1″ before calibration, output is A-quad-B and digital index window). The angle measurement errors of the rotary encoder are mainly caused by error motions of the rotating shaft, manufacturing and installation eccentricity of the grating disk, and variations of ambient temperature.

Fourier Expansion-BP Neural Network Optimized by Genetic Algorithm
The angle measurement error compensation model was established by FE-GABPNN method. The discrete angle measurement error values were calibrated by using an autocollimator and a regular optical polygon with 23 faces at temperatures of 10,15,20,25,30,35 and 40 °C separately. The repeated experiments were carried out three times at each temperature among the seven temperatures mentioned above. A total of ( ) 23   The reading head is installed on the mounting plate of the reading head that is installed on the shaft sleeve, the grating disk is installed on the rotating shaft. The reading head is stationary and the grating disk installed on the rotating shaft is rotated relative to the reading head. The rotary encoder is composed of the reading head and the grating disk. The model of the rotary encoder is the Mercury 3000 (Celera MOTION Company, Bedford, MA, USA, resolution is 0.39", measuring range is 360 • , measurement accuracy is ±2.1" before calibration, output is A-quad-B and digital index window). The angle measurement errors of the rotary encoder are mainly caused by error motions of the rotating shaft, manufacturing and installation eccentricity of the grating disk, and variations of ambient temperature.

Fourier Expansion-BP Neural Network Optimized by Genetic Algorithm
The angle measurement error compensation model was established by FE-GABPNN method. The discrete angle measurement error values were calibrated by using an autocollimator and a regular optical polygon with 23 faces at temperatures of 10,15,20,25,30,35 and 40 • C separately. The repeated experiments were carried out three times at each temperature among the seven temperatures mentioned above. A total of (23 × 7 × 3 =)483 data sets were obtained. Each data set included the ambient temperature T, the angular position of the rotary encoder θ and the relative discrete angle measurement error value ∆θ. The structure of the FE-GABPNN method is shown Figure 2. Based on the characteristics of angle measurement errors of the rotary encoders, the proposed method innovatively integrated the In the following subsections, Section 3.1 provides the details of the Fourier expansion, Section 3.2 introduces the details of the BP neural network and Section 3.3 introduces the details of the genetic algorithm.

Fourier Expansion
The characters of angle measurement errors are circle closure and periodicity [5]. Fourier expansion method is simple with good fitting accuracy when the ambient temperature is not changed. The average values of angle measurement errors calibrated at temperature of 20 °C were set as the basic angle measurement errors. The angle measurement error compensation model at the temperature of 20 °C was built by the Fourier expansion, as shown in Equation (1) The 23 discrete values were obtained in the calibration process, so the Fourier expansion which is from 0 to 11 orders can be used to fit the discrete angle measurement values without residual errors. The parameters 0 , , , 1, ,11

BP Neural Network
The improved BP neural network optimized by the genetic algorithm was used to compensate the angle measurement errors caused by the ambient temperature. The BP neural network is illustrated in the following section. The remained discrete angle measurement error values  In the following subsections, Section 3.1 provides the details of the Fourier expansion, Section 3.2 introduces the details of the BP neural network and Section 3.3 introduces the details of the genetic algorithm.

Fourier Expansion
The characters of angle measurement errors are circle closure and periodicity [5]. Fourier expansion method is simple with good fitting accuracy when the ambient temperature is not changed. The average values of angle measurement errors calibrated at temperature of 20 • C were set as the basic angle measurement errors. The angle measurement error compensation model at the temperature of 20 • C was built by the Fourier expansion, as shown in Equation (1): The 23 discrete values were obtained in the calibration process, so the Fourier expansion which is from 0 to 11 orders can be used to fit the discrete angle measurement values without residual errors. The parameters a 0 , a i , b i , i = 1, · · · , 11 were calculated based on the least-squares method by using the average discrete values ∆θ 20 k ·k = 1, 2, · · · , 23. The algorithm details of the least-squares method are introduced in Appendix A.

BP Neural Network
The improved BP neural network optimized by the genetic algorithm was used to compensate the angle measurement errors caused by the ambient temperature. The BP neural network is illustrated in the following section. The remained discrete angle measurement error values ∆θ m , m = 1, 2, · · · , 483 were obtained by subtracting the average discrete values ∆θ The structure of the BP neural network is shown in Figure 3. The BP neural network consists of one input layer, one hidden layer and one output layer. The remained discrete angle measurement error values were relative to the angular position and ambient temperature. So the input layer included two nodes, and the input variables were the angular position of rotary encoder θ and ambient temperature T. The output layer had one node and the predicted value was the compensation value of the angle measurement error ε(θ, T). There is no exact algorithm to determine the number of nodes of the hidden layer n [27]. Some empirical formulas are proposed to calculate the general number nodes of the hidden layer [28]. When the number of hidden layer nodes is small, the structure of the BP neural network is too simple to fit the discrete angle measurement error values properly. On the other hand, when there are too many nodes in the hidden layer, the BP neural network has the risk of overfitting. The number of hidden layer nodes is decided by the training results of the BP neural network, which is evaluated by the RMSE of the residual errors after compensation.
Sensors 2020, 20, x FOR PEER REVIEW 5 of 15 The structure of the BP neural network is shown in Figure 3. The BP neural network consists of one input layer, one hidden layer and one output layer. The remained discrete angle measurement error values were relative to the angular position and ambient temperature. So the input layer included two nodes, and the input variables were the angular position of rotary encoder θ and ambient temperature T . The output layer had one node and the predicted value was the compensation value of the angle measurement error ( , ) T ε θ . There is no exact algorithm to determine the number of nodes of the hidden layer n [27]. Some empirical formulas are proposed to calculate the general number nodes of the hidden layer [28]. When the number of hidden layer nodes is small, the structure of the BP neural network is too simple to fit the discrete angle measurement error values properly. On the other hand, when there are too many nodes in the hidden layer, the BP neural network has the risk of overfitting. The number of hidden layer nodes is decided by the training results of the BP neural network, which is evaluated by the RMSE of the residual errors after compensation.

Input layer Hidden layer
Output layer Further, ih v was the weight between the input layer and hidden layer; h ω was the weight between the hidden layer and output layer; h γ was the bias of the hidden layer; ϕ was the bias of the output layer. The input value of the neural cell of the hidden layer was calculated by Equation (2): The output value of the node of the hidden layer was ( ) The input value of the node of the output layer was calculated by Equation (3): The output value of the node of the output layer was ( , ) g( The transfer functions we used were shown as follows.

Training of the BP Neural Network
The flowchart of the BP neural network is shown in Figure 4. Further, v ih was the weight between the input layer and hidden layer; ω h was the weight between the hidden layer and output layer; γ h was the bias of the hidden layer; ϕ was the bias of the output layer. The input value of the neural cell of the hidden layer was calculated by Equation (2): The output value of the node of the hidden layer was b h = f (α h − γ h ). The input value of the node of the output layer was calculated by Equation (3): The output value of the node of the output layer was ε(θ, T) = g(β − ϕ). Here, i = 1, 2; h = 1, · · · , n. The transfer functions we used were shown as follows.

Training of the BP Neural Network
The flowchart of the BP neural network is shown in Figure 4.  Structure establishment. The structure of the BP neural network is described in detail in Section 3.2.1. There were 483 data sets obtained from the above-mentioned calibration process, and the data sets are randomly divided, with 90% used for training, 10% for validation.
Data normalization. All the data sets, which consist of the input values and expected values, were normalized within [0, 1]. The normalization process was shown in Equation (6).  Update parameters. When mean squared error (MSE) of the residual errors is not less than the target training error, or iterations are not completed, the weights and biases are updated through the corresponding algorithms. The residual errors are back-propagated through the neural network, the Levenberg-Marquardt (LM) algorithm was used to adjust the weights and biases, so as to build the proper compensation model and reduce the residual errors. The LM algorithm is more efficient for training the moderate-sized neural networks, which is up to several hundred weights, with good prediction performance [20,29].
The BP neural network is built when it meets the end condition.

Genetic Algorithm
The prediction performance of the BP neural network is influenced by the initial weights and biases. The genetic algorithm is used to optimize the initial weights and biases to improve the prediction performance. The flowchart of the genetic algorithm is presented in Figure 5. Structure establishment. The structure of the BP neural network is described in detail in Section 3.2.1. There were 483 data sets obtained from the above-mentioned calibration process, and the data sets are randomly divided, with 90% used for training, 10% for validation.
Data normalization. All the data sets, which consist of the input values and expected values, were normalized within [0, 1]. The normalization process was shown in Equation (6).
T mmax , θ mmax , ∆θ mmax were the maximum values of the ambient temperature, angular position and remained discrete angle measurement error values, separately, and T mmin , θ mmin , ∆θ mmin were the minimum values. Parameters initialization. Then the initialized parameters, which consist of the weights v ih , ω h and biases γ h , ϕ, are set to random numbers within [−1, 1].
Errors calculation. The predicted values ε(θ, T) m , which are the compensation values of the angle measurement error in this situation, were calculated by Equations (2)- (5). Then the residual errors were calculated by subtracting the predicted values ε(θ, T) m from the expected values ∆θ m .
Update parameters. When mean squared error (MSE) of the residual errors is not less than the target training error, or iterations are not completed, the weights and biases are updated through the corresponding algorithms. The residual errors are back-propagated through the neural network, the Levenberg-Marquardt (LM) algorithm was used to adjust the weights and biases, so as to build the proper compensation model and reduce the residual errors. The LM algorithm is more efficient for training the moderate-sized neural networks, which is up to several hundred weights, with good prediction performance [20,29].
The BP neural network is built when it meets the end condition.

Genetic Algorithm
The prediction performance of the BP neural network is influenced by the initial weights and biases. The genetic algorithm is used to optimize the initial weights and biases to improve the prediction performance. The flowchart of the genetic algorithm is presented in Figure 5.
Selection. The selection algorithm used in this article is the roulette method based on the proportionate fitness. The selection probability is calculated by Equation (8) Here, n F is the fitness value of individual n , n p is the selection probability of individual n and N is the size of individuals. The smaller the fitness value of individual is, the higher the selection probability will be. The individuals which are selected will be conducted in the subsequent operations. Crossover. The same parameters of two different individuals are changed by using the crossover algorithm, as shown in Equation (9): where mk a , nk a are the values of the parameter numbered k of the individual m and n , separately. The parameter numbered k is selected randomly from the whole weights and biases, individuals m , n are selected randomly from the population. w is a random value within [0, 1].
Mutation. The mutation algorithm is shown in Equation (10)  Initial values encoding. A population consists of different individuals. Each one is a string of the real numbers which are consisted of the weights between the input layer and hidden layer v ih , the biases of the hidden layer γ h , the weights between the hidden layer and output layer ω h , and the bias of the output layer ϕ. The parameters mentioned above are encoded in order.
Definition of fitness value. The MSE of the residual errors is set as the fitness value of individual F in genetic algorithm, as shown in Equation (7): Selection. The selection algorithm used in this article is the roulette method based on the proportionate fitness. The selection probability is calculated by Equation (8): Here, F n is the fitness value of individual n, p n is the selection probability of individual n and N is the size of individuals. The smaller the fitness value of individual is, the higher the selection probability will be. The individuals which are selected will be conducted in the subsequent operations.
Crossover. The same parameters of two different individuals are changed by using the crossover algorithm, as shown in Equation (9): where a mk , a nk are the values of the parameter numbered k of the individual m and n, separately. The parameter numbered k is selected randomly from the whole weights and biases, individuals m, n are selected randomly from the population. w is a random value within [0, 1].

of 14
Here a ij is the value of the parameter numbered j of the individual i. a max , a min are the maximum and minimum of the parameter numbered j of the whole individuals, separately. f (e) = r e (1 − e/E max ) 2 , where r e is a random value within [0, 1]. e is the current evolution number. E max is the maximum evolution value. r is a random value within [0, 1].
Calculation of fitness value. The selection, crossover and mutation mentioned above are operated N times separately. Then the fitness value of each individual is calculated, the individual whose fitness value is the smallest is obtained and then the corresponding parameter values are obtained.
Optimized parameters. One evolution process is consisted of the processes mentioned above. The whole individuals of population evolve G max times. At last, the individual whose fitness value is the smallest in the whole evolutions is found, the corresponding optimized weights and biases are obtained and used as the initial parameters of the BP neural network.

Calibration Experiment
The experimental system is shown in Figure 6. The autocollimator and regular optical polygon were used to obtain the discrete angle measurement error values of the rotary encoder [30]. The model of autocollimator was TriAngle US 300-57 (TRIOPTICS Company, Wedel, Germany, with resolution of 0.005" and measurement accuracy of 0.25"). The rotation joint which was installed close to the bottom of the ACMM is shown as an example. The structure of the rotation joint is shown in Figure 1. The temperature sensor was fixed on the mounting plate of the reading head. The temperature sensor used in the experiment was DS18B20 (Maxim, San Jose, CA, USA, with resolution of 0.06 • C and accuracy of 0.5 • C). The rotation joint was installed on the foundation support which the shaft sleeve is fixed on. The installation situation of the rotation joint in experiment and industrial field were same. The foundation support with the rotation joint was placed in the thermotank. The regular optical polygon with 23 faces and rotating shaft were fixed by the use of a clamp. The angle measurement error of the autocollimator will not be caused by the small eccentric installation of the regular optical polygon. The autocollimator and foundation support were adjusted to make sure that the light beam was perpendicular to the regular optical polygon. The position of the regular optical polygon was adjusted relative to the clamp to make sure that the indicating value of the rotary encoder θ was less than 0.2 • when the autocollimator was aimed at the first working face of the regular optical polygon. The initial position error is negligible, because 0.2 • is small compared with 360 • . Then the regular optical polygon was fixed by fastening the nut. Set the temperature in the thermotank and maintained the temperature for a long enough time to make sure the internal and external parts of the ACMM reach the same temperature. The thermal barrier was used to make sure that the variation of temperature was less than 0.2 °C during the calibration. The rotating shaft was rotated by hand without using motor for the reason that it was similar to the practical application of ACMM. The indicating value of the rotary encoder k θ and the indicating value of the autocollimator along the horizontal direction X , 1, ,23 k k δ = ⋅⋅⋅ were Set the temperature in the thermotank and maintained the temperature for a long enough time to make sure the internal and external parts of the ACMM reach the same temperature. The thermal barrier was used to make sure that the variation of temperature was less than 0.2 • C during the calibration. The rotating shaft was rotated by hand without using motor for the reason that it was similar to the practical application of ACMM. The indicating value of the rotary encoder θ k and the indicating value of the autocollimator along the horizontal direction δ Xk , k = 1, · · · , 23 were recorded simultaneously, when the autocollimator was aimed at each working face of the regular optical polygon. The discrete angle measurement error values ∆θ T k at current ambient temperature T were calculated by Equation (11): All the calibration data mentioned in the previous chapter were obtained in the same way.
During the experiments, it took within 30 min to install and adjust the devices. It usually took 4 h to change and maintain the temperature in the thermotank to make sure the different parts of ACMM reach the same set temperature at each specific temperature. It took within 20 min to finish the calibration process, which consists of repeated experiments carried out three times at each specific temperature. It took about 40 min to train all the calibration data and build the error compensation model when the time of repeated trials of the BP neural network is included.

Compensation Results
The average discrete angle measurement error values before compensation at temperatures of 10,15,20,25,30,35 and 40 • C are shown in Figure 7. The angle measurement errors ranged from −110.2" to 43.9". The angle measurement errors caused by the variation of temperature at the same angular position reached up to (−9.7", 7.0"). The angle measurement errors at the temperature of 20 °C were compensated by using the Fourier expansion mentioned above. The remained angle measurement errors were compensated by the improved BP neural network optimized by the genetic algorithm. It was obvious that 20 nodes in the hidden layer was optimal from Figure 8. Here a 2-20-1 BP neural network was selected. The angle measurement errors at the temperature of 20 • C were compensated by using the Fourier expansion mentioned above. The remained angle measurement errors were compensated by the improved BP neural network optimized by the genetic algorithm. It was obvious that 20 nodes in the hidden layer was optimal from Figure 8. Here a 2-20-1 BP neural network was selected.
The angle measurement errors at the temperature of 20 °C were compensated by using the Fourier expansion mentioned above. The remained angle measurement errors were compensated by the improved BP neural network optimized by the genetic algorithm. It was obvious that 20 nodes in the hidden layer was optimal from Figure 8. Here a 2-20-1 BP neural network was selected. According to the convergence condition of the fitness value of individuals in genetic algorithms, the total number of individuals N was set to 30, the maximum evolution number max G was set to 25. The compensation effect of the FE-GABPNN is presented in Figure 9. The RMSE of the residual errors after compensation was 0.84″, the residual errors were within (−2.2″, 2.5″). According to the convergence condition of the fitness value of individuals in genetic algorithms, the total number of individuals N was set to 30, the maximum evolution number G max was set to 25. The compensation effect of the FE-GABPNN is presented in Figure 9. The RMSE of the residual errors after compensation was 0.84", the residual errors were within (−2.2", 2.5").
Using the above-mentioned 483 data sets, the parameters 00 10 05 , , , p p p ⋅⋅⋅ are obtained by the linear least square fitting method. The compensation effect of the two-dimensional polynomial fitting method is presented in Figure 10. The RMSE of the residual errors after compensation is 3.69″. The extreme deviation of the residual errors after compensation is (−9.1″, 10.6″).

Two-Dimensional Polynomial Fitting
The two-dimensional polynomial fitting is widely used to fit the model that has two independent variables and one dependent variable. The mathematical model of the two-dimensional polynomial fitting method is expressed by Equation (12): ε(θ, T) = p 00 + p 10 θ + p 01 T + p 20 θ 2 + p 11 θT + p 02 T 2 + . . . +p 50 θ 5 + p 41 θ 4 T + p 32 θ 3 T 2 + p 23 θ 2 T 3 + p 14 θT 4 + p 05 T 5 (12) Using the above-mentioned 483 data sets, the parameters p 00 , p 10 , · · · , p 05 are obtained by the linear least square fitting method. The compensation effect of the two-dimensional polynomial fitting method is presented in Figure 10. The RMSE of the residual errors after compensation is 3.69". The extreme deviation of the residual errors after compensation is (−9.1", 10.6").
Using the above-mentioned 483 data sets, the parameters 00 10 05 , , , p p p ⋅⋅⋅ are obtained by the linear least square fitting method. The compensation effect of the two-dimensional polynomial fitting method is presented in Figure 10. The RMSE of the residual errors after compensation is 3.69″. The extreme deviation of the residual errors after compensation is (−9.1″, 10.6″).

FEPF Method
The FEPF method is proposed to improve the angle measurement accuracy of rotary encoders [16]. First, the compensation model of angle measurement error at each specific temperature is built by using Fourier expansion, as shown in Equation (13). Then the relationship between the coefficients of the Fourier series and ambient temperature is established by using of polynomial fitting separately, as shown in Equation (14). The orders of Fourier series are from 0 to 7, the degree of polynomial is 5.
f a 0 (T) = p a 0 1 T 5 + p a 0 2 T 4 + · · · + p a 0 5 T + p a 0 6 f a i (T) = p a i 1 T 5 + p a i 2 T 4 + · · · + p a i 5 T + p a i 6 Using the above-mentioned 483 data sets, the parameters p a 0 1 , · · · , p a 0 6 , p a i 1 , · · · , p b i 6 , i = 1, 2, · · · , 7 are calculated by the least square fitting method. The residual errors are calculated by subtracting the compensation values from the original errors. The RMSE of the residual errors after compensation is 1.20". The extreme deviation of the residual errors after compensation is (−2.1", 2.9").

Compensation Effect Comparison
The Fourier expansion-standard BP neural network (FE-BPNN) method, without using genetic algorithm, and the standard BP neural network (BPNN) method, without using Fourier expansion or genetic algorithm, are presented for comparison. The 25 nodes in the hidden, which is expected to have the best performance, are set when using the BPNN method. The same experiments' data sets are used as the training and test data.
Each approach is evaluated using the mean of the RMSE and the extreme deviation of the residual errors after compensation. The unit of the RMSE of the residual errors and the angle measurement errors are the same. Using the RMSE has the advantage of reflecting the magnitude of the residual errors directly compared with the MSE.
For the FE-GABPNN, FE-BPNN and BPNN methods, the repeated trials are carried out 20 times. The results are presented in Table 1. The compensation results of two-dimensional polynomial fitting and FEPF are presented in Table 2. Compared with the FE-BPNN and BPNN methods, the FE-GABPNN method shows a better compensation effect by evaluating the mean RMSE and mean extreme deviation of residual errors. Compared with the FEPF method proposed in a recent study, the extreme deviation of the residual errors by using FE-GABPNN method is almost the same, but the RMSE of the residual errors decreases from 1.20" to 0.85".

Discussion
The angle measurement accuracy of the rotary encoder installed in the rotation joint is mainly influenced by error motions of rotating shaft, installation eccentricity, imperfect manufacturing of the grating disk and variations of ambient temperature. In the article, a method based on FE-GABPNN is proposed to compensate the angle measurement error of the rotary encoder. The Fourier expansion method has the advantage of compensating periodic errors and the improved BP neural network optimized by the genetic algorithm method has the advantages of nonlinear fitting capability, regardless of the exact error model of the angle sensors and overcoming the local minimum. The FE-GABPNN method innovatively integrates the characteristics of Fourier expansion, BP neural network and genetic algorithm.
The rotary encoder installed in the rotation joint of ACMM is calibrated by the experiment. The experimental results show that over the ambient temperature range of 10 to 40 • C, the FE-GABPNN is superior to the FE-BPNN, BPNN, two-dimensional polynomial fitting and FEPF. The FE-GABPNN, which further decreases the RMSE of the residual errors, has better performance in compensating the angle measurement errors of rotary encoders when the ambient temperature changes. The FE-GABPNN method mentioned above has the potential of being applied to other precision instruments which contain rotation joints, such as a laser tracker.
By using the FE-GABNN proposed in this article, the residual errors after compensation is almost the same as the random errors of the angle measurement errors. It is hard to improve the angle measurement accuracy of rotary encoders based on the current devices when using single reading head. From our previous research work carried out at the stationary temperature, the random errors are decreased in a certain extent by using the double reading heads which are set in a regularly distributed way. The reason for this is that some error sources of random errors have the opposite effects on the double reading heads. The random errors caused by the variations of ambient temperature may have the similar characteristics. In addition, according to the researches [14,15], different arrangements of multi-reading heads have different compensation effect.
So, in future work, installing multi-reading heads is considered as the effective way to improve the angle measurement accuracy of the rotary encoders when the ambient temperature effect is considered, and the algorithm based on the multi-reading heads will be researched.

Conclusions
In this paper, a novel method based on FE-GABPNN is proposed to improve the angle measurement accuracy of the rotary encoders installed in the rotation joints of ACMM. The angle measurement errors decrease remarkably, from 110.2" to 2.7" after compensation. The mean RMSE of residual errors after compensation is 0.85". Installing multi-reading heads in a proper way and developing the related algorithm is the next step to further improve the angle measurement accuracy of the rotary encoders.

Conflicts of Interest:
The authors declare no conflicts of interest.

Appendix A
This appendix introduces the algorithm details of the least-square method to calculate the parameters a 0 , a i , b i , i = 1, · · · , 11 mentioned in Section 3.1.
The matrix M is defined as M = [a 0 a 1 b 1 a 2 b 2 · · · a 11 b 11 ] T .
The matrix E mea is defined as E mea = [∆θ T .
The matrix M is calculated by the following equation: M = A T A −1 A T E mea . The parameters a 0 , a i , b i , i = 1, · · ·, 11 are calculated.