## 1 Introduction  
The manufacturing accuracy of machine tools is seriously influenced by the inevitable geometric errors of the linear stages. Error compensation technology has been widely used as a cost-effective way to reduce the effects of the geometric errors [1; 2; 3]. As an important premise of the error compensation, the accuracy of the measurement approaches for detecting the geometric errors directly influence the compensation results.  
Currently, there are some approaches for measuring the geometric errors of machine tools, such as laser ball bars [4; 5], laser trackers [6; 7], laser interferometers [8; 9] and the techniques based on the principles of laser collimation (LC) and laser autocollimation (LA) [10; 11; 12; 13; 14] and so on. Among these techniques, the simplest and most on-line applicable one is to detect the position variation of the laser spot with respect to the photodetector based on the principles of LC and LA, which take advantage of the high sensitivity, high accuracy and simple computation. In order to reduce the size of the measurement system and realize the on-line measurement, a laser diode (LD), which has the advantages of miniaturization and low cost, is always adopted as the laser source of the measurement system [10; 11; 12].  
The most commonly used normalization and differential algorithm of the photodetector in the measurement system based on the principles of LC and LA is derived from an ideal circular laser spot with a uniform distribution of the intensity. However, the shape and the intensity distribution of the LD is actually elliptical and have a Gauss distribution, which will affect the measurement accuracy. There are many researchers focusing on establishing compensation models for the circular laser spot with a Gauss distribution [15; 16]. However, those models cannot be used for the elliptical laser spot. Laser beam shaping is one of the most cost-effective approaches to eliminate the measurement error caused by the laser spot characteristic of the LD. However, the traditional laser beam shaping methods require a set combination of lens [17], or a lens with a special shape [18], or some additional optical elements, such as a single-mode optical fiber [19], which will make the measurement system complex and unstable. How to reduce the effect of the elliptical laser spot without adding additional optical elements will have a positive effect on further improving the measurement accuracy of the LD-based system.  
In addition, the LD has inevitable laser beam drifts, including a linear drift and an angular drift, which will influence the stability, the accuracy and the repeatability of the measurement system. The laser beam drifts can be reduced and compensated by integrating a beam expander [20] or establishing a passive common path in the measurement system [21; 22]. An optical fiber can also be used to reduce the beam drift [23]. A special mechanism with a piezoelectric actuator can also be integrated into the system to actively compensate the laser beam drifts [10; 11; 24]. However, most of the above-mentioned methods only compensate the angular drift and only the laser beam drifts near the laser source can be compensated. The laser beam drifts in the long-distance measurement are not considered. Moreover, the linear drift is also not considered.  
To address the above-mentioned problems, an active shaping method is firstly proposed for shaping the elliptical laser spot of the LD without adding additional optical elements in an LD-based system, which is constructed to measure the geometric errors of machine tools. An improved active error compensator is then designed to reduce the linear drift and the angular drift of the laser source during the long-distance measurement. The principles of the proposed active methods will be introduced in the following sections.