A method for on-line measurement and compensation of geometric errors of a numerical control machine tool
By combining an infrared light source and a binocular measurement unit with Gaussian surface fitting and the BLSTM-MHA-TCN algorithm, high-precision online measurement and real-time compensation of geometric errors in CNC machine tools are achieved, solving the problems of low measurement efficiency and high cost in existing technologies and improving the machining accuracy of machine tools.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- OCEANOGRAPHIC INSTR RES INST SHANDONG ACAD OF SCI
- Filing Date
- 2026-02-09
- Publication Date
- 2026-05-05
AI Technical Summary
Existing technologies are insufficient for real-time, high-precision measurement and effective compensation of geometric errors during CNC machine tool machining. Furthermore, the devices are complex to install, costly, and do not consider the impact of cutting conditions on dynamic geometric errors.
Using an infrared light source and an infrared binocular measurement unit, combined with an improved Gaussian surface fitting algorithm and a BLSTM-MHA-TCN algorithm, the coordinates in the machine tool coordinate system are acquired in real time, an error compensation model is established, and the motion trajectory of the spindle and fixture is tracked in real time through the infrared binocular measurement unit to realize online measurement and compensation of geometric errors.
It enables high-precision online measurement of geometric errors in CNC machine tools, with an accuracy of up to 2 micrometers. This simplifies device installation, reduces costs, and allows for real-time correction of geometric errors, thereby improving machining accuracy.
Smart Images

Figure CN121680277B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of CNC machine tool machining technology, and in particular to a method for online measurement and compensation of geometric errors in CNC machine tools. Background Technology
[0002] With the upgrading of my country's manufacturing industry, the demand for high-precision CNC machine tools is booming. Machining accuracy has always been a key research area in the machine tool field. Currently, the positioning accuracy of domestically produced machine tools at the factory has reached the micrometer level. However, after a period of use, their machining accuracy can only reach the sub-millimeter level. This is mainly because, during machining, the machining data is primarily composed of the guide rail trajectory measured by a linear encoder. Working in a factory environment for extended periods, the linear encoder, moving along with the guide rail, may deform and wear, and its measured data cannot meet the requirements for measuring the geometric errors of the machine tool. Ultimately, improving the machining accuracy of CNC machine tools requires real-time, high-precision measurement of the actual geometric motion errors of the tool and workpiece during machining, and compensation for these errors.
[0003] To address the aforementioned issues, existing technologies utilize ballbars for circularity testing of five-axis CNC machine tools and laser interferometers for measuring machine tool positioning errors. However, both suffer from complex installation and debugging processes, high installation errors, and high costs. Furthermore, the tests are still conducted under cold and air-cutting conditions, and existing technologies do not consider the influence of cutting conditions on the dynamic geometric errors of CNC machine tools. Summary of the Invention
[0004] To overcome the aforementioned problems in the existing technology, this invention proposes an online measurement and compensation method for geometric errors of CNC machine tools.
[0005] The technical solution adopted by this invention to solve its technical problem is: an online measurement and compensation method for geometric errors of CNC machine tools, comprising the following steps:
[0006] Step 1: Install infrared light sources evenly on the lower edges of the spindle and fixture respectively. Fix the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit in appropriate positions on the CNC machine tool body, and calibrate the internal and external parameters of the two infrared binocular measurement units.
[0007] Step 2: Light up the infrared light sources respectively, and use the improved Gaussian surface fitting algorithm to obtain the coordinates of the center of the infrared light source in the coordinate systems of the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit. Then, calibrate the transformation relationship between the coordinate systems of the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit and the machine tool coordinate system respectively.
[0008] Step 3: Move the spindle and fixture to various positions in the machining area. Based on the transformation relationship obtained in Step 2, transform the measured coordinates of the infrared light source center in the infrared binocular measurement unit coordinate system into coordinates in the machine tool coordinate system to obtain the actual geometric trajectory of the spindle and fixture.
[0009] Step 4: Establish an error compensation model based on the BLSTM-MHA-TCN algorithm, and use the spindle and fixture infrared binocular measurement unit to obtain the coordinates in the machine tool coordinate system in real time;
[0010] Step 5: Compare the actual geometric trajectory obtained in Step 3 with the theoretical geometric trajectory to obtain the dynamic geometric error. Based on the error compensation model obtained in Step 4, correct the geometric trajectory in real time.
[0011] The above-mentioned method for online measurement and compensation of geometric errors of CNC machine tools, specifically the calibration process of internal and external parameters in step 1, is as follows: ceramic calibration plates are placed on the fixture in different postures, and multiple sets of calibration plate images are collected by the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit, respectively. Based on the coordinates of the calibration points in the phase plane and the calibration plate plane, the internal and external parameters of the two infrared binocular measurement units are calibrated.
[0012] The above-mentioned online measurement and compensation method for geometric errors of CNC machine tools, specifically the improved Gaussian surface fitting algorithm in step 2, is as follows: when scanning the light bar image row by row and column by column, if two or more consecutive pixels are detected to have saturated gray values, then all saturated pixels will not participate in Gaussian fitting; if only one pixel is detected to have saturated gray values, then that saturated pixel will participate in Gaussian fitting; after determining the number of saturated pixels to be filtered out, the roughly calculated center point of the light spot is used as the midpoint, and the radius of the light spot is reduced by a scale based on the original radius of the light spot; the number of pixels in the light spot minus the number of filtered saturated pixels, and the remaining pixels maintain a light spot radius of 3-5 pixels, and participate in the final Gaussian fitting.
[0013] The above-mentioned method for online measurement and compensation of geometric errors of CNC machine tools uses two high-resolution, low-distortion cameras with identical model parameters in the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit. These cameras are installed in a pre-designed housing with a baseline length of 460mm and an angle of 18° between the optical axes of the two cameras.
[0014] The above-mentioned method for online measurement and compensation of geometric errors of CNC machine tools, specifically includes the error correction model establishment process in step 4: establishing a bidirectional long short-term memory network, the input gate determining the ratio of the new input state to the data of the previous moment, and forming a new dataset as input; the output gate obtaining the output result based on the integral of the high-level input state and the current input state;
[0015] The bidirectional long short-term memory network introduces a multi-head attention layer at the back end. Based on the different operating conditions of the CNC machine tool, the linear layer is used to correct the feature dimension of the input data. The segmentation operation divides the embedding vector of the input sequence data into multiple heads and assigns different attention weights to the input features, so as to more accurately predict the pose of the CNC machine tool spindle and fixture.
[0016] The data output by the multi-head attention mechanism enters the TCN network, where the feature dimensions are expanded. The expanded feature dimensions are then sent back to the bidirectional long short-term memory network and the multi-head attention layer for further processing until the optimal solution is obtained, thus yielding the geometric error compensation model.
[0017] The above-mentioned method for online measurement and compensation of geometric errors of CNC machine tools, in step 2, before obtaining the center coordinates of the infrared light source, calibrates the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit. Specifically, the laser interferometer is aligned with the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit respectively. At the same time, the laser interferometer is used to measure the center of the infrared light source before and after each movement with the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit to complete the calibration.
[0018] The advantages of this invention are that it is simple to install, low in cost, and can achieve high-precision online measurement with an accuracy of up to 2 micrometers. This invention effectively improves the real-time tracking accuracy of the spindle and fixture movement trajectory through the BSV-IGSF algorithm, and effectively compensates for errors through the BLSTM-MHA-TCN algorithm, enabling online non-contact high-precision measurement of CNC machine tool geometric errors. Attached Figure Description
[0019] Figure 1 This is a schematic diagram of the system installation of the present invention;
[0020] Figure 2 This is a schematic diagram of a simple binocular model based on the ray intersection method of the present invention;
[0021] Figure 3 This is a schematic diagram illustrating the method for representing actual geometric motion errors in this invention;
[0022] Figure 4 This is a schematic diagram of the BLSTM network structure of the present invention;
[0023] Figure 5 This is a schematic diagram of the attention mechanism module framework of the present invention;
[0024] Figure 6 This is a schematic diagram of the internal structure of the TCN in this invention;
[0025] Figure 7 This is a schematic diagram of the infrared light source center position measurement error compensation method of the present invention;
[0026] Figure 8 The displacement measurement result-measurement error relationship curve of the present invention is shown, where (a) is the error relationship curve in the X direction; (b) is the error relationship curve in the Y direction; and (c) is the error relationship curve in the Z direction.
[0027] Figure 9 This is a schematic diagram of the displacement measurement error after compensation according to the present invention, wherein (a) is the error in the X direction, (b) is the error in the Y direction, and (c) is the error in the Z direction.
[0028] The components are as follows: 1. Z-axis guide rail; 2. Spindle box; 3. Spindle infrared binocular measuring unit; 4. Fixture; 5. X-axis guide rail; 6. Column; 7. Fixture infrared binocular measuring unit; 8. Z-axis guide rail; 9. Control system; 10. Spindle; 11. Infrared light source; 12. Cross slide; 13. Y-axis guide rail; 14. Base. Detailed Implementation
[0029] To enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0030] This embodiment discloses an online measurement and compensation method for geometric errors of CNC machine tools. It can accurately and automatically detect geometric errors during machining. By controlling the machine tool, the infrared binocular measurement unit, and the infrared light source, the geometric trajectory can be detected in a timely manner during machining, thus achieving better real-time compensation for geometric errors. This solves the problems of low detection efficiency, untimely feedback, and inability to measure dynamic geometric errors in existing machining processes. It also addresses the accuracy degradation caused by factors such as machine tool thermal deformation and wear. Figure 1 As shown, the spindle infrared binocular measurement unit 3 is fixed on one side of the machine body, and the infrared light source 11 is evenly installed on the lower edge of the spindle 10 and the fixture 4 respectively. The ceramic calibration plate is installed on the fixture 4. The control system communicates with the machine body, the spindle infrared binocular measurement unit 3, the fixture infrared binocular measurement unit 7, and the infrared light source 11. The machine body includes a base 14, a fixture 4, a guide rail, a column 6, a spindle box 2, a spindle 10, a cross slide 12, and a fixture 4. The guide rail includes an X guide rail 5, a Y guide rail 13, and a Z guide rail 8.
[0031] Based on the above structure, the specific method of this embodiment is as follows: Step 1, the infrared light source is evenly installed on the lower edge of the spindle and the fixture respectively, the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit are fixed in appropriate positions on the CNC machine tool body, and the internal parameters and external parameters of the two infrared binocular measurement units are calibrated.
[0032] First, fix the spindle infrared binocular measurement unit 3 and the fixture infrared binocular measurement unit 7 in appropriate positions on the machine body to prevent cutting fluid splashing from interfering with the measurement. Adjust the two infrared binocular measurement units so that their fields of view can completely cover the entire moving area of the spindle and the fixture, respectively. Place the ceramic calibration plate on the fixture in different orientations, and use the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit to acquire multiple sets of calibration plate images. Based on the coordinates of the calibration points in the phase plane and the calibration plate plane (which can be converted to the fixture plane), calibrate the internal and external parameters of the two infrared binocular measurement units.
[0033] Step 2: Light up the infrared light sources respectively, and use the improved Gaussian surface fitting algorithm to obtain the coordinates of the center of the infrared light source in the coordinate systems of the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit. Then, calibrate the transformation relationship between the coordinate systems of the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit and the machine tool coordinate system respectively.
[0034] After calibrating the infrared binocular measurement units, illuminate the infrared light sources evenly installed at the bottom edges of the spindle and fixture. Initially, position the spindle and fixture in their respective initial positions. Use the spindle and fixture infrared binocular measurement units to acquire multiple sets of infrared light source images, obtaining the coordinates of the infrared light sources in each infrared binocular measurement unit coordinate system. Based on the coordinates of the infrared light sources at the bottom edges of the spindle and fixture in the machine tool coordinate system (set during installation) and the infrared binocular measurement unit coordinate system, respectively, calibrate the transformation relationship between the two infrared binocular measurement unit coordinate systems and the machine tool coordinate system.
[0035] To improve the machining accuracy of CNC machine tools, it is necessary to obtain the geometric error of the CNC machine tool, which fundamentally depends on obtaining the real-time movement trajectory of the CNC machine tool spindle and tool. In this embodiment, an infrared binocular measurement unit and an infrared light source are used to track the movement trajectory of the spindle and tool in real time, thereby obtaining the machine tool's geometric error. To improve the real-time tracking accuracy of the spindle and tool movement trajectory, this embodiment designs a high-precision measurement method based on the BSV-IGSF algorithm, which can accurately locate the coordinate changes of the infrared light source of the spindle and fixture, thereby obtaining the spindle and fixture motion trajectory that reflects the movement error of the CNC machine tool in real time.
[0036] The infrared binocular measurement unit is used to track the motion trajectory of the spindle and the infrared light source of the fixture in real time. The infrared binocular measurement unit uses two high-resolution, low-distortion cameras with identical model parameters, installed in a pre-designed housing. To expand the common field of view and measurement distance, the baseline length is designed to be 460mm, and the angle between the optical axes of the two cameras is 18°. The infrared binocular measurement unit uses a binocular model based on the ray intersection method for measurement, such as... Figure 2 As shown, assume the world coordinates of any point P in space are: (X... w ,Y w Zw Let P be the image points of point P on the imaging planes of the two cameras, P1 and P2, respectively. The pixel coordinates of P1 and P2 are (u1, v1) and (u2, v2), respectively. The projection matrices of the two cameras are:
[0037]
[0038]
[0039] Based on the camera's imaging model, the transformation relationship between the camera coordinate system and the world coordinate system can be expressed as:
[0040]
[0041]
[0042] in, and These are the coordinates of point P in space along the optical axis in the optical center coordinate systems of the two cameras, respectively. , . , These are the intrinsic parameter matrices for the left and right cameras, respectively. , These are the rotation matrix of the world coordinate system relative to the left camera coordinate system and the translation vector relative to the origin of the left imaging plane, respectively. , Let be the rotation matrix of the world coordinate system relative to the right camera coordinate system and the translation vector relative to the origin of the right imaging plane, respectively. Assume the left camera coordinate system coincides with the world coordinate system, then:
[0043]
[0044]
[0045] Therefore:
[0046]
[0047]
[0048] The results obtained after expansion and organization are as follows:
[0049]
[0050]
[0051] ,
[0052] because It's not a square matrix; for easier calculation, we'll calculate it first. Therefore, we can obtain:
[0053]
[0054] The above analysis shows that, given the calibrated intrinsic parameter matrices of the two cameras and the rotation and translation matrices between them, the three-dimensional coordinates of a point in space can be calculated as long as the coordinates of a point in space on the image planes of the two cameras are known.
[0055] An improved Gaussian surface fitting algorithm is used to obtain the coordinates of the center of the infrared light source of the main axis and fixture on the image planes of the two cameras in the infrared binocular measurement unit. An infrared LED is used as the light source emitter; the emitted light intersects the field of view of the infrared binocular measurement unit module and forms an image within the field of view. Within the field of view, the light intensity distribution of the infrared light source from the edge to the center of the spot roughly follows the distribution law of a two-dimensional Gaussian function surface. The center position of the infrared light source can be considered as the location of the extreme point of the fitted Gaussian function. The mathematical expression of the Gaussian function surface is:
[0056]
[0057] in, A Let σ be the magnitude of the Gaussian function, and σ be the half-width of the Gaussian function. Let be the coordinates of the center of the Gaussian surface, i.e., the center of the spot image. Taking the logarithm of both sides of expression (17) yields:
[0058]
[0059] make , , , , Then equation (24) can be rewritten as:
[0060]
[0061] in, , , , These are the parameters to be estimated. For digitally processed infrared light source images, it is assumed that there are parameters on the extracted cross-section. N points ( , ) as sampling points, For the first i The pixel coordinates of each point For the first i The grayscale value of each sampling point (the intensity of the quantization capability of the pixel) can be obtained according to expression (19). , Furthermore, equation (19) is derived from this:
[0062]
[0063] To obtain the parameters to be estimated , , , We can establish the objective function (21) and solve it using the least squares method.
[0064]
[0065] make , , , Then the following equation can be derived:
[0066]
[0067] Therefore, the parameters to be estimated can be obtained. , , , Finally, the extreme point location of the fitted Gaussian function, i.e., the coordinates of the center of the light spot, are obtained as follows:
[0068]
[0069] In applications using traditional Gaussian fitting to determine the center of a light spot, all pixels within the rectangular region containing the spot are often included in the fitting process. This can negatively impact the accuracy of the center localization. As the spot radius increases, the image grayscale distribution deviates significantly from the ideal Gaussian surface, especially at the spot edges where background grayscale is more susceptible to noise. Furthermore, real light spots exhibit significant light saturation near extreme points. Having multiple saturated points with peak grayscale values participating in the Gaussian fitting operation inevitably introduces errors, affecting the fitting results. Therefore, traditional Gaussian fitting algorithms are no longer suitable for the specific circumstances of this project, requiring measures to limit the spot radius and remove saturated points. To make Gaussian fitting more suitable for this project, it is necessary to carefully consider each step of the Gaussian algorithm's application, optimizing localization accuracy while ensuring algorithm timeliness.
[0070] To address the light saturation phenomenon, when scanning the light bar image row by row (column), if two or more consecutive pixels are detected to have saturated gray values, then all saturated pixels are excluded from Gaussian fitting; if only one pixel is detected to have saturated gray values, then that saturated pixel participates in Gaussian fitting. After determining the number of saturated pixels to be filtered out, the roughly calculated center point of the light spot is used as the midpoint, and the light spot radius is reduced proportionally based on the original light spot radius. The number of pixels within the light spot minus the number of filtered saturated pixels leaves the remaining pixels, maintaining a light spot radius of 3-5 pixels, and these remaining pixels participate in the final Gaussian fitting.
[0071] Step 3: Move the spindle and fixture to various positions in the machining area. Based on the transformation relationship obtained in Step 2, convert the measured coordinates of the infrared light source center in the infrared binocular measurement unit coordinate system into coordinates in the machine tool coordinate system to obtain the actual geometric trajectory of the spindle and fixture.
[0072] like Figure 3 As shown, For the actual geometric trajectory, For theoretical geometric motion trajectory, The geometric trajectory of the main axis. For the geometric motion trajectory of the clamp, The initial relative position between the spindle and the fixture. In the machine tool coordinate system OXYZ, , Initial relative positional relationship between the two trajectories, the spindle, and the fixture The combined trajectory is the actual geometric trajectory. Therefore, the actual geometric trajectory can be represented as:
[0073]
[0074] if , Initial relative positional relationship between the two trajectories, the spindle, and the fixture Measurements show that the actual geometric trajectory can be obtained by calculating according to the above formula. Therefore, constructing a closed vector relationship allows geometric trajectories, which are difficult to measure in real time, to be represented in space. After obtaining the actual geometric trajectory, the theoretical geometric trajectory can then be used... Then the geometric motion error can be calculated. .
[0075] Real-time measurement of geometric errors in CNC machine tools is performed. The magnitude and direction of vector BD are constant parameters during the measurement process and can be obtained through precise pre-measurement. The magnitude and direction of vectors AB and DC are the parameters being measured during the measurement process. By measuring only the magnitude and direction of vectors AB and DC, the actual geometric trajectory can be measured. After obtaining the actual geometric trajectory, the geometric error C'C can be calculated based on the theoretical geometric trajectory AC'. The magnitude and direction of vectors AB and DC can be measured using an infrared binocular measurement unit and an infrared light source.
[0076] Because the system frequently operates in harsh environments with splashing cutting fluid, severe vibration, and flying metal chips, conventional measurement methods are often affected. However, infrared light possesses strong cloud-penetrating capabilities and resists interference from visible light, giving the CNC machine tool geometric error real-time detection system designed in this embodiment significant advantages in terms of observability. Therefore, this paper employs a method combining an infrared binocular measurement unit and an infrared light source to construct real-time observation vectors AB and DC. Through mature binocular stereo vision technology and improved Gaussian surface fitting technology, the magnitude and direction of the vectors are accurately measured.
[0077] First, fix the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit in appropriate positions on the machine body to prevent cutting fluid splashing from interfering with the measurement. Adjust the two infrared binocular measurement units so that their fields of view completely cover the entire moving area of the spindle and fixture, respectively. Infrared light sources are evenly installed on the lower edges of the spindle and fixture, respectively. Use the infrared binocular measurement units to track and locate the center coordinates of the infrared light sources. The field of view of the infrared binocular measurement units completely covers the entire moving range of the spindle and fixture, and infrared filters are used to ensure that the wavelength range of the transmitted infrared light matches the wavelength range of the infrared light emitted by the infrared light source. During operation, the infrared light source emits infrared light, which propagates along the optical axis of the infrared binocular measurement units. After passing through the camera lens, the infrared light forms an image within the field of view.
[0078] Currently, the measurement error of the infrared light source center coordinates within a 400mm*400mm machine tool machining area using high-precision binocular stereo vision and improved Gaussian surface fitting technology does not exceed 5μm, fully meeting the research requirements of this project. It should be noted that infrared light scattering occurs during propagation in environments with water mist or cutting fluid splashes, especially within a range exceeding 1 meter, where reduced light intensity leads to blurred imaging within the field of view, making it impossible to extract the infrared light source center coordinates. However, since the measurement distance in this paper does not exceed 1.5 meters, the impact of light scattering is negligible. Furthermore, in practical engineering applications, a dedicated light shield can be installed on the machine tool to prevent interference from stray light and other factors from affecting the measurement of the infrared light source center.
[0079] During real-time measurement of the actual geometric trajectory, two infrared binocular measurement units are combined for measurement. The trajectories measured by the two infrared binocular measurement units together construct the actual geometric trajectory. Before machining begins, the coordinate transformation relationship between the coordinate systems of the two infrared binocular measurement units and the machine tool coordinate system is calibrated. The spindle infrared binocular measurement unit mainly obtains the motion trajectory of the infrared light source on the spindle, and obtains the spindle motion trajectory in the machine tool coordinate system based on the coordinate transformation relationship between the infrared binocular measurement unit coordinate system and the machine tool coordinate system. The fixture infrared binocular measurement unit mainly obtains the motion trajectory of the infrared light source on the fixture, and obtains the fixture motion trajectory in the machine tool coordinate system based on the coordinate transformation relationship between the infrared binocular measurement unit coordinate system and the machine tool coordinate system. The motion trajectories measured by the two sets of infrared binocular measurement units, combined with the initial positions between the spindle and the fixture, are used to calculate the actual geometric trajectory in the machine tool coordinate system.
[0080] During operation, the infrared beam passes through the lenses of the two cameras in the infrared binocular measurement unit and is projected onto two image planes. Initially, the center point of the image plane of the left camera is selected as the origin of the infrared binocular measurement unit's coordinate system. On one hand, the image plane imaging point of the right camera, sharing the same infrared light source center, is the matching point for the image plane imaging point of the left camera; on the other hand, when measuring the spindle and fixture motion trajectories, the coordinates of the infrared light source in the infrared binocular measurement unit's coordinate system are obtained using ray intersection.
[0081] The optical path lengths from the infrared light source module to the center points of the image planes of the left and right cameras in the two infrared binocular measurement units are different. The image of the main axis infrared light source is obtained by the main axis infrared binocular measurement unit. By measuring the position of the center point of the main axis infrared light source in real time, the direction and magnitude of vector AB can be obtained. Similarly, the image of the infrared light source on the fixture is obtained by the fixture infrared binocular measurement unit. By measuring the position of the center point of the infrared light source module mounted on the fixture in real time, the direction and magnitude of vector DC can be obtained.
[0082] The infrared binocular measurement unit mainly consists of a filter, a housing, a projector, and industrial cameras. The filter is mounted on the lens of the infrared binocular measurement unit. The housing encapsulates the entire unit, and the projector provides illumination during calibration. Two industrial cameras are mounted on the housing base according to a calculated baseline length and angle to collect transmitted infrared light. After encapsulation, the relative position and orientation of the two cameras remain fixed, requiring only one calibration to obtain the internal and external parameters of the infrared binocular measurement unit. The advantage of this implementation is that the internal and external parameters of the infrared binocular measurement unit remain constant, therefore the measurement accuracy is independent of the position of the infrared light source.
[0083] To ensure the measurement accuracy of the infrared binocular measurement unit, the housing base is integrally machined from 40Cr material, which has high rigidity, strong torsional resistance, and is not easily deformed, ensuring that the external parameters of the infrared binocular measurement unit remain constant. The internal parameters of the infrared binocular measurement unit are determined when the industrial camera leaves the factory and can be obtained by calibration using a high-precision ceramic calibration plate. The outer surface of the housing is coated with a high-reflectivity (e.g., above 90%) diffuse reflection coating to reflect stray visible light from the environment as much as possible without affecting the penetrating infrared light, thus reducing the influence of stray visible light from the environment. Therefore, to meet the signal-to-noise ratio requirements of the infrared light source spot center point position signal, a dedicated low-light or ultra-low-light industrial camera should be selected to acquire the infrared light source spot image.
[0084] Step 4: Establish an error compensation model based on the BLSTM-MHA-TCN algorithm, and use the spindle and fixture infrared binocular measurement unit to obtain the coordinates in the machine tool coordinate system in real time.
[0085] Bidirectional Long Short-Term Memory (LSTM) is a variant of Long Short-Term Memory (LSTM). This paper designs it to run two LSMs simultaneously over a time series, one processing data from front to back and the other from back to front. The input gate determines the ratio of the new input state to the data from the previous time step, forming a new dataset as input, represented as:
[0086]
[0087]
[0088]
[0089]
[0090] The output gate obtains the output result based on the integral of the higher-level input state and the current input state, expressed as:
[0091]
[0092]
[0093] In the formula, Indicates the geometric position input vector. , , , , and It includes the forget gate, input gate, update cell state, cell state, output gate, hidden state update, and bias vector. , , These represent the input, output, and forget gate weight matrices, respectively. The bidirectional loop structure combining the forward and backward BLSTM networks is as follows: Figure 4 As shown.
[0094] A BLSTM network consists of two LSTMs operating in opposite directions: the forward LSTM processes sequences from beginning to end, and the backward LSTM processes sequences from end to beginning. Each LSTM contains an input gate, a forget gate, an output gate, and cell states, with information flow controlled by weight matrices and bias terms. Input data is filtered for new information by the input gate, the forget gate determines which historical information to retain, and the output gate generates a feature vector containing contextual information. This bidirectional structure allows the model to simultaneously capture the dependencies between sequences, enhancing its temporal modeling capabilities. The forward LSTM computes the input gate, forget gate, output gate, cell state, and hidden state. The backward LSTM works similarly, with the final output being a concatenation of the forward and backward hidden states, capturing contextual information within the sequence.
[0095] Data obtained using the BSV-IGSF algorithm is first processed by the BLSTM network. At each time step, the BLSTM receives a 64-dimensional vector as input from the BSV-IGSF. Assuming the BLSTM is bidirectional, the output at each time step should be 128 dimensions (64 dimensions forward plus 64 dimensions backward). However, by default, the outputs from both directions are typically merged into a single vector, resulting in a BLSTM output feature dimension of 64.
[0096] Due to the extremely complex factory environment, CNC machine tools are affected by a variety of factors. The BLSTM model handles all these influencing parameters. However, low-correlation data not only prolongs processing time but also affects prediction accuracy. To improve accuracy, a multi-head attention mechanism is introduced in the backend of the BLSTM model. This model assigns different attention weights to input features based on different operating conditions of the CNC machine tool, thus more accurately predicting the pose of the CNC machine tool spindle and fixture. The attention mechanism performs a global analysis of the data, revealing the relationships between CNC machine tool geometric error data. The model structure is as follows: Figure 5 As shown.
[0097] The attention mechanism module receives the BLSTM output, corrects the feature dimension through a linear layer, and divides it into multiple heads (e.g., 12 heads). Each head processes the data independently, performing linear transformations of the query, key, and value, and scaling dot product attention calculations. The outputs are concatenated and then integrated through a projection layer. The input features are divided into multiple subspaces (e.g., 768 dimensions divided into 12 heads, each with 64 dimensions). Each head calculates an attention score, which is then weighted using softmax. The weighted summation vector is concatenated and projected back to the original dimension through the output. Multiple heads process different feature patterns in parallel (e.g., low-frequency energy, high-frequency transients) to enhance sequence representation capabilities.
[0098] In the CNC machine tool geometric error prediction model, a linear layer is used to correct the feature dimension of the input data to better meet the model parameters. A segmentation operation divides the embedding vector of the input sequence data into multiple heads. This allows the multi-head attention mechanism to process different heads simultaneously, thereby improving the model's ability to capture complex relationships. An attention scoring layer calculates the influence score of each data point in the input sequence on the geometric position of the CNC machine tool, thus focusing more on important parameters during the prediction process.
[0099] During CNC machine tool machining, a large amount of time-series data is generated, including the spindle and fixture geometric positions obtained using the BSV-IGSF algorithm and the spindle and fixture geometric positions measured by a laser interferometer. This data exhibits complex temporal dependencies. After processing by a BLSTM model and a multi-head attention mechanism, the data is finally fed into a TCN network to establish an error model. TCN aims to effectively capture long-term dependencies in the data by combining extended convolution and causal convolution, thus processing sequential data. When operating at different geometric positions, CNC machine tools generate machining parameters and machining log data of varying lengths, posing challenges to the model training process. However, TCN can adapt to these variations and provide greater flexibility in data processing. Furthermore, TCN can process data of all time steps in parallel, further improving efficiency. The internal structure of TCN is as follows... Figure 6 As shown.
[0100] The TCN consists of multiple Temporal Blocks, each containing two layers of dilated convolutions, Chomp1d pruning, LeakyReLU activation, and Dropout. The dilated convolutions expand the receptive field through interval sampling (e.g., dilation rate d=2i), causal convolutions ensure the output depends only on past information, and residual connections pass information across layers. The input is expanded in feature dimension by 1D convolutions, and the dilated convolutions... kernelsize =3、 padding =( kernelsize -1)∗ dilation Preserving the temporal dimension, Chomp1d trims redundant padding, and after two convolutional layers, non-linear activation and regularization are applied. The residual block adjusts the number of channels through 1×1 convolutions to achieve cross-layer feature fusion, process all time steps in parallel, and efficiently capture long-term dependencies.
[0101] The TCN model expands the feature dimension to capture richer feature representations. This change in feature dimension enables the model to learn more complex feature representations, thereby improving model performance. The input data has a feature dimension of 17; through TCN feature transformation, the output feature dimension becomes 64. This is then sent back to the bidirectional long short-term memory layer and the multi-head attention layer for further iterative processing. The three parts of the model iterate repeatedly until the optimal solution is obtained, ultimately leading to the optimal geometric error compensation model, thus ending the iteration. These three modules together constitute the error compensation network for online measurement of CNC machine tool geometric errors, improving measurement accuracy through a triple mechanism of temporal modeling, key parameter weighting, and long-term dependency capture.
[0102] Step 5: Compare the actual geometric trajectory obtained in Step 3 with the theoretical geometric trajectory to obtain the dynamic geometric error. Based on the error compensation model obtained in Step 4, correct the geometric trajectory in real time.
[0103] Move the spindle and fixture to various positions (arbitrary areas) in the machining area, convert the coordinates in the infrared binocular measurement unit coordinate system to coordinates in the machine tool coordinate system, complete the calibration of the spindle and fixture infrared binocular measurement units with the assistance of a laser interferometer, and establish an error compensation model for the spindle and fixture infrared binocular measurement units, thereby enabling the use of the spindle and fixture infrared binocular measurement units to obtain high-precision coordinates in the machine tool coordinate system in real time.
[0104] The workpiece is clamped in a machine tool fixture. During each cutting step, the spindle and fixture infrared binocular measurement units are used to locate the center of the infrared light source at the lowest edge of the spindle and fixture, respectively, obtaining the coordinates in the coordinate system of the spindle and fixture infrared binocular measurement units. Based on the previously calibrated transformation relationship between the coordinate system of the spindle and fixture infrared binocular measurement units and the machine tool coordinate system, and the established error compensation model, the coordinates in the high-precision machine tool coordinate system are obtained in real time, thus obtaining the geometric motion trajectory of the spindle and fixture. During the machining process, the actual geometric trajectory is obtained in real time based on the real-time obtained spindle and fixture motion trajectory and the initial relative position relationship between the spindle and fixture. The real-time obtained actual geometric trajectory is compared with the theoretical geometric trajectory to obtain the dynamic geometric error, thereby correcting the geometric trajectory in real time to reduce the geometric error.
[0105] To verify the accuracy of the method in this embodiment, an experiment was designed. First, the infrared markers and the camera used in the infrared binocular stereo vision measurement system were selected. To facilitate the differentiation of the infrared markers from the background and reduce the influence of stray light, after researching relevant products, the L9337 infrared LED light source from Hamamatsu Photonics Co., Ltd. (Japan) was chosen as the infrared marker, with a center wavelength of 870nm. Since the infrared markers use an infrared LED light source, a camera with high response efficiency to infrared wavelengths was selected. After researching relevant products, the MQ042RG-CM near-infrared monochrome industrial CMOS camera from Ximea Co., Ltd. (Germany) was finally selected. The camera has a pixel size of 5.5 micrometers, a resolution of 4.2 megapixels, and a frame rate of 90fps. A VTG1614 industrial lens from SATOO Co., Ltd. (Japan) with a resolution of 5 megapixels and a nominal focal length of 16mm was also selected. Based on the above camera, and using a tripod and mounting plate, an infrared binocular stereo vision measurement system was built. In actual use, the dual cameras can be split into two single cameras depending on the site conditions, thereby increasing the baseline length.
[0106] For the 400mm*400mm*400mm field of view in the binocular stereo vision measurement system presented in this paper, an industrial camera with a resolution of 2048 pixels * 2048 pixels was selected. Each pixel corresponds to a spatial measurement resolution of 0.075mm*0.075mm*0.075mm. Combining the infrared binocular measurement unit's internal and external parameter calibration method with an accuracy of 0.13 pixels and the BSV-IGSF algorithm with an accuracy of 0.1 pixels, the measurement accuracy of the infrared light source spot center position can reach the ten-micrometer level. To further improve the measurement accuracy, an error compensation method based on the BLSTM-MHA-TCN algorithm was designed. By combining the two methods, the aim is to improve the real-time measurement accuracy of CNC machine tool geometric errors to the micrometer level.
[0107] Due to manufacturing errors in industrial cameras and ceramic calibration plates, the calibrated internal and external parameters of the infrared binocular measurement unit (BMU) may contain certain errors. The ceramic calibration plate is fixed on a linear translation stage. In this embodiment, a high-precision linear translation stage LMP850 manufactured by Renishaw was used for the experiment (positioning was achieved using a high-precision grating ruler with a positioning error of 1 micrometer). The stage was moved along the X, Y, and Z axes of the BMU coordinate system, allowing the ceramic calibration plate to traverse the entire field of view of the BMU. The center of the ceramic calibration plate was measured by the BMU before and after each movement to improve calibration accuracy. The measurement results were compared with the positioning results of the high-precision linear translation stage, and a measurement error model was constructed based on the difference between the two to compensate for the internal and external parameters of the BMU.
[0108] After acquiring images of the calibration board, I used OpenCV 2.4.4 + Visual Studio 2022 hybrid programming to complete the monocular and binocular calibration of the binocular measurement unit, as well as the writing and debugging of the binocular model measurement program. After successful debugging, I conducted a binocular measurement unit calibration experiment using a purchased high-precision ceramic calibration board. The board was positioned in different orientations, and the internal and external parameters of the binocular measurement unit were calibrated. The transformation relationship between the binocular measurement unit coordinate system and the world coordinate system was calibrated using the high-precision ceramic calibration board (calibration accuracy within 0.13 pixels and 9.75 micrometers).
[0109] The calibrated internal and external parameters of the infrared binocular measurement system are shown below:
[0110] (1) The internal parameters of the left and right cameras are:
[0111]
[0112]
[0113] (2) The distortion coefficients of the left and right cameras are:
[0114]
[0115]
[0116] (3) The external parameters between the two cameras are:
[0117]
[0118] .
[0119] In online measurement of geometric errors in CNC machine tools, the infrared binocular measurement unit needs to locate the center of the infrared light source in real time, requiring a measurement accuracy at the micrometer level, far exceeding the measurement accuracy of general binocular stereo vision measurement systems. For the nonlinear measurement error of the infrared light source center position, this embodiment uses a laser interferometer (measurement accuracy 0.1 micrometers) for positional measurement compensation. Figure 7 As shown, the infrared light source is fixed on a linear translation stage (with a movement accuracy of 0.5 micrometers). The translation stage is controlled to move the infrared light source along the Z-axis perpendicular to the coordinate system of the infrared binocular measurement unit, allowing the infrared light source to traverse the entire field of view of the infrared binocular measurement unit. During the movement of the infrared light source, a dual-frequency laser interferometer is aligned with the binocular stereo vision measurement system. Both are used to measure the center of the infrared light source before and after each movement, thus completing the calibration of the binocular stereo vision measurement system.
[0120] After obtaining the infrared light source image, high-precision coordinates of the infrared light source center were obtained based on the BSV-IGSF algorithm, and the program was written and debugged. After successful debugging, an experiment was conducted to extract the center of the infrared light source spot. The coordinates of the infrared spot center were located in real time, and the obtained phase plane coordinates were brought into the binocular model to obtain the coordinates of the infrared spot center in the binocular measurement unit coordinate system (spot center extraction accuracy within 0.1 pixels and 7.5 micrometers).
[0121] After obtaining the center positions of the infrared light source before and after each movement using a dual-frequency laser interferometer and a binocular stereo vision measurement system, the measurement results from the binocular stereo vision system are compared with those from the laser interferometer. Measurement error relationship curves are constructed using the BLSTM-MHA-TCN algorithm based on the differences between the two in the X, Y, and Z directions, respectively. Figure 8 As shown, the measurement error of the infrared binocular measurement unit is compensated according to the error relationship curve. The displacement measurement error of the measurement system in the X, Y, and Z directions after compensation is reduced. Figure 9 As shown.
[0122] from Figure 8 It can be seen that the displacement measurement error of the measurement system in the X, Y, and Z directions is approximately ±0.08 mm. From... Figure 9 It can be seen that, after compensation, the displacement measurement error of the measurement system in the X, Y, and Z directions is within ±0.0015 mm.
[0123] After calibrating the infrared binocular stereo vision measurement system, a verification experiment on the geometric error measurement of a CNC machine tool was conducted. In the experiment, an iron plate equipped with an infrared light source was fixed to a fixture and moved along the X, Y, and Z directions along the machine tool guide rails, allowing the infrared light source to traverse the entire machining area of the CNC machine tool. During the movement, the moving distance was measured using the infrared binocular stereo vision measurement system designed in this paper (split into left and right monocular cameras) and a Renishaw XL80 laser interferometer calibrated by the National Institute of Metrology of China (accuracy ±0.1μm). The measurement results were compared with the feedback data from the grating ruler carried by the machine tool itself to obtain the geometric error measurement results of the CNC machine tool. The experiment was conducted on a high-precision three-axis machining center AVL850e produced by Shandong Chenbang CNC Equipment Co., Ltd. (using a grating ruler for positioning, with a theoretical positioning error of 10 micrometers). The experiment was conducted at a temperature of 20±2℃, after the machining center was preheated for 1 hour.
[0124] In the X, Y, and Z directions, the CNC machine tool's travel distance is divided into eight segments. Including the initial point, nine points are selected in each of the three directions for geometric error measurement. The guide rail is repeatedly moved, and fifty measurements are performed at each of the nine points in each of the three directions. Based on the measurement results from the infrared binocular stereo vision measurement system, the laser interferometer, and the machine tool's own positioning travel distance, the BLSTM-MHA-TCN algorithm introduced in this paper is used to obtain the geometric error G at each point in the three directions. X G Y G Z As shown in column 1 of Table 1. For comparison, linear interpolation algorithm and cubic spline fitting algorithm were used to obtain error relationship curves, thereby compensating for the measurement error of the binocular stereo vision measurement system. The compensated measurement errors are shown in columns 2 and 3 of Table 1.
[0125] Table 1. Measurement error of geometric error after compensation
[0126]
[0127] As shown in Table 1, after error compensation, the cubic spline fitting algorithm has the largest error, followed by the linear interpolation algorithm. The BLSTM-MHA-TCN algorithm proposed in this embodiment reduces the error by 91.8% compared to the cubic spline fitting algorithm. It can be concluded that the BLSTM-MHA-TCN algorithm has significant advantages in improving the measurement accuracy of geometric errors in CNC machine tools.
[0128] This embodiment proposes a method for real-time online measurement of geometric errors in CNC machine tools based on the BSV-IGSF algorithm. To improve measurement accuracy, a measurement error compensation method based on the BLSTM-MHA-TCN algorithm is designed. Experimental results show that this embodiment can achieve high-precision online measurement with an accuracy of 2 micrometers. The main contribution of this embodiment is that the proposed method can achieve high-precision measurement of geometric errors in CNC machine tools, providing a reference for their online detection.
[0129] The above embodiments are merely exemplary embodiments of the present invention and are not intended to limit the present invention. Those skilled in the art can make various modifications or equivalent substitutions to the present invention within its scope and spirit, and such modifications or equivalent substitutions should also be considered to fall within the scope of protection of the present invention.
Claims
1. A method for online measurement and compensation of geometric errors in CNC machine tools, characterized in that, Includes the following steps: Step 1: Install infrared light sources evenly on the lower edges of the spindle and fixture respectively. Fix the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit in appropriate positions on the CNC machine tool body, and calibrate the internal and external parameters of the two infrared binocular measurement units. Step 2: Light up the infrared light sources respectively, and use the improved Gaussian surface fitting algorithm to obtain the coordinates of the center of the infrared light source in the coordinate systems of the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit. Then, calibrate the transformation relationship between the coordinate systems of the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit and the machine tool coordinate system respectively. Step 3: Move the spindle and fixture to various positions in the machining area. Based on the transformation relationship obtained in Step 2, transform the measured coordinates of the infrared light source center in the infrared binocular measurement unit coordinate system into coordinates in the machine tool coordinate system to obtain the actual geometric trajectory of the spindle and fixture. Step 4: Establish an error compensation model based on the BLSTM-MHA-TCN algorithm, and use the spindle and fixture infrared binocular measurement unit to obtain the coordinates in the machine tool coordinate system in real time; Step 5: Compare the actual geometric trajectory obtained in Step 3 with the theoretical geometric trajectory to obtain the dynamic geometric error. Based on the error compensation model obtained in Step 4, correct the geometric trajectory in real time. The error correction model establishment process in step 4 specifically includes: establishing a bidirectional long short-term memory network, determining the ratio of the new input state to the data at the previous time step through the input gate, and forming a new dataset as input; The output gate obtains the output result based on the integral of the higher input state and the current input state; The bidirectional long short-term memory network introduces a multi-head attention layer at the back end. Based on the different operating conditions of the CNC machine tool, the linear layer is used to correct the feature dimension of the input data. The segmentation operation divides the embedding vector of the input sequence data into multiple heads and assigns different attention weights to the input features, so as to more accurately predict the pose of the CNC machine tool spindle and fixture. The data output by the multi-head attention mechanism enters the TCN network, where the feature dimensions are expanded. The expanded feature dimensions are then sent back to the bidirectional long short-term memory network and the multi-head attention layer for further iteration until the optimal solution is obtained, thus yielding the geometric error compensation model.
2. The method for online measurement and compensation of geometric errors in CNC machine tools according to claim 1, characterized in that, The calibration process of the internal and external parameters in step 1 is as follows: ceramic calibration plates are placed on the fixture in different postures, and multiple sets of calibration plate images are collected by the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit respectively. Based on the coordinates of the calibration points on the phase plane and the calibration plate plane respectively, the internal and external parameters of the two infrared binocular measurement units are calibrated.
3. The method for online measurement and compensation of geometric errors in CNC machine tools according to claim 1, characterized in that, The improved Gaussian surface fitting algorithm in step 2 is as follows: When scanning the light bar image row by row and column by column, if two or more consecutive pixels are detected to have saturated gray values, then all saturated pixels will not participate in Gaussian fitting; if only one pixel is detected to have saturated gray values, then that saturated pixel will participate in Gaussian fitting; after determining the number of saturated pixels to be filtered out, the roughly calculated center point of the light spot is used as the midpoint, and the radius of the light spot is reduced by a scale based on the original radius of the light spot; the number of pixels in the light spot minus the number of filtered saturated pixels, and the remaining pixels maintain a light spot radius of 3-5 pixels, and participate in the final Gaussian fitting.
4. The method for online measurement and compensation of geometric errors in CNC machine tools according to claim 1, characterized in that, The main shaft infrared binocular measurement unit and the fixture infrared binocular measurement unit use two high-resolution, low-distortion cameras with identical model parameters, which are installed in a pre-designed housing. The design baseline length is 460mm, and the angle between the optical axes of the two cameras is 18°.
5. The method for online measurement and compensation of geometric errors in CNC machine tools according to claim 1, characterized in that, Before obtaining the center coordinates of the infrared light source in step 2, the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit are calibrated. Specifically, the laser interferometer is aligned with the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit respectively. At the same time, the laser interferometer is used to measure the center of the infrared light source before and after each movement with the spindle infrared binocular measurement unit and the fixture infrared binocular measurement unit to complete the calibration.
Citation Information
Patent Citations
Real-time self-feedback numerical control machine tool and machining method based on same
CN108311952A
Underwater robot autonomous positioning method and system based on binocular stereo vision
CN117310773A