Spindle thermal error prediction method and spindle thermal error compensation system based on double-flow space-time fusion
By using a dual-stream spatiotemporal graph attention fusion network model and a digital twin system, the problem of insufficient spatiotemporal feature capture in thermal error prediction is solved, achieving high-precision and robust real-time thermal error compensation, which meets the real-time requirements of precision machining.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies fail to effectively capture spatiotemporal characteristics in thermal error prediction, resulting in insufficient prediction accuracy and robustness. Furthermore, real-time compensation systems lack security and real-time performance, making it difficult to meet the requirements of precision machining.
A dual-stream spatiotemporal graph attention fusion network model is adopted, which uses temperature-sensitive points and non-temperature-sensitive points as primary and secondary feature streams. The spatiotemporal feature extraction is enhanced by an interactive fusion module. Combined with a digital twin system trained on edge computing and cloud, real-time thermal error prediction and compensation are achieved.
It improves the accuracy and robustness of thermal error prediction, ensures the reliability of real-time compensation and the safety of the system, and meets the real-time requirements of precision machining.
Smart Images

Figure CN121763940A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of thermal error control technology, specifically a spindle thermal error prediction method and a spindle thermal error compensation system based on dual-stream spatiotemporal fusion. Background Technology
[0002] The precision machining field demands increasingly stringent tolerance requirements. Therefore, improving machining accuracy and stability has become a critical issue. During operation, friction and electrothermal activity lead to temperature increases, inevitably causing thermal expansion and deformation of machine tool components. For precision machine tools, this results in thermal errors. These errors significantly affect dimensional accuracy, accounting for 40-70% of total machining errors. Therefore, improving machining accuracy and reducing thermal errors have become priorities for research and industry. To reduce thermal errors, two control strategies are commonly employed: mechanism-based models and data-driven methods. Mechanism-based models require complex boundary conditions and high computational costs, making their real-time implementation extremely difficult. In contrast, data-driven methods typically achieve higher prediction accuracy. This method establishes a mapping relationship between thermal errors and temperature measurements, and its implementation is simpler than that of mechanism-based models. Therefore, data-driven thermal error compensation has been widely adopted in engineering practice.
[0003] In thermal error modeling, temperature is a crucial factor that cannot be ignored and must be input as a variable into the model, as temperature rise is the direct cause of thermal errors. Traditional data-driven models include Support Vector Machine (SVM), Gaussian Process Regression (GPR), Multiple Linear Regression (MLR), Least Squares Support Vector Machine (LSSVM), and Random Forest algorithms. However, if the relationship between thermal error and temperature is expressed solely through simple mathematical relationships established by machine learning, some important thermal information will be ignored due to the lack of self-learning ability, leading to decreased prediction accuracy and robustness. To more fully capture thermal information, neural network models are used for prediction. However, thermal information data is time-series data, exhibiting memory behavior. Existing methods have established empirical relationships between thermal error and temperature variables, but all ignore the time factor, resulting in reduced robustness and prediction accuracy. To consider the time factor, some time-based neural network models capable of learning and remembering complex relationships to represent memory behavior have been designed. Therefore, using neural networks with memory capabilities has become an important approach to building thermal error prediction models to improve prediction accuracy and robustness. LSTM is a type of RNN that possesses the ability to handle long-term data dependencies and plays a crucial role in preserving historical features. With the emergence of attention mechanisms, adding attention mechanisms to neural networks has become a new approach. The gated Tanh unit (GTU) is an activation unit based on a gated mechanism. Compared to LSTM and GRU, it is better suited for solving temperature-related problems, exhibits more stable gradients during backpropagation, and demonstrates greater generalization ability in time series prediction.
[0004] The aforementioned model primarily characterizes the temporal relationship of thermal errors. According to existing research, the spatial location of machine tool sensors also influences model performance. Therefore, the spatial location information of the sensors should be considered, as it affects model robustness and prediction accuracy. However, researchers mainly focus on modeling the temporal characteristics of thermal information acquisition, neglecting the spatial information of the sensors, leading to reduced modeling accuracy and robustness. To balance spatiotemporal information, Graph Convolutional Networks (GCNs) are introduced, which can establish temperature-related graph structures based on spatial location. Specifically, the Spatiotemporal Graph Convolutional Network (STGCN) is used to perform sequential convolution operations in both the spatial and temporal domains. Each module first performs graph convolution followed by temporal (sequence) convolution to extract deep spatiotemporal features. However, spatial and temporal behaviors are not independent. Most studies do not simultaneously learn spatiotemporal interactions; this separation reduces computational efficiency and may lead to gradient explosion. Graph Multi-Attention Networks (GMANs) are a deep learning model for spatiotemporal prediction that captures dependencies across spatiotemporal domains by combining graph neural networks with multi-attention mechanisms. Although attention is used to learn spatiotemporal features, this model relies on large-scale data input. The Spatiotemporally Gated Hybrid Transformer Network (STGHTN) employs multi-head attention (MSA) and a spatiotemporal fusion structure, but it fails to capture multi-scale temporal information when extracting temporal features. Its spatiotemporal aggregation method is merely particle aggregation, failing to fully fuse spatiotemporal features. Furthermore, none of the aforementioned models capture multi-scale temporal information, resulting in insufficient global context, and the spatial receptive field cannot be dynamically adjusted, thus limiting their ability to model data with variable context ranges. Multiple temperature measurements often exhibit collinearity; if temperature sensitive points (TSPs) are not selected as input, collinearity among multiple sensors severely weakens robustness. Previous studies have used fuzzy clustering and grey clustering algorithms for clustering, then selected TSPs and completely discarded non-TSPs.
[0005] It can be concluded that capturing spatiotemporal features is crucial for achieving robust and high-accuracy thermal error prediction. Simple time-series models only learn temporal information while ignoring spatial features; some existing spatiotemporal models, while considering both, fail to achieve interactive fusion and do not handle collinearity between temperature points. Therefore, the interaction between TSP clustering and explicit spatiotemporal features should be considered when constructing prediction models. Since some measurement points have a greater impact on thermal error when filtering non-TSPs, discarding them would lead to the loss of important features and reduce prediction performance. Traditionally, spatiotemporal models use adjacency matrices as spatial features, which are constructed based on Euclidean distances between sensor locations. The aforementioned factors limit the robustness and accuracy of these spatiotemporal models. To better encode spatiotemporal relationships, a temporal adjacency matrix is introduced and fused with the spatial matrix to form a spatiotemporally fused adjacency matrix. Derivative Dynamic Time Warping (DDTW) can effectively extract temporal features and can be used to construct the temporal adjacency matrix, while the spatial adjacency matrix is calculated using Euclidean distance. Combining the two helps to capture spatiotemporal information.
[0006] Compensation systems are crucial for achieving thermal error compensation. A robust and highly accurate prediction model is the core of such a system. Due to the variable, nonlinear, and unsteady nature of thermal errors, real-time online compensation is essential. The real-time performance of the compensation system is paramount. Recent research has shifted compensation systems from offline modeling to online closed-loop deployment by employing digital twins (DT). A common approach is edge-cloud collaboration. Specifically, edge nodes are used to predict thermal errors, run inference, and generate compensation instructions, while cloud servers use historical data to train and update the model. Compensation values are written into the computer numerical control (CNC) / programmable logic controller (PLC) loop to close the dual-machine feedback. For example, a fog / edge-cloud LSTM system was designed for heavy-duty CNC machine tools, employing cloud hosting and cross-site learning for compensation. Temporal deep networks (such as LSTM) and federated learning are used for adaptation across machine tools and sites. The introduction of Kalman filter state observers enables real-time prediction without machine-specific training data. Edge intelligence is used to reduce communication load and shorten inference paths. Case studies demonstrate that deploying digital twin (DT) inference near the machine tool reduces data transmission and improves machining accuracy. Integrated monitoring, data management, and on-machine deployment DT frameworks have been applied at the industrial scale. Simultaneously, DT-aware spatiotemporal models are being explored to enhance prediction capabilities under small sample sizes and varying operating conditions. Digital twin thermal error networks with interactive spatiotemporal fusion have shown higher compensation accuracy and achieved superior real-time performance on prototypes. However, due to the high computational load of thermal error models, the real-time performance of DT-based thermal error compensation systems remains relatively weak and requires further improvement.
[0007] Based on the above analysis, the research gaps are summarized as follows: (1) Most DT compensation systems only report the average delay, and rarely establish worst-case end-to-end delay, jitter tolerance, and cutoff period missing analysis aligned with the CNC interpolation cycle. The compensation system lacks a safety / uncertainty hierarchy, and real-time thermal error compensation rarely includes calibration uncertainty or fail-safe backoff mechanisms (e.g., a safety mode on the controller side when inference delay or confidence is low). (2) Existing studies often discard non-temperature-sensitive point sensors or select temperature-sensitive points offline, which reduces feature integrity and ignores runtime collinearity mitigation. (3) Spatial graphs are usually based only on Euclidean distance and are time-invariant, and temporal similarity is rarely adaptively fused, resulting in insufficient modeling of heat transfer state transitions. (4) Many studies sequentially apply spatial and temporal models, failing to capture the bidirectional interaction between primary and secondary feature flows, thus limiting the acquisition of global context. Summary of the Invention
[0008] In view of this, the purpose of this invention is to provide a spindle thermal error prediction method and a spindle thermal error compensation system based on dual-stream spatiotemporal fusion. It adopts a dual-stream spatiotemporal graph attention fusion network model with dual-stream collinearity sensing, takes temperature-sensitive points as the main feature stream and non-temperature-sensitive points as the secondary feature stream, and retains auxiliary information while suppressing online collinearity through interactive fusion, which can effectively improve prediction accuracy and robustness.
[0009] To achieve the above objectives, the present invention provides the following technical solution:
[0010] A spindle thermal error prediction method based on dual-stream spatiotemporal fusion includes the following steps:
[0011] S1: Obtain temperature data of the spindle at N temperature measurement points, where N≥2;
[0012] S2: Divide the N temperature measurement points into a temperature-sensitive set P and a non-temperature-sensitive set S, where: P∪S={1,2,...,N}; the temperature data of the temperature-sensitive point set P is used as the main feature stream. The temperature data of the non-temperature-sensitive point set S is used as a secondary feature stream.
[0013] S3: Transfer the main feature stream and secondary feature flow The features are input into a dual-stream spatiotemporal graph attention fusion network model, which includes a primary feature extraction module and a secondary feature extraction module with identical structures, as well as an interactive fusion module, to extract and fuse spatiotemporal features; wherein,
[0014] The main feature extraction module is used to process the main feature stream. The secondary feature extraction module is used to process the secondary feature stream.
[0015] The interactive fusion module is used to execute the main feature stream. With secondary feature flow The two-way information exchange and fusion between the modules enhances the representation of the main features and captures global spatiotemporal dependencies; the two-way information exchange and fusion includes at least: aggregating the spatial information extracted by the secondary feature extraction module into the spatiotemporal features of the main feature extraction module, and feeding back the spatial information extracted by the main feature extraction module into the spatiotemporal features of the secondary feature extraction module.
[0016] S4: Based on the fusion output of the dual-stream spatiotemporal graph attention fusion network model, the thermal error value of the main axis is predicted.
[0017] Furthermore, both the primary feature extraction module and the secondary feature extraction module include a multi-scale attention-gated temporal unit, a large-selectivity kernel spatial extractor, and a spatiotemporal convolution unit connected in sequence; wherein:
[0018] The multi-scale attention-gated temporal unit is used to extract the temporal features of the input data;
[0019] The high-selectivity kernel spatial extractor is used to extract spatial features of the input data and dynamically adjust the receptive field.
[0020] The spatiotemporal convolutional unit is used to fuse temporal features from the multi-scale attention-gated temporal unit and spatial features from the large selective kernel spatial extractor, and performs graph convolution based on a spatiotemporal fusion adjacency matrix to output the main feature stream. and secondary feature flow The spatiotemporal characteristics of fusion.
[0021] Furthermore, the multi-scale attention gating time unit performs the following operations:
[0022] For the input four-dimensional tensor X t ∈R B×C×N×T One-dimensional causal convolution is performed by applying multiple gated unit (GTU) branches with different kernel sizes along the time axis, wherein the kernel size includes at least 3, 5, and 7.
[0023] Each GTU branch executes the output. The following formula is used to calculate:
[0024] First, convolution is performed on the time dimension to map the channels from C to 2C:
[0025] X conv =Conv2d(X t )∈RB×2C×N×(T-K+1)
[0026] Where: X conv B represents the convolution output; C represents the batch size; N represents the number of nodes; T represents the number of channels; and K represents the kernel size.
[0027] The convolution output X conv Divide into X along the channel dimension P and X q Two parts, respectively for X P and X q The two parts apply the tanh(·) and sigmoid(·) activation functions, and the output of the GTU branch is obtained through element-wise product:
[0028] X gtu =tanh(X) p )⊙sigmoid(X q )
[0029] Where: ⊙ represents element-wise multiplication;
[0030] The output of each GTU branch of the gate control unit and By splicing along the time axis, we obtain X. concat ;
[0031]
[0032] X is processed through an efficient channel attention module concat Perform channel reweighting to obtain the weighted feature X. att :
[0033] X att =A(X) concat )
[0034] Where: A is the adjacency matrix;
[0035] The weighted feature X att After mapping through a fully connected layer, it is compared with the original input X. t The residues are added together and then activated by ReLU before being output:
[0036] X final =RELU(X t +f(X att ))
[0037] Where: X final This is the output of the multi-scale attention-gated time unit.
[0038] Furthermore, the highly selective nuclear space extractor performs the following operations:
[0039] Based on spatial features X s =R B×C×N×T Spatial information is obtained via GCN as input:
[0040]
[0041] Where: A is the adjacency matrix; (in ); I is the identity matrix; It is a degree matrix; Here, σ is the weight matrix; σ is the activation function.
[0042] Pass through m deep convolutional layers with different receptive fields in sequence Obtain the multi-scale feature representation U i+1 :
[0043]
[0044] in: U is the i-th depthwise convolutional layer; i+1 This represents the feature representation output by the depthwise convolution of the i-th layer;
[0045] For each scale of feature U i Through a 1×1 convolutional layer The transformation is performed to obtain the feature representation at the i-th scale:
[0046]
[0047] By concatenating the multi-scale features along the channel dimension, we obtain:
[0048]
[0049] Perform global average pooling and global max pooling, and concatenate the results to generate a spatial attention map.
[0050]
[0051] Where: AvgPool(·) is the global average pooling layer; MaxPool(·) is the global max pooling layer;
[0052] The spatial attention map The final spatial attention weights S are obtained by processing with the Sigmoid function and the convolutional layer F(·);
[0053]
[0054] Take the original input X sThe spatial attention weights S are multiplied element-wise to output the enhanced spatial features Y = X. s ⊙S.
[0055] Furthermore, the spatiotemporal fusion adjacency matrix construction method includes:
[0056] Based on the Euclidean distance d between each measuring point i,j Construct the spatial adjacency matrix A S ,in:
[0057]
[0058] Where: ζ is the variance;
[0059] A time adjacency matrix A is constructed based on the derivative dynamic time warping similarity of temperature time series at temperature measurement points. t ,in:
[0060]
[0061] Where: D ij For time series X i With X j The DDTW distance between them; τ is the scale parameter;
[0062] Calculate the spatial adjacency matrix A S and the time adjacency matrix A t The Pearson correlation coefficient ρ between them t :
[0063] ρ t =corr(vecA spa ,vecA tm p)
[0064] Among them: A spa and A tmp These are the spatial adjacency matrix and the temporal adjacency matrix, respectively.
[0065] Generate fusion weights based on the correlation coefficients:
[0066] α t =(1+ρ t ) / 2
[0067] The two adjacency matrices are weighted and merged according to the fusion weight:
[0068]
[0069] Add a self-connect to the merged matrix and perform symmetric normalization:
[0070]
[0071] Where: D t I is the degree matrix; I is the identity matrix.
[0072] Furthermore, the specific fusion calculation process of the interactive fusion module is as follows:
[0073] For the main feature stream, the enhanced features for:
[0074]
[0075] Where: Y a The spatial information output by the large selective kernel spatial extractor in the secondary feature extraction module; X p The main feature information output by the spatiotemporal feature fusion of the main feature extraction module; W l p A linear transformation embedded in the central node; A linear transformation of the domain-aggregated message; N a The domain of the central node; The output of the main feature extraction module; These are intermediate enhanced features resulting from aggregation and nonlinear mapping;
[0076] For secondary feature streams, the enhanced features for:
[0077]
[0078] Where: Y p Spatial information output by the large selective kernel spatial extractor in the main feature extraction module; X a The main feature information output after spatiotemporal feature fusion of the secondary feature module; W l a A linear transformation embedded in the central node; A linear transformation of the domain-aggregated message; N p The domain of the central node; This is the output of the secondary feature extraction module; The enhanced intermediate feature representation is obtained by introducing the spatial information of the main feature flow into the l-th level feature flow through neighborhood aggregation, linear transformation and nonlinear mapping.
[0079] This invention also proposes a spindle thermal error compensation system based on dual-stream spatiotemporal fusion, comprising:
[0080] The thermal error prediction model is based on the spindle thermal error prediction method based on dual-stream spatiotemporal fusion as described above.
[0081] The physical layer includes multiple temperature sensors and at least one displacement sensor arranged on the machine tool spindle, as well as a data acquisition and preprocessing unit, used to synchronously acquire temperature and thermal error signals and perform analog-to-digital conversion and filtering.
[0082] The edge computing node is equipped with the thermal error prediction model. It receives real-time data preprocessed by the physical layer through the industrial network, performs thermal error prediction, and generates compensation instructions.
[0083] The digital space layer includes a cloud training platform and a local data platform. The cloud training platform is used to train and update the dual-stream spatiotemporal graph attention fusion network model using historical data, and the local data platform is used to store and manage real-time and historical data.
[0084] The controller layer includes a programmable logic controller (PLC) and a computer numerical control (CNC) system. The PLC is used to receive compensation instructions from the edge computing nodes, and the CNC system is used to apply the compensation instructions in the current position control loop to achieve real-time closed-loop compensation.
[0085] The human-machine interface provides a visual interface to display spindle temperature distribution, thermal error prediction curve, compensation command value, key real-time performance indicators of the system, and machine tool operating status.
[0086] Furthermore, the programmable logic controller is based on the predicted thermal error value. Generate compensation instruction u t The machine tool CNC system has an interpolation cycle T. s Within, the compensation command u t The position controller is written to perform thermal error compensation; the end-to-end delay L within the interpolation period satisfies the deterministic real-time constraint L. max ≤T s and jitter constraint J≤J budget ,and:
[0087]
[0088] L∈E2E delay of periodic measurements
[0089] in: The time t for sensor and PLC preprocessing S Maximum allowed value; The time t for PLC to edge transmission X Maximum allowed value; The time t for edge reasoning I Maximum allowed value; The time t for edge-to-PLC / CNC write-back W Maximum allowed value; The execution time t for the position loop A Maximum allowed value; L max The maximum allowable delay; J budget This is the maximum allowable budget value for end-to-end delay jitter, used to constrain the statistical fluctuation range of the end-to-end delay within consecutive interpolation periods.
[0090] Furthermore, it also includes uncertainty gating and an arbitrary time-based compensation and backoff mechanism:
[0091] The uncertainty gating mechanism is based on the rolling residual set. Calculate the security gain g t :
[0092]
[0093] Where: q α λ is the 1-α empirical quantile of the residual; λ is the adjustable safety gain; ε>0 is a small constant; the output compensation command u t Updated to g t u t ;y k The actual thermal error observation value of the spindle obtained by the machine tool measurement system at the kth sampling time is the displacement error or equivalent displacement error of the spindle caused by thermal deformation. The predicted value of the spindle thermal error is output by the dual-stream spatiotemporal fusion prediction model at the k-th sampling time.
[0094] The arbitrary time compensation and rollback mechanism applies when the single inference time exceeds the deadline t. ddl =T s When activated, the rollback compensation value is:
[0095]
[0096] in: It is at a strict boundary The low-order observer obtained through internal computation; β t This is the fallback fusion coefficient.
[0097] Furthermore, the system supports online graph refresh and hot model switching:
[0098] The online graph refresh is performed once every R control cycles, and the time similarity matrix A is recalculated based on the latest temperature data. t and fusion weight α t Update the spatiotemporal fusion adjacency matrix Furthermore, the worst-case time cost of the refresh operation satisfy:
[0099]
[0100] The model hot switching is achieved by maintaining A / B dual model channels on the edge computing node and seamlessly switching the quantized model weights during the compensation process. The additional latency introduced by the switching is incorporated into real-time budget management.
[0101] The beneficial effects of this invention are as follows:
[0102] This invention presents a spindle thermal error prediction method based on dual-stream spatiotemporal fusion. Through an innovative "dual-stream" architecture and "interactive fusion" mechanism, it significantly improves the accuracy and robustness of spindle thermal error prediction, achieving the following technical effects:
[0103] (1) Effectively overcome collinearity and retain information integrity: In order to avoid multicollinearity among temperature sensors, traditional methods usually discard non-temperature sensitive points directly, resulting in the loss of valuable auxiliary information. This invention divides the measurement points into primary and secondary dual flows, and retains non-temperature sensitive points as secondary features. At the same time, through the subsequent interactive fusion module, the main features are enhanced while the collinearity effect is suppressed, so as to make full use of the information of all sensors without model degradation.
[0104] (2) Deep spatiotemporal feature interaction fusion is realized: Unlike the existing spatiotemporal feature processing models that are serial or separate, this invention establishes a bidirectional information exchange channel between the main and secondary streams through a dedicated interaction fusion module (the secondary stream spatial information enhances the main stream, and the main stream spatial information is fed back to the secondary stream); this design forces the model to learn the global spatiotemporal dependency relationship, more accurately model the dynamic and nonlinear process of heat transfer, and thus extract more discriminative fusion features;
[0105] (3) A complete and efficient technical process closed loop has been formed: from data partitioning, dual-stream parallel processing to interactive fusion, a logically rigorous and hierarchical prediction process has been constructed. It not only theoretically conforms to the physical nature of the spatiotemporal coupling of thermal error, but also the modular design facilitates engineering deployment and optimization, laying the core algorithm foundation for the final realization of high-precision prediction and subsequent real-time digital twin compensation.
[0106] In summary, this invention resolves the contradiction between collinearity suppression and feature integrity preservation in the prediction model through architectural innovation, and enhances the model's expressive power through deep spatiotemporal fusion, ultimately achieving superior and more stable thermal error prediction performance.
[0107] This invention is based on a dual-stream spatiotemporal fusion spindle thermal error compensation system. Through a collaborative architecture of precise perception at the physical layer, real-time inference at edge nodes, continuous optimization at the digital space layer, and closed-loop execution at the controller layer, it systematically solves the industry problem of achieving real-time performance, accuracy, and robustness simultaneously in spindle thermal error compensation. The main technical effects achieved are as follows: (1) Achieving deterministic real-time compensation: By deploying lightweight models at the edge, and using clear end-to-end delay budgets and priority scheduling, the compensation instructions are reliably executed within millisecond-level interpolation cycles, meeting the real-time requirements of precision machining; (2) Achieving a balance between high accuracy and strong robustness: The dual-stream network structure combined with an adaptive spatiotemporal fusion graph fully utilizes spatiotemporal features while suppressing sensor collinearity, significantly improving prediction accuracy and maintaining stability under varying operating conditions; (3) Ensuring system practicality and security: Edge-cloud collaboration supports online model updates; the built-in rollback and gating mechanisms provide a safety boundary for the real-time loop, ensuring that the system can still safely degrade during disturbances or overloads, greatly improving the reliability of industrial deployment. Attached Figure Description
[0108] To make the objectives, technical solutions, and beneficial effects of this invention clearer, the following figures are provided for illustration:
[0109] Figure 1 A simplified schematic diagram of the thermal deformation of a one-dimensional principal shaft;
[0110] Figure 2 This is a framework diagram of the STG-AFN model;
[0111] Figure 3 This is the schematic diagram of the MSAGTU module;
[0112] Figure 4 This is the schematic diagram of the LSKSE module;
[0113] Figure 5 This is a framework diagram of the spindle thermal error compensation system based on dual-stream spatiotemporal fusion of the present invention;
[0114] Figure 6 Flowchart for information transmission compensation;
[0115] Figure 7 This is a layout diagram of the data acquisition system and sensor locations;
[0116] Figure 8 This is a working condition diagram;
[0117] Figure 9 Temperature data under two operating conditions;
[0118] Figure 10 TE data for two operating conditions;
[0119] Figure 11The spatial adjacency matrix and the temporal similarity matrix are used.
[0120] Figure 12 A comparison of the prediction performance of different input methods;
[0121] Figure 13 This is the prediction result for the second working condition;
[0122] Figure 14 This refers to the predicted residual under the second operating condition;
[0123] Figure 15 This is the prediction result for the first working condition;
[0124] Figure 16 This refers to the predicted residual under the first operating condition;
[0125] Figure 17 This is an ablation experiment under the second operating condition;
[0126] Figure 18 The processed workpiece. Detailed Implementation
[0127] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.
[0128] 1. A spindle thermal error prediction method based on dual-stream spatiotemporal fusion
[0129] This embodiment is based on a spindle thermal error prediction method using dual-stream spatiotemporal fusion, and includes the following steps.
[0130] S1: Obtain temperature data at N temperature measurement points on the spindle, where N≥2.
[0131] S2: Divide the N temperature measurement points into a temperature-sensitive set P and a non-temperature-sensitive set S, where: P∪S={1,2,...,N}; the temperature data of the temperature-sensitive point set P is used as the main feature stream. The temperature data of the non-temperature-sensitive point set S is used as a secondary feature stream.
[0132] S3: Transfer the main feature stream and secondary feature flow The features are input into a dual-stream spatiotemporal graph attention fusion network model, which includes a primary feature extraction module and a secondary feature extraction module with identical structures, as well as an interactive fusion module, to extract and fuse spatiotemporal features; wherein,
[0133] The main feature extraction module is used to process the main feature stream. The secondary feature extraction module is used to process the secondary feature stream.
[0134] The interactive fusion module is used to execute the main feature stream. With secondary feature flow The two-way information exchange and fusion between the modules enhances the representation of the main features and captures global spatiotemporal dependencies; the two-way information exchange and fusion includes at least: aggregating the spatial information extracted by the secondary feature extraction module into the spatiotemporal features of the main feature extraction module, and feeding back the spatial information extracted by the main feature extraction module into the spatiotemporal features of the secondary feature extraction module.
[0135] S4: Based on the fusion output of the dual-stream spatiotemporal graph attention fusion network model, the thermal error value of the main axis is predicted.
[0136] 1.1 Proof of Spacetime Characteristics
[0137] This embodiment demonstrates the spatiotemporal correlation of thermal errors through mathematical modeling. The final conclusion is that thermal error prediction is inseparable from its temporal and spatial characteristics, meaning it is a spatiotemporal prediction problem. Assume the machine tool spindle is a one-dimensional slender shaft with a bearing heat source at its left end, and the heat generated by this heat source is conducted from left to right.
[0138] like Figure 1 As shown, ΔX is the total elongation due to thermal deformation, ΔX1, ΔX2, ..., ΔX n Their origins are X1, X2, ..., X, respectively. n Before thermal deformation to the final point X1 ′ X2 ′ ,…,X ′ n The displacement distance, therefore ΔX can be expressed as ΔX=ΔX1+ΔX2+…+ΔX n During conduction, heat loss and time lag occur, and thermal deformation gradually decreases, thus obtaining... Figure 1 In the context of ΔX1>ΔX2>…>ΔX n The thermal deformation ΔX is defined as D(t). Meanwhile, the temperature distribution function is also closely related to spatial location; here, we consider a one-dimensional heat conduction equation:
[0139]
[0140] Where: T(x,t) is the one-dimensional internal temperature function of the shaft; L is the original length of the shaft; α is the thermal diffusivity, calculated from the thermal conductivity ∝, specific heat capacity τ, and principal shaft density ρ, and:
[0141] If ambient temperature is fully considered, the equation becomes:
[0142]
[0143] Where μ is the convective heat transfer coefficient; T0 is the ambient temperature.
[0144] Assuming heat is transferred to the axis in the form of a sine curve, the boundary conditions are defined as follows: (1) The temperature excitation at x = 0 is:
[0145] T(0,t)=γ0+γ1sin(ωt)
[0146] Where: γ0 is the reference temperature; γ1 is the amplitude; ω is the angular frequency.
[0147] At a specific point, the heat transfer process will respond to the heat source. (Axial positions x) i Temperature can be controlled by attenuation factor δ i and lag time ε i Characterized by this, its heat transfer equation can be expressed as:
[0148]
[0149] Where: δ i ε represents the attenuation coefficient of temperature amplitude with respect to space; λ represents the attenuation rate; ε i This indicates a temperature wave from x0 to x i The time delay can be used to obtain the following relationship:
[0150]
[0151] Thermal deformation can be calculated in two forms: integral and discrete. If the x-points on the axis are considered to be continuously distributed, then the thermal deformation can be expressed as:
[0152]
[0153] Where: β E Let T(x,t) be the coefficient of thermal expansion of the material; the analytical solution of T(x,t) is derived from Fourier's law:
[0154]
[0155] We can obtain:
[0156]
[0157] However, in practical applications, the axis length L is often discretely divided into n+1 computation nodes. The increment of each segment is based on the previously defined Δx. i The node temperature is obtained as T(x). i If ,t), then the thermal deformation can be approximated as:
[0158]
[0159] The thermal deformation formula fully integrates all factors. A comprehensive mathematical modeling analysis of the axial heat conduction process reveals that, due to time lag effects, different axial positions will produce different thermal deformations. This demonstrates that thermal error prediction is a problem with spatiotemporal correlation. Therefore, spatiotemporal characteristics must be fully considered.
[0160] 1.2 STG-AFN Model
[0161] In spindle thermal error prediction, temperature measurements represent the instantaneous thermal state of each sensor or region. They also encode the spatiotemporal relationships of heat conduction and diffusion between regions. The heat transfer process exhibits strong dynamic and nonlinear behavior. The dominant transfer modes differ across different regions and at different times. The model must learn precise and time-varying relationships between nodes (sensors or regions). Through this representation, the intrinsic mechanisms that generate thermal errors can be captured more realistically.
[0162] This embodiment proposes a dual-stream spatiotemporal graph attention fusion network model, aiming to characterize thermal errors by fully capturing their spatiotemporal behavior. The overall framework is as follows: Figure 2 As shown, the model comprises three parts: a main feature extraction module, a secondary feature extraction module, and a feature fusion module. The main and secondary feature extraction modules have identical structures, each consisting of a Multi-Scale Attention Gated Temporal Unit (MSAGTU), a Large Selective Kernel Spatial Extractor (LSKSE), and a dynamic spatiotemporal convolution. MSAGTU aims to extract temporal features; it includes a channel attention mechanism and multiple GTUs. Temporal patterns at different scales are captured, concatenated, and then reweighted through channel attention. This weighting allows the model to learn the importance of each channel and optimize the representation of complex time series. LSKSE aims to extract spatial features and dynamically adjusts the receptive field to handle changing conditions. Multi-scale spatial modeling is achieved by decomposing a large effective kernel into multiple convolutional layers with different receptive fields. The spatiotemporal convolution fuses the temporal features from MSAGTU with the spatial features from LSKSE within each stream. The feature fusion module, based on GraphSAGE, performs a two-stream interaction: spatial features from the secondary stream are aggregated with the spatiotemporal features of the primary stream to enhance the main representation; conversely, spatial features from the primary stream are fed back and fused with the secondary stream to capture global spatiotemporal dependencies. The goal is to strengthen the interaction and fusion, thereby fully utilizing the spatiotemporal information of both streams.
[0163] In this model, temperature and thermal error signals are first classified using TSP. The data is segmented into main stream and secondary stream. Each stream is passed through a one-dimensional convolutional layer to increase channel dimensionality and reveal local patterns, thus obtaining richer feature channels. The output is then fed into MSAGTU, which extracts temporal features at multiple scales, capturing and aggregating diverse temporal patterns to obtain comprehensive temporal information. Simultaneously, LSKSE is designed to extract spatial features. Next, a dynamic spatiotemporal convolution at time t fuses the temporal features from MSAGTU with the spatial features from LSKSE. This operation generates fused representations of the main stream and secondary stream, denoted as […]. and Each representation is further fused with the LSKSE spatial features of its respective stream (mainstream to mainstream, secondary to secondary). Finally, the fused outputs are combined via residual connections and weighted summation to produce the final output. and They serve as inputs for the next layer.
[0164] 1.2.1 MSAGTU Module
[0165] Time dependence and multi-scale patterns are crucial for thermal error prediction. Therefore, this embodiment designs MSAGTU to extract temporal information. Its framework is as follows: Figure 3 As shown, temporal convolutional outputs at different scales are fused by concatenation. The concatenated features are then reweighted through channel attention. Channel weights are learned to optimize feature selection. Inside MSAGTU, GTU extracts local temporal dependent features. The input is a four-dimensional tensor X. t ∈R B×C×N×T (Batch, Time, Node, Channel). Apply a one-dimensional causal convolution along the time axis with a kernel size of K. Convolution is performed only on the time dimension; this operation maps channels from C to 2C, and can be written as:
[0166] X conv =Conv2d(X t )∈R B×2C×N×(T-K+1)
[0167] Where: X conv is the convolution output; b is the batch size; C is the time; N is the number of nodes; T is the number of channels; K is the kernel size.
[0168] Then, a gated partitioning step is applied. The tensor is uniformly partitioned into two parts X along the channel dimension. P and X q Each section has C channels. Then, X is processed separately. P and X q The activation functions tanh(·) and σ(·)(sigmoid) are applied. The output of the GTU branch is obtained through element-wise (Hadamard) product:
[0169] X gtu =tanh(X) p )⊙sigmoid(X q )
[0170] Where ⊙ represents element-wise multiplication. This gating mechanism emphasizes information-rich time response while suppressing noise.
[0171] In this embodiment, MSAGTU employs three GTU branches of different scales to capture multi-scale temporal information, with convolutional kernel sizes of 3, 5, and 7, respectively. After convolution and gating, the resulting features are concatenated along the time axis to form a fused tensor. The branch output is denoted as... and The multi-scale fusion formula is:
[0172]
[0173] This operation aggregates temporal patterns from different receptive fields. The Efficient Channel Attention (ECA) module assigns adaptive weights to channels: first, global average pooling is performed; then, one-dimensional convolution is used to capture local cross-channel dependencies; finally, attention coefficients are generated using the sigmoid function. The weighted output is:
[0174] X att =A(X) concat )
[0175] Where: A is the adjacency matrix.
[0176] After channel weighting, the features are further mapped through a fully connected layer to obtain f(X). att The mapped output is added to the original input via a residual connection and then activated by ReLU:
[0177] X final =RELU(X t +f(X att ))
[0178] Where: X final This is the output of a multi-scale attention-gated temporal unit. The design fully utilizes multi-scale convolution for temporal feature extraction and dynamically adjusts channel features through a lightweight attention mechanism, thereby enhancing temporal representation capabilities and ultimately improving overall prediction performance.
[0179] 1.2.2 Data Computation Layer
[0180] In this embodiment, the LSKSE module is used to extract spatial features, and its framework is as follows: Figure 4As shown, this module dynamically adjusts the receptive field to adapt to input changes through a spatial selection mechanism: features generated by a set of deep convolutional kernels are re-weighted and fused along the spatial dimension, giving each location a dynamically adaptable receptive field. Spatial features are first used as input, and a Large Selective Kernel (LSK) mechanism generates a spatial attention map. The spatial extractor (SE) then fuses this attention with the original input through residual paths. This preserves the original spatial information while strengthening key structures, thereby facilitating subsequent extraction and discrimination. First, spatial information is obtained through a GCN:
[0181]
[0182] Where: A is the adjacency matrix; (in ); I is the identity matrix; It is a degree matrix; X is the weight matrix; σ is the activation function; s The spatial features are input, and X s =R B×C×N×T The data is passed sequentially through m deep convolutional layers with different receptive fields. Obtain the multi-scale feature representation U i+1 :
[0183]
[0184] in: For the i-th th Deep convolutional layer, U i+1 This represents the feature representation output by the depthwise convolutional layer ith. It contains m decomposed convolutional kernels, and the output of each kernel is then passed through a 1×1 convolutional layer. Modeling. For i th Scale feature representation and (where i∈[1,m]), and then the feature maps of different scales are spliced along the channels:
[0185]
[0186] Perform global average pooling and global max pooling, and concatenate the results to generate a spatial attention map.
[0187]
[0188] Where: AvfPool(·) is the global average pooling layer; MaxPool(·) is the global max pooling layer.
[0189] The spatial attention map The final spatial attention weights S are obtained by processing with the Sigmoid function and the convolutional layer F(·);
[0190]
[0191] Take the original input X s The LSKSE module outputs the enhanced spatial feature Y = X after element-wise multiplication with the spatial attention weight S. s ⊙S.
[0192] 1.2.3 Data Analysis Layer
[0193] To enhance the completeness and robustness of extracted primary and secondary features, a dual-stream feature fusion strategy is adopted. This module enhances the representations of both streams through inter-stream information exchange. Specifically, the spatial features of the secondary stream (LSKSE output) are fused with the spatiotemporal representation of the primary stream to strengthen the primary features; conversely, the spatial features of the primary stream are fed back and fused with the spatiotemporal representation of the secondary stream. This bidirectional design facilitates multi-view, multi-scale dependency modeling, capturing richer spatiotemporal patterns, thereby improving generalization ability and robustness. Spatial information in the secondary features is used to enhance the spatial and temporal information of the primary features.
[0194]
[0195] Where: Y a The spatial information output by the large selective kernel spatial extractor in the secondary feature extraction module; X p The main feature information output by the spatiotemporal feature fusion of the main feature extraction module; W l p A linear transformation embedded at the central node; A linear transformation of the domain-aggregated message; N a The domain of the central node; The output of the main feature extraction module; The secondary feature flow spatial information Y is introduced into the primary feature flow at layer l. a Then, the enhanced intermediate feature representation is obtained by domain normalization aggregation, linear transformation and nonlinear mapping.
[0196] For secondary feature streams, the enhanced features for:
[0197]
[0198] Where: Y p Spatial information output by the large selective kernel spatial extractor in the main feature extraction module; X a The main feature information output after spatiotemporal feature fusion of the secondary feature module; W l aA linear transformation embedded in the central node; A linear transformation of the domain-aggregated message; M p The domain of the central node; This is the output of the secondary feature extraction module; The enhanced intermediate feature representation is obtained by introducing the spatial information of the main feature flow into the l-th level feature flow through neighborhood aggregation, linear transformation and nonlinear mapping.
[0199] 1.2.4 Spatiotemporal Fusion Adjacency Matrix
[0200] In existing technologies, the adjacency matrix input to conventional spatiotemporal models is a spatial adjacency matrix constructed based on Euclidean distance and simple spatial locations. The adjacency matrix corresponding to a spatial location is defined as follows:
[0201]
[0202] Where: d i,j The distance between each measuring point is the Euclidean distance. The variance is used. To encode richer spatiotemporal structures, temporal adjacency is introduced and fused with spatial adjacency constructed using Euclidean distance. Temporal information is crucial for thermal error dynamics, and the core task is to measure the similarity between two time series data. Simple Euclidean distance is often insufficient; two series may have similar shapes but be temporally misaligned. Direct distortion of the original values can also introduce singularities (a point mapping to a segment). To address this, DDTW is employed. DDTW aligns the sequences by comparing local slopes rather than the original amplitudes, thereby mitigating singularities. The two time series data are:
[0203] X i = [x1,x2,…,x i ],X j = [x1,x2,…,x j ]
[0204] Its first derivative is calculated as follows:
[0205] X ′i =[x1 ′ x2 ′ ,…,x i ′ ],x i ′ =x i -x i-1 ,X ′j =[x1 ′ ,x ′ ′ ,…,x j ′ ],x j ′ =x j -xj-1
[0206] Based on the definition of the distance matrix, the following relationship is obtained:
[0207] D(i,j)=ω1·|x i -x j |+ω2·|x i ′ -x j ′ |
[0208] Where ω1 and ω2 are weight coefficients. Therefore, the temporal similarity adjacency matrix can be expressed as:
[0209]
[0210] The spatiotemporal fusion adjacency matrix is constructed in three steps: First, a temporal adjacency matrix is built using DDTW, and a spatial adjacency matrix is constructed based on Euclidean distance; second, the Pearson correlation coefficient between the two adjacency matrices is calculated, and a weight reflecting their consistency is derived accordingly; finally, the two adjacencies are weighted and averaged according to this weight to obtain the fused spatiotemporal adjacency matrix. In practice, the fused matrix can be normalized and sparsified to improve stability and efficiency, but the core process follows the above order. Specifically, the construction of the spatiotemporal fusion adjacency matrix can be expressed as:
[0211]
[0212] Where: r i,j X is the correlation coefficient; i and X j Used to measure linear correlation; ω h ω s and ω t These are non-negative weighting coefficients.
[0213] The fused spatiotemporal adjacency is a convex combination of Euclidean and DDTW affinity. Its symmetric normalized S... t The expression is non-negative and its spectrum lies within [0,1]. Therefore, a single-layer graphical neural network (GNN) with a Lipschitz activation function is non-expanding, ensuring stable propagation across the window. This is demonstrated by proving that multi-scale aggregation approximates S... t The truncated thermonuclear filter formalizes the relationship between LSKSE and diffusion. To alleviate collinearity in the temperature sensor, a dual-flow gate is used via γ... t Scaling secondary features.
[0214] 2. Spindle thermal error compensation system based on dual-stream spatiotemporal fusion
[0215] To improve the efficiency and accuracy of thermal error prediction and compensation, this embodiment establishes a DT system based on the STG-AFN model. This framework comprises four layers: a physical layer, a human-computer interaction (HMI) layer, a digital space layer, and a controller layer. The overall architecture is as follows: Figure 5 As shown, the STG-AFN prediction results are transmitted to the CNC system. The compensation value is calculated in the CNC system and applied to the machine tool to achieve automatic thermal error compensation. In the physical layer, temperature and displacement sensors are used to collect thermal information data. Other devices collect additional data from the machine tool. The HMI layer visualizes the prediction results, compensation values, and machine tool status. The digital space layer stores the input thermal information data and integrates and organizes the data to form a dataset for modeling and evaluation. The controller performs thermal error compensation in real time. The close interaction between these layers ensures the accuracy and real-time performance of thermal error compensation.
[0216] Specifically, this embodiment is a spindle thermal error compensation system based on dual-stream spatiotemporal fusion, including a thermal error prediction model, a physical layer, edge computing nodes, a digital space layer, a controller layer, and a human-machine interaction layer. The thermal error prediction model operates according to the spindle thermal error prediction method based on dual-stream spatiotemporal fusion described in Part 1 of this embodiment. The physical layer includes multiple temperature sensors and at least one displacement sensor arranged on the machine tool spindle, as well as a data acquisition and preprocessing unit for synchronously acquiring temperature and thermal error signals and performing analog-to-digital conversion and filtering. The edge computing node deploys the thermal error prediction model, receives real-time data preprocessed by the physical layer through an industrial network, performs thermal error prediction, and generates compensation instructions. The digital space layer includes a cloud training platform and a local data platform. The cloud training platform is used to train and update the dual-stream spatiotemporal graph attention fusion network model using historical data, and the local data platform is used to store and manage real-time and historical data. The controller layer includes a programmable logic controller (PLC) and a computer numerical control (CNC) system. The PLC receives compensation instructions from the edge computing node, and the CNC system applies the compensation instructions in the current position control loop to achieve real-time closed-loop compensation. The human-machine interface provides a visual interface to display spindle temperature distribution, thermal error prediction curve, compensation command value, key real-time performance indicators of the system, and machine tool operating status.
[0217] 2.1 Real-time Design Objectives and Constraints
[0218] Let the CNC interpolation period be T. s(e.g., 2-4 milliseconds). The end-to-end (E2E) pipeline for each control cycle consists of five parts: (1) Sensing and PLC preprocessing S performs analog-to-digital (A / D) conversion, noise reduction, and timestamp marking. (2) Edge transfer process X performs data transfer from the PLC to the edge input / output (I / O). (3) Inference process I performs STG-AFN forward calculation on the latest window. (4) Write-back process W performs data transfer from the edge to the PLC / CNC and writes the thermal error compensation value to the PLC. (5) Execution A performs the position loop application. The system has budgeted for worst-case E2E delays.
[0219] In this embodiment, the programmable logic controller (PLC) bases its operation on the predicted thermal error value. Generate compensation instruction u t The machine tool CNC system has an interpolation cycle T. s Within, the compensation command u t The position controller is written to perform thermal error compensation; the end-to-end delay L within the interpolation period satisfies the deterministic real-time constraint L. max ≤T s and jitter constraint J≤J budget ,and:
[0220]
[0221] L∈E2E delay of periodic measurements
[0222] in: The time t for sensor and PLC preprocessing S Maximum allowed value; The time t for PLC to edge transmission X Maximum allowed value; The time t for edge reasoning I Maximum allowed value; The time t for edge-to-PLC / CNC write-back W Maximum allowed value; The execution time t for the position loop A Maximum allowed value; L max The maximum allowable delay; J budget This is the maximum allowable budget value for end-to-end delay jitter, used to constrain the statistical fluctuation range of the end-to-end delay within consecutive interpolation periods.
[0223] Determinism is ensured through fixed windowing (length W), thread binding, and priority scheduling (inference has the highest real-time priority on the edge core).
[0224] 2.2 System Framework
[0225] (1) Physical layer
[0226] The physical layer is the foundation of the digital twin system. It is designed to sense, acquire, and transmit spindle operation data. This data is forwarded to the upper-layer Digital Twin Data Platform (DTDP) as input to the Thermal Error Prediction (TEP) and Thermal Error Compensation (TEC) models. This layer comprises two main units. The sensing and acquisition unit includes temperature sensors, displacement sensors, and devices for recording spindle operation parameters. The data acquisition and processing unit performs preprocessing such as A / D conversion and filtering to reduce the upstream computational load. After preprocessing, the data is sent to routing nodes and subsequently written to the DTDP database. As the data backbone of the compensation system, the physical layer supports the real-time operation and prediction accuracy of thermal error compensation.
[0227] (2) Human-computer interaction layer
[0228] The HMI layer provides users with an interface to access the digital twin system. System data is visualized on the user interface (UI), including indicators such as spindle speed, temperature distribution, and load. TEP results and TEC evaluation charts are also presented.
[0229] (3) Digital Space Layer
[0230] The digital space layer is the core virtual computing environment of the digital twin system. It builds, predicts, and optimizes the TEP model. Employing an edge-cloud collaborative framework, the edge platform is deployed on local devices. Real-time sensor data is transmitted to edge nodes via industrial Ethernet or Wi-Fi. Temperature and displacement signals are preprocessed synchronously, and then thermal errors are predicted using the STG-AFN model. Based on the prediction results, correction instructions are calculated and sent to the CNC system. The cloud platform runs in the industrial cloud, serving as the central hub for model training and optimization. STG-AFN parameters are fine-tuned using historical prediction data; this platform provides powerful computing and storage capabilities. Simultaneously, a high-fidelity virtual machine bed model is maintained, ensuring its structural and thermodynamic properties remain correlated with the physical system. The spatiotemporal characteristics of thermal errors are captured to form a reusable knowledge base. Compensation strategies are validated in the virtual environment before deployment, thereby reducing the cost of physical experiments.
[0231] In a digital twin system, a low-latency link must be established between the edge node and the machine tool to ensure real-time compensation, such as... Figure 6As shown, field data is collected via temperature and displacement sensors, and the signals first enter the PLC for preliminary processing. The PLC performs A / D conversion and basic filtering to generate digital streams, which are then forwarded to edge computing devices. Thermal error prediction and local compensation are performed at the edge to ensure timeliness and accuracy. The calculated TEC value is sent from the edge node to the PLC terminal of the CNC system, and the compensation value is written to the position controller and applied to each axis to complete the compensation. The processed data can drive local automatic control, while the same data is uploaded to the cloud for centralized storage and optimization. In this way, the collaboration between real-time field control and remote intelligent management is achieved.
[0232] 2.3 Edge Model Embedding
[0233] (1) Dual-stream collinear sensing feature flow
[0234] make Let the temperature be t. Divide the node index into primary P (TSPs) and secondary S (non-TSPs), P∪S={1,…,N}, P∩S=Φ, thus forming a data stream.
[0235]
[0236] Using temperature covariance ∑ t =Cov(X) t-W+1:t Define the flow collinearity index:
[0237]
[0238] If κ t >κ th Then the secondary streams pass through during fusion. Attenuation is performed. Where: λ max and λ min The temperature covariance matrix ∑ t The largest and smallest eigenvalues; κ th The threshold parameter for the streamlining index is used to determine whether the temperature evolution within the current time window exhibits significant anisotropy or anomalously concentrated changes.
[0239] (2) Spatiotemporal fusion adjacency (adaptive graph)
[0240] Spatiotemporal fusion adjacency (adaptive graph) is determined by Euclidean distance d i,j generate Time Adjacency A t The distance from DDTW within the latest time window ij generate Data-driven fusion weights α t ρ is generated based on Pearson consistency. t =corr(vecAspa ,vecA tmp ), and thus obtain
[0241]
[0242] Then, row randomization is performed: Where: D l I is the degree matrix; I is the identity matrix.
[0243] (3) Synchronous spatiotemporal coding and interactive dual-stream fusion
[0244] For each flow q∈{P,S}, MSAGTU generates temporal features. LSKSE Generative Spatial Features Fusion is achieved using spatiotemporal convolution:
[0245]
[0246] Cross-current enhancement (secondary to primary) achieved through cross-attention is as follows:
[0247]
[0248] Symmetrical feedback (primary to secondary) is achieved to obtain Both paths apply residual connectivity and layer normalization.
[0249] 2.4 Arbitrary Time Compensation Based on Uncertainty Gating
[0250] Let t ddl =T s Let t be the deadline for each period. ddl , If the previous step is completed, the result will be applied; otherwise, a rollback mechanism will be activated, with the rollback compensation value being:
[0251]
[0252] in: It is at a strict boundary Low-order observers obtained through internal computation (e.g., linear mapping of TSP temperature).
[0253] Maintain a residual The rolling calibration set. Let q α The threshold compensation range is given by the empirical 1-α quantile:
[0254]
[0255] Where λ is the adjustable safety gain, and ε>0.
[0256] The safety constraints are as follows:
[0257]
[0258] Otherwise, it will trigger graceful degradation (observer only) or severance.
[0259] 2.1.5 Online graph refresh with limited overhead
[0260] Every R cycles (e.g., R = 10), ρ is recalculated. t And update α using downsampling DDTW or slope-based proxy. t and
[0261]
[0262] The maximum refresh cost is:
[0263]
[0264] like If the limit is exceeded, the event will be postponed to the next time slot.
[0265] The model hot switching is achieved by maintaining A / B dual model channels on the edge computing node and seamlessly switching the quantized model weights during the compensation process. The additional latency introduced by the switching is incorporated into real-time budget management.
[0266] 3. Data collection and TSP screening and verification
[0267] 3.1 Data Acquisition
[0268] The experiment employed a temperature-displacement synchronous acquisition system built on the NISCXI-1600 platform. For example... Figure 7 As shown, the system records thermal information and synchronously acquires thermal data. Since spindle thermal error is mainly driven by temperature changes, prediction is made by monitoring the spindle temperature. The sensor arrangement on the spindle follows three principles: First, the measurement points are as close as possible to the main heat source, because thermal error is mainly caused by temperature rise; second, multiple sensors are avoided at the same heat source to reduce collinearity between temperature variables; third, the sensor installation must not interfere with spindle operation to ensure normal system function.
[0269] Two datasets were collected as training and testing sets to evaluate the accuracy and robustness of the proposed STG-AFN. Three operating conditions were considered, each with different speed curves. Figure 8 The temperature trajectories are also different. Figure 9 Therefore, both speed and temperature change during operation. Figure 10A representative small sample segment is shown. The acquisition time for conditions 1 and 2 is 500 minutes: thermal data for condition 1 is sampled every 7.5 seconds, resulting in 4000 records; thermal data for condition 2 is sampled every 15 seconds, resulting in 2000 records. Each record contains nine temperature channels and one thermal error channel.
[0270] 3.2 Selection and Verification of Temperature Sensitive Points
[0271] Properly arranging temperature sensors is crucial for accurately monitoring the machine tool temperature field and improving thermal error prediction. The temperature field is complex, exhibiting nonlinear, time-varying, and strongly coupled characteristics. Therefore, multiple sensors are typically installed to track its dynamic changes, but this can lead to collinearity issues among temperature measurements. Collinearity refers to a linear dependency between predictor variables, which weakens the robustness and stability of the model and reduces prediction accuracy. Due to the strong coupling between temperature sensors, collinearity is prone to occur in the spindle thermal error model, thus affecting accuracy. To mitigate this problem, the temperature-sensitive points that have the most significant impact on thermal error should be identified as the primary inputs. Simultaneously, to avoid losing useful information when the number of primary inputs is limited, the remaining sensors are retained as secondary features. This two-layer design retains key information while reducing the negative impact of collinearity.
[0272] To identify temperature-sensitive points, a five-fold cross-validation combined with recursive feature elimination was employed. First, the thermal data was preprocessed: a percentile filter was applied to remove outliers in the temperature channels, and a low-pass filter based on Fast Fourier Transform (FFT) smoothed the thermal error quality index. Then, the dataset containing nine temperature features and one thermal error target was divided into five folds. In each fold iteration, four folds were used for training, and one fold for validation. During the training phase, the recursive feature elimination method iteratively eliminated the temperature sensors that contributed the least to thermal error prediction, performing six rounds of elimination. After ranking the features from each fold, the six sensors with the highest retention frequency were selected as temperature-sensitive points, serving as the primary input to the proposed model. The remaining three sensors were retained as secondary features to avoid losing auxiliary information. Temperature-sensitive and non-sensitive points are listed in Tables 1 and 2, respectively.
[0273] Table 1. Distribution of Temperature Sensitive Points
[0274]
[0275] Table 2 Distribution of non-sensitive temperature points
[0276]
[0277] 3.2.1 Model Parameters and Adjacency Matrix
[0278] To evaluate the performance of the STG-AFN model and the effect of splitting the temperature input into primary and secondary features, thermal information was used as input. Data from Condition 1 was used as the training set, and data from Condition 2 was used as the test set. The model hyperparameters are listed in Table 3. The model uses 10 time windows and 9 nodes, with a batch size of 32. The temporal branches use dilated convolutional kernels of sizes [3,5,7], a learning rate of 0.001, and the optimizer is Adam. The network depth is 2 layers, providing sufficient capacity for spatiotemporal patterns while maintaining efficiency. This configuration supports stable training and competitive performance on complex data. The spatial adjacency matrix is constructed from measured sensor locations, such as... Figure 11 As shown in (a), the temperature signal is correlated with displacement, and the correlation strength depends on location. Therefore, nodes in neighboring locations are highly correlated rather than independent. The time similarity matrix is as follows. Figure 11 As shown in (b), the relationships between strong nodes are dynamically adjusted to capture the local temporal structure.
[0279] Table 3 Hyperparameter values
[0280]
[0281] 3.2.2 Verification of collinearity at temperature points
[0282] Existing research indicates that collinearity exists among temperature sensors, which reduces the stability, robustness, and accuracy of the model. Therefore, many works, after noting collinearity, reduce the input of all measurement sensors to only temperature-sensitive points. In contrast, the model proposed in this embodiment retains both temperature-sensitive and non-sensitive sensors, routing them as primary and secondary features, respectively. This design alleviates collinearity while maintaining feature integrity. Six temperature-sensitive points serve as primary inputs, and three non-sensitive sensors serve as secondary inputs. Three configurations were compared: (1) Method 1 is a thermal error model with all nine temperature sensors as inputs. (2) Method 2 is a thermal error model with only six temperature-sensitive points as inputs. (3) Method 3 is a thermal error model with six temperature-sensitive points as primary inputs and the remaining three non-temperature-sensitive points as secondary inputs. Model performance was evaluated using mean absolute error (MAE), mean square error (MSE), root mean square error (RMSE), and η. Lower MAE, MSE, and RMSE indicate better prediction performance, and higher η indicates higher prediction accuracy. The definitions of MAE, MSE, RMSE, and η follow the standard formula for accuracy evaluation.
[0283] Let y t To account for measured thermal error, These are the model predictions. Prediction error is evaluated using MAE and RMSE. Prediction accuracy η is expressed in normalized MAE form:
[0284]
[0285] according to Figure 12 According to Table 4, Method 3 achieved the best performance. Method 2 was second best and outperformed Method 1. Therefore, using all nine temperature sensors resulted in lower accuracy than using only six temperature-sensitive points. This indicates that collinearity among the sensors reduces prediction accuracy. Furthermore, adding three non-temperature-sensitive points as secondary features to the six temperature-sensitive points further improved accuracy compared to using temperature-sensitive points alone. This demonstrates that secondary features both avoid harmful collinearity among temperature-sensitive points and provide complementary information to enhance model performance.
[0286] Table 4. Predictive performance evaluation of different data input methods under the second operating condition.
[0287]
[0288] 4. Experimental verification
[0289] To demonstrate the superiority of STG-AFN, model comparison, cross-validation, ablation studies, and compensation experiments were conducted. TEP used six temperature sensors as primary inputs and three sensors as secondary inputs.
[0290] 4.1 Comparative Experiment
[0291] To rigorously evaluate STG-AFN, a set of baseline models was selected for comparison, including LSSVM, LSTM, TCN, GMAN, STGCN, and STGHTN. These models cover traditional machine learning, pure temporal prediction, and spatiotemporal prediction methods. Specifically, LSSVM represents the traditional method; LSTM and TCN represent temporal models; and STGHTN, GMAN, and STGCN represent spatiotemporal models. To ensure fair comparison, the principle of controlling variables was followed. All baseline models used the same hyperparameters, training data, and testing data as STG-AFN. Temperature and thermal error data from Condition 1 were used for training, and data from Condition 2 were used for testing. Performance was evaluated using MAE, MSE, RMSE, and η. Lower MAE, MSE, and RMSE indicate better performance, and higher η indicates higher accuracy. The results for each model are summarized in Table 5. The proposed STG-AFN model outperformed all baselines, achieving the lowest MAE, MSE, and RMSE, with a prediction accuracy of 98.64%. The performance ranking is as follows: STGHTN, GMAN, STGCN, TCN, LSTM, and LSSVM. This order aligns with the characteristics of thermal information data: it possesses both temporal and spatial structures. LSSVM lacks a modeling mechanism for both, thus performing the worst. LSTM and TCN can capture local temporal patterns, thus outperforming LSSVM, but still lagging behind spatiotemporal models. STGCN combines graph convolution and temporal convolution to model spatial dependencies and temporal dynamics; this joint modeling is beneficial for thermally driven processes. GMAN further employs multi-head attention adaptive weighting of nodes and time steps to more flexibly capture complex dependencies. STGHTN uses MSA to capture spatial features and employs a spatiotemporal fusion structure to aggregate spatiotemporal features of different granularities. Even so, both are surpassed by STG-AFN. STG-AFN's advantage lies in its more comprehensive handling of spatiotemporal interactions and feature organization: MSAGTU is used to extract multi-scale temporal patterns and captures both local fluctuations and long-term trends through lightweight channel attention reweighting; LSKSE provides a dynamic spatial receptive field and improves the representation of inter-node dependencies through spatiotemporal fusion adjacency operations. Furthermore, the input is divided into primary features (TSPs) and secondary features (non-TSPs), mitigating collinearity while preserving auxiliary information. Subsequently, a two-stream fusion mechanism aggregates and cross-enhances the spatiotemporal representations of the two streams. Therefore, STG-AFN captures richer spatiotemporal interactions than STGCN's essentially serial spatiotemporal flow and GMAN's lack of explicit two-stream interaction or input partitioning attention mechanisms. Although the STGHTN model also uses MSA and a spatiotemporal fusion structure, it cannot capture temporal information at different scales when extracting spatiotemporal features, and the method used in its spatiotemporal fusion layer cannot fully aggregate spatiotemporal features compared to STG-AFN's two-stream feature fusion structure; therefore, its performance is still weaker than STG-AFN. Figure 13These advantages are demonstrated, showing that its accuracy is higher than that of models with only temporal features or incomplete spatiotemporal coupling.
[0292] In summary, STG-AFN outperforms the baseline model in prediction accuracy and all error metrics (MAE, RMSE, MSE, and η). Although both are spatiotemporal models, it dynamically captures information and represents thermal data more comprehensively, thus exhibiting a significant advantage even compared to STGCN and GMAN. To further illustrate its predictive capabilities, the residual plot was examined. The prediction residual is the difference between the measured thermal error and the model output; the residual for condition 2 is shown below. Figure 14 As shown, the magnitude and distribution of the error are visually illustrated. Figure 14 In (a), the residuals of STG-AFN are significantly lower than those of LSSVM, LSTM, and TCN. Although there are slight fluctuations, they approach zero and stabilize over time. Figure 14 In (b), STGCN, GMAN, and STGHTN all stabilize near zero after fluctuations, but STG-AFN exhibits smaller residual amplitudes. Overall, these results indicate that STG-AFN demonstrates higher accuracy and stronger stability compared to the baseline model.
[0293] Table 5 Predictive performance evaluation under the second operating condition
[0294]
[0295] 4.2 Cross-validation
[0296] Cross-validation was performed to assess reliability, stability, and generalization ability in real-world scenarios. In the previous evaluation, thermal data from operating condition 1 was used as the training set, and thermal data from operating condition 2 was used as the test set. For cross-validation, the roles were reversed: thermal data from operating condition 2 was used for training, and thermal data from operating condition 1 was used for testing. The prediction results are as follows: Figure 15 As shown. Prediction performance in Figure 16As evaluated in Table 6, STG-AFN achieved the highest accuracy. This model maintains strong predictive power on operating condition 1 and outperforms LSSVM, LSTM, and TCN. LSSVM cannot extract spatial or temporal features, explaining its weaker performance. LSTM and TCN can capture temporal patterns but lack spatial modeling capabilities, thus remaining less suitable as spatiotemporal methods under this condition. STGCN, GMAN, and STGHTN are spatiotemporal models, but their performance is inferior to STG-AFN. They do not classify temperature nodes at input. In contrast, STG-AFN distinguishes between TSP and non-TSP as primary and secondary features, reducing collinearity among temperature nodes and preserving complementary information. The proposed STG-AFN model's superior predictive performance further demonstrates the effectiveness of the proposed design. Therefore, based on Table 6, STG-AFN maintains a significant advantage under cross-validation, maintaining high predictive accuracy and demonstrating strong generalization ability for thermal error prediction across different operating conditions. This model also adapts well to small sample datasets and exhibits strong robustness.
[0297] Table 6 Predictive Performance Evaluation under the First Operating Condition
[0298]
[0299] 4.3 Ablation Test
[0300] To evaluate the contribution of each component, ablation studies were conducted by sequentially removing LSKSE, the interaction fusion layer, and MSAGTU, resulting in STG-AFN1, STG-AFN2, and STG-AFN3, respectively. Results (Table 7 and...) Figure 17 All three models performed worse than the complete model, indicating that optimal performance is only achieved when all modules work together. MSAGTU integrates multi-scale temporal convolutions and reweights concatenated features through channel attention, thereby enhancing temporal pattern learning and selection. The interactive fusion layer performs two-stream aggregation, enhancing the primary features with secondary spatial cues and feeding the primary spatial information back to the secondary stream, which improves global dependency capture. LSKSE is used to extract spatial features with dynamically adjustable receptive fields and supports the construction of spatiotemporal fusion adjacency relationships, which is crucial for accurate spatial encoding. Numerically, removing LSKSE from the STG-AFN model (STG-AFN1) reduced the accuracy to 96.97%; removing the interactive fusion layer (STG-AFN2) improved the prediction accuracy to 97.66%; and removing MSAGTU (STG-AFN3) improved the prediction accuracy to 96.14%, the lowest value in the ablation experiments. Other error metrics (MAE, MSE, RMSE) also deteriorated compared to STG-AFN. These results confirm that MSAGTU, the interactive fusion layer, and LSKSE all make significant contributions to prediction accuracy, and their integration in STG-AFN achieves the strongest overall performance in the TEP task.
[0301] 4.4 System Real-Time Performance Verification
[0302] Each control cycle comprises five timing phases: sensing and PLC preprocessing (S); PLC to edge transmission (X); edge inference (I); edge to PLC / CNC write-back (W); and execution in the position loop (A). The end-to-end delay is:
[0303] L = t S +t X +t I +t W +t A
[0304] Jitter is defined as If L max ≤T S If the deadline is missed, the cycle is considered to be missed. The edge clock is synchronized with the PLC clock via Precision Time Protocol / Network Time Protocol (PTP / NTP) and the offset is measured. Deterministic feasibility requirement L max ≤T S and J≤J budget The phase budget is set as follows: L max ≤T s The jitter budget is J. budget = 0.10ms. Determinism is guaranteed through fixed windowing, thread binding, and priority scheduling on the edge core.
[0305] Key performance indicators (KPIs) were recorded under C1-C3 and stress conditions: (1) CPU load was injected at 50% and 80% edge utilization, (2) I / O jitter was injected on PLC→edge transfer, (3) the graph was refreshed online every R=10 cycles, and (4) model weights were hot-switched via A / B channels during real-time compensation. Each scenario was run for at least 10 cycles. 6 The period is used to characterize the tail of P99.9. Closed-loop stability is achieved by injecting a delay δ∈{0,0.25T} into the inference phase. s 0.5T s The thermal error transients during the C3 ramp were observed for verification. Overshoot and settling time were recorded, and persistent oscillations were checked. Table 8 reports end-to-end delay statistics, jitter, deadline misses, and on-the-fly activation rates. Table 8 shows that the end-to-end delay remains constant throughout the interpolation period T in all scenarios. s = Below 2.00ms. Under nominal conditions (C1-C3), the median is 1.12-1.22 milliseconds, while L P99.9The latency is 1.42–1.55 milliseconds. Worst-case latency remains within 1.60–1.68 milliseconds. Jitter is minimal (0.07–0.09 milliseconds). No deadline misses were observed. Activation at any time is rare (0.10–0.18%). Under stress, the latency tail increases but remains manageable. At 50% CPU load, L… P99.9 Increased to 1.65ms, L max Up to 1.83 milliseconds. At 80% CPU load, the worst-case time reached 1.95 milliseconds, still below T. s The error rate remained at 7×10 -4 %. The percentage of always-on activations increased to 0.62%, indicating timely rollback rather than exceeding limits. I / O jitter produces a similar pattern: L P99.9 =1.72ms,L max =1.90ms, jitter 0.11ms, and extremely low error rate (0.0003%). Maintenance overhead is limited. Online map refresh behavior is almost identical to baseline behavior ((L P99.9 =1.52ms; L max = 1.66ms; Any-time 0.17%. Hot switching introduces a transient tail (L). P99.9 =1.76ms; L max =1.92ms), negligible errors (0.0002%), and moderate activity (0.42%). Overall, deterministic real-time constraints were met. Latency, jitter, and reliability remained within budget under all operating and stress conditions.
[0306] Table 8 Real-time KPIs for Each Scenario
[0307]
[0308] 4.5 Compensation Experiment
[0309] This embodiment evaluates whether the proposed digital twin-based, edge-deployed STG-AFN system (DT-STG-AFN) can: (i) reduce spindle thermal errors during machining, (ii) improve part accuracy relative to uncompensated and statically mapped references, and (iii) maintain stability and robustness under varying operating conditions and sensor disturbances. All experiments were conducted on a TGK46100 horizontal boring and milling machine equipped with a Siemens 840Dsl control system. The interpolation cycle was T. s= <2-4> milliseconds. Nine temperature channels were configured (six temperature-sensitive points as primary points and three non-sensitive points as secondary points), and a displacement probe was used for thermal error measurement. The PLC performed A / D conversion of the temperature signal, range limiting, percentile denoising, and FFT low-pass filtering on the thermal error quality index. Timestamps were synchronized, and data packets were forwarded to edge devices. STG-AFN used a time window W=10, MSAGTU core size of [3,5,7], network depth of 2, optimizer Adam, and learning rate of 10. -3 Spatiotemporal fusion adjacency is achieved through Pearson weighted fusion, combining Euclidean spatial proximity with DDTW-based temporal similarity. Compensation instruction u t Write the CNC position ring in each cycle. Maintain the ambient temperature at 20±2℃. Preheat for 60 minutes before each test.
[0310] By comparing the machining errors under the current model compensation, other model compensations, and without thermal error compensation, the effectiveness of the proposed modeling and compensation method is fully demonstrated. Subsequently, the carbon steel workpiece was machined. Special attention was paid to the roundness error of the two cylindrical surfaces, as they have a significant impact on assembly quality. Figure 18 As shown. The TGK46100 machine tool was run from a cold state until all workpieces were machined. After machining, the workpieces were placed at room temperature (20°C) for eight hours to eliminate environmental influences, and then their roundness error was measured using a coordinate measuring machine.
[0311] Three representative work cycles were tested: C1 (low-speed preheating, <3000 rpm, 500 minutes>), C2 (rated cutting, <4000 rpm, 1000 minutes>), and C3 (rated cutting, <8000 rpm, 800 minutes>). Four groups were compared under each condition: G0 uncompensated (open loop), G1 static mapping (polynomial / lookup table for temperature), and G2 model only (STG-AFN prediction). However, thermal error compensation is not applied), as is G3DT-STG-AFN (the proposed method, online thermal error compensation). Each group is run repeatedly R=5 times. The compensation effect relative to the baseline b∈{G0,G1} under operating condition c is:
[0312]
[0313] The accuracy of parts is assessed by machining standard samples (such as ring gauges / pitch gauges). This represents the part deviation for feature k under group g. The improvement relative to reference b is:
[0314]
[0315] The control loop is divided into sensing (S), transmission (X), inference (I), write-back (W), and execution (A). Under the fixed priority scheduling of the edge core, the inference response time R... I The fixed priority response time analysis (FP-RTA) recursive relationship is satisfied. Combined with the worst-case execution time (WCET) bounds of the STG-AFN forward propagation, the end-to-end worst-case delay follows L. max ≤T s If a momentary timeout is detected, a rollback mechanism ensures safety at any point in time.
[0316] After warm-up and sensor health checks, the model is trained and quantized to half-precision floating-point / 8-bit integer (FP16 / INT8) for edge deployment. For each condition c, four groups are executed in random order to avoid drift bias. The thermal error y of the measurements is recorded. t Predicted values Compensation value u t All real-time key performance indicators were included. Each configuration was repeated R times. Results are reported as the mean ± standard deviation of repeated experiments. Paired comparisons (G3 vs. G0, G3 vs. G1) were performed using paired t-tests (or Wilcoxon signed-rank tests if not normally distributed) and were Bonferroni corrected. Confidence intervals (95%) were obtained using a bootstrap method with 10,000 resampling iterations. Table 9 summarizes the compensation results for the three settings under three operating conditions (C1-C3): static mapped baseline (G1), open-loop STG-AFN with only the model (G2), and the proposed DT-STG-AFN closed-loop system (G3). Under all conditions, G3 achieved the lowest errors—MAE = 0.02875–0.03213 μm, RMSE = 0.4852–0.4995 μm, MSE = 0.2345–0.2495 μm—and the highest prediction accuracy η = 98.03%–98.96%. Compared to static mapping (G1), G3 reduced RMSE by 89.61% (C1), 89.79% (C2), and 89.97% (C3), indicating that online compensation using adaptive spatiotemporal modeling is far more effective than fixed-temperature error mapping. Compared to the open-loop model (G2), G3 further reduced RMSE by 12.19% (C1), 14.76% (C2), and 14.31% (C3), demonstrating that closed-loop design (prediction → compensation write-back) can continuously reduce residuals further. In contrast, static mapping exhibited a larger error (RMSE = 4.7543-4.9825 μm, η≈84%), reflecting its limited adaptability to time-varying nonlinear heat transfer mechanisms.
[0317] Under all three operating conditions, the compensated ΔGE was significantly improved. The static mapping baseline results were ΔGE = 62.15% (C1), 61.38% (C2), and 62.33% (C3). Only the STG-AFN (open loop) model produced ΔGE = 23.15% (C1), 22.17% (C2), and 23.29% (C3). Therefore, static mapping brings an average improvement of approximately 2.7× in part accuracy, higher than the open loop model (mean 61.95% vs. 22.87%; ratio ≈ 2.71). Both methods showed small fluctuations (range ≈ 1%) under different conditions, indicating that the part-level benefits remain stable across mechanisms. This trend is consistent with thermal error residuals. Static mapping eliminates a large number of low-frequency drift components through closed-loop control, resulting in a higher ΔGE than the open loop model. The proposed DT-STG-AFN achieved the lowest RMSE in all groups under all conditions. Therefore, its ΔGE is expected to exceed the value of the aforementioned static mapping, although the specific value depends on the workpiece geometry and the sensitivity of thermal error to geometric error. Reporting the ΔGE and confidence intervals for DT-STG-AFN will refine the comparison and quantify the part quality margin obtained through real-time adaptive compensation. ER c,Gl Not applicable to G3, as it is used as a comparison benchmark.
[0318] Table 9 Thermal error and component accuracy for each group under operating condition C1
[0319]
[0320] Under operating condition C2, Table 10 compares the three methods across groups G1-G3. The proposed DT-STG-AFN (G3) achieves the best overall accuracy, with MAE≈0.029-0.034 μm, RMSE≈0.498-0.502 μm, MSE≈0.248-0.252 μm, and efficiency η≈97.78-98.43%. Only the STG-AFN (G2) model performs slightly worse—MAE≈0.031-0.036 μm, RMSE≈0.572-0.595 μm, MSE≈0.334-0.354 μm, and η≈97.52-98.40%—indicating that the dynamic / migration mechanism in G3 brings substantial gains, especially in terms of RMSE / MSE. In contrast, the static model (G1) exhibits larger errors (MAE≈4.21–4.38 μm, RMSE≈4.81–5.01 μm, MSE≈23.16–25.12 μm) and significantly lower efficiency (η≈83.67–84.13%). Compared to G1 (ER) c,GI The relative error changes show that G2 (≈13-15%) only decreased moderately, while the static model increased significantly (≈89-90%).
[0321] In the three sub-scenarios, the ΔGE of the static mapping baseline was 61.28%, 62.23%, and 62.19% (mean 61.90%), respectively. Only the STG-AFN (open-loop) model produced ΔGEs of 24.17%, 23.54%, and 23.38% (mean 23.70%). Therefore, the static mapping closed-loop model improved part accuracy by approximately 2.6 × (61.90% vs. 23.70%; mean +38.20 percentage points). The variability between sub-scenarios for both methods was small, indicating stable benefits under C2. Since the proposed DT-STG-AFN achieved the lowest TE residuals (RMSE = 0.4976–0.5016 μm) in each sub-scenarios, and reduced RMSE by 89.66–89.99% relative to static mapping and 13.05–15.46% relative to the open-loop model, its ΔGE is expected to exceed that of the static mapping value (≈62%). The specific gain depends on the workpiece geometry and TE→GE sensitivity, but a monotonic improvement is expected. Reporting ΔGE of DT-STG-AFN via confidence intervals will refine the comparison and quantify the part quality margin brought about by real-time adaptive compensation.
[0322] Table 10 Temperature Error and Part Accuracy for Each Group under Operating Condition C2
[0323]
[0324]
[0325] 5. Conclusion
[0326] To address spindle thermal errors, this embodiment develops a dual-stream spatiotemporal modeling framework and a digital twin compensation loop. Non-TSP channels are retained as secondary inputs, while TSP channels are routed as primary inputs. Collinearity is mitigated through interactive fusion rather than sensor removal. Temporal information is encoded using multi-scale attention-gated units, and spatial information is encoded using a large selective kernel extractor with a dynamic receptive field. Fusion adjacency combines Euclidean proximity with DDTW-based temporal similarity. The model is deployed on an edge-PLC-CNC loop with explicit delay and jitter budgets. Lower MAE / RMSE and higher accuracy are achieved under three operating conditions. Cross-validation confirms generalization ability, and ablation experiments validate the function of each module. Real-time testing shows bounded delay and rare backoff. Closed-loop compensation outperforms static mapping and open-loop prediction. This method is practical, accurate, and real-time.
[0327] (1) Primary (TSP) and secondary (non-TSP) flows are jointly modeled. Information is exchanged through an interactive fusion layer, suppressing redundant correlations while preserving complementary cues. This design reduces residuals compared to “all-sensor” input and “TSP-only” input. The complete model achieves higher accuracy without discarding sensors.
[0328] (2) DDTW captures the temporal similarity between nodes. Data-driven weights fuse the two into a single graph for each window. This fusion tracks state transitions in propagation and diffusion, learning more reliable spatiotemporal dependencies, thereby improving prediction stability and robustness.
[0329] (3) MSAGTU extracts multi-scale temporal patterns and reweights the channels. LSKSE adapts the receptive field to spatial scale variations. Spatiotemporal convolution integrates the two domains in one stage. Removing any component degrades performance: accuracy drops to 96.97% without LSKSE; to 97.66% without interactive fusion; and to 96.14% without MSAGTU. The complete model provides the best results.
[0330] (4) The inference pipeline is budgeted in stages. End-to-end latency remains below the interpolation period, median latency is close to 1.2ms, and P under heavy load... 99.9 Still below 2.0ms. Low jitter; missed deadlines are negligible (<10). -3 %). Rollback at any time is rare (<1%). Online graph refresh and model hot-swapping introduce limited overhead and do not break deadlines.
[0331] (5) The DT-STG-AFN loop reduces RMSE by approximately 89.6-90.0% compared to the static mapping baseline under different conditions, and by an additional 12-15% compared to open-loop prediction. The accuracy is up to η≈98.96%. These gains are consistent across the three operating conditions and are supported by residual plots and robust scenarios.
[0332] Overall, the proposed framework achieves accurate thermal error prediction and periodic-level compensation while preserving complete sensing capabilities. The design addresses issues of online collinearity, non-stationary spatiotemporal coupling, and real-time constraints. Results demonstrate its strong deployment potential in industrial CNC systems and provide a foundation for multi-machine migration, uncertainty-aware control, and physics-guided regularization in future applications.
[0333] The above-described embodiments are merely preferred embodiments provided to fully illustrate the present invention, and the scope of protection of the present invention is not limited thereto. Equivalent substitutions or modifications made by those skilled in the art based on the present invention are all within the scope of protection of the present invention. The scope of protection of the present invention is defined by the claims.
Claims
1. A spindle thermal error prediction method based on dual-stream spatiotemporal fusion, characterized in that: Includes the following steps: S1: Obtain temperature data of the spindle at N temperature measurement points, where N≥2; S2: Divide the N temperature measurement points into a temperature-sensitive set P and a non-temperature-sensitive set S, where: P∪S={1,2,...,N}; the temperature data of the temperature-sensitive point set P is used as the main feature stream. The temperature data of the non-temperature-sensitive point set S is used as a secondary feature stream. S3: Transfer the main feature stream and secondary feature flow The features are input into a dual-stream spatiotemporal graph attention fusion network model, which includes a primary feature extraction module and a secondary feature extraction module with identical structures, as well as an interactive fusion module, to extract and fuse spatiotemporal features; wherein, The main feature extraction module is used to process the main feature stream. The secondary feature extraction module is used to process the secondary feature stream. The interactive fusion module is used to execute the main feature stream. With secondary feature flow The two-way information exchange and fusion between the modules enhances the representation of the main features and captures global spatiotemporal dependencies; the two-way information exchange and fusion includes at least: aggregating the spatial information extracted by the secondary feature extraction module into the spatiotemporal features of the main feature extraction module, and feeding back the spatial information extracted by the main feature extraction module into the spatiotemporal features of the secondary feature extraction module. S4: Based on the fusion output of the dual-stream spatiotemporal graph attention fusion network model, the thermal error value of the main axis is predicted.
2. The spindle thermal error prediction method based on dual-stream spatiotemporal fusion according to claim 1, characterized in that: Both the primary feature extraction module and the secondary feature extraction module include a multi-scale attention-gated temporal unit, a large-selectivity kernel spatial extractor, and a spatiotemporal convolution unit connected in sequence; wherein: The multi-scale attention-gated temporal unit is used to extract the temporal features of the input data; The high-selectivity kernel spatial extractor is used to extract spatial features of the input data and dynamically adjust the receptive field. The spatiotemporal convolutional unit is used to fuse temporal features from the multi-scale attention-gated temporal unit and spatial features from the large selective kernel spatial extractor, and performs graph convolution based on a spatiotemporal fusion adjacency matrix to output the main feature stream. and secondary feature flow The spatiotemporal characteristics of fusion.
3. The spindle thermal error prediction method based on dual-stream spatiotemporal fusion according to claim 1, characterized in that: The multi-scale attention-gated time unit performs the following operations: For the input four-dimensional tensor X t ∈R B×C×N×T One-dimensional causal convolution is performed by applying multiple gated unit (GTU) branches with different kernel sizes along the time axis, wherein the kernel size includes at least 3, 5, and 7. Each GTU branch executes the output. The following formula is used to calculate: First, convolution is performed on the time dimension to map the channels from C to 2C: X conv =Conv2d(X t )∈R B×2C×N×(T-K+1) Where: X conv B represents the convolution output; C represents the batch size; N represents the number of nodes; T represents the number of channels; and K represents the kernel size. The convolution output X conv Divide into X along the channel dimension P and X q Two parts, respectively for X P and X q The two parts apply the tanh(·) and sigmoid(·) activation functions, and the output of the gated unit (GTU) branch is obtained through element-wise product: X gtu = tanh(X p )⊙sigmoid(X q ) Where: ⊙ represents element-wise multiplication; The output of each GTU branch of the gate control unit and By splicing along the time axis, we obtain X. concat ; X is processed through an efficient channel attention module concat Perform channel reweighting to obtain the weighted feature X. att : X att =A(X concat ) Where: A is the adjacency matrix; The weighted feature X att After mapping through a fully connected layer, it is compared with the original input X. t The residues are added together and then activated by ReLU before being output: X final =RELU(X t +f(X att )) Where: X final This is the output of the multi-scale attention-gated time unit.
4. The spindle thermal error prediction method based on dual-stream spatiotemporal fusion according to claim 2, characterized in that: The highly selective nuclear space extractor performs the following operations: Based on spatial features X s =R B×C×N×T Spatial information is obtained via GCN as input: Where: A is the adjacency matrix; (in ); I is the identity matrix; It is a degree matrix; W s 0 Here, σ is the weight matrix; σ is the activation function. Pass through m deep convolutional layers with different receptive fields in sequence Obtain the multi-scale feature representation U i+1 : U0=X s , in: U is the i-th depthwise convolutional layer; i+1 This represents the feature representation output by the depthwise convolution of the i-th layer; For each scale of feature U i Through a 1×1 convolutional layer The transformation is performed to obtain the feature representation at the i-th scale: By concatenating the multi-scale features along the channel dimension, we obtain: Perform global average pooling and global max pooling, and concatenate the results to generate a spatial attention map. Where: AvgPool(·) is the global average pooling layer; MaxPool(·) is the global max pooling layer; The spatial attention map The final spatial attention weights S are obtained by processing with the Sigmoid function and the convolutional layer F(·); S=F(S i +…+S m ), Take the original input X s The spatial attention weights S are multiplied element-wise to output the enhanced spatial features Y = X. s ⊙S.
5. The spindle thermal error prediction method based on dual-stream spatiotemporal fusion according to claim 2, characterized in that: The spatiotemporal fusion adjacency matrix construction method includes: Based on the Euclidean distance d between each measuring point i,j Construct the spatial adjacency matrix A S ,in: Where: ζ is the variance; A time adjacency matrix A is constructed based on the derivative dynamic time warping similarity of temperature time series at temperature measurement points. t ,in: Where: D ij For time series X i With X j The DDTW distance between them; τ is the scale parameter; Calculate the spatial adjacency matrix A s and the time adjacency matrix A t The Pearson correlation coefficient ρ between them t : ρ t =corr(vecA spa ,more tmp ) Among them: A spa and A tmp These are the spatial adjacency matrix and the temporal adjacency matrix, respectively. Generate fusion weights based on the correlation coefficients: a t =(1+ρ t ) / 2 The two adjacency matrices are weighted and merged according to the fusion weight: Add a self-connect to the merged matrix and perform symmetric normalization: Where: D t I is the degree matrix; I is the identity matrix.
6. The spindle thermal error prediction method based on dual-stream spatiotemporal fusion according to claim 1, characterized in that: The specific fusion calculation process of the interactive fusion module is as follows: For the main feature stream, the enhanced features for: Where: Y a The spatial information output by the large selective kernel spatial extractor in the secondary feature extraction module; X p The main feature information output by the spatiotemporal feature fusion of the main feature extraction module; W l p A linear transformation embedded in the central node; A linear transformation of the domain-aggregated message; N a The domain of the central node; The output of the main feature extraction module; These are intermediate enhanced features resulting from aggregation and nonlinear mapping; For secondary feature streams, the enhanced features for: Where: Y p Spatial information output by the large selective kernel spatial extractor in the main feature extraction module; X a The main feature information output after spatiotemporal feature fusion of the secondary feature module; W l a A linear transformation embedded in the central node; A linear transformation of the domain-aggregated message; N p The domain of the central node; This is the output of the secondary feature extraction module; The enhanced intermediate feature representation is obtained by introducing the spatial information of the main feature flow into the l-th level feature flow through neighborhood aggregation, linear transformation and nonlinear mapping.
7. A spindle thermal error compensation system based on dual-stream spatiotemporal fusion, characterized in that: include: A thermal error prediction model based on the spindle thermal error prediction method based on dual-stream spatiotemporal fusion as described in any one of claims 1-6; The physical layer includes multiple temperature sensors and at least one displacement sensor arranged on the machine tool spindle, as well as a data acquisition and preprocessing unit, used to synchronously acquire temperature and thermal error signals and perform analog-to-digital conversion and filtering. The edge computing node is equipped with the thermal error prediction model. It receives real-time data preprocessed by the physical layer through the industrial network, performs thermal error prediction, and generates compensation instructions. The digital space layer includes a cloud training platform and a local data platform. The cloud training platform is used to train and update the dual-stream spatiotemporal graph attention fusion network model using historical data, and the local data platform is used to store and manage real-time and historical data. The controller layer includes a programmable logic controller (PLC) and a computer numerical control (CNC) system. The PLC is used to receive compensation instructions from the edge computing nodes, and the CNC system is used to apply the compensation instructions in the current position control loop to achieve real-time closed-loop compensation. The human-machine interface provides a visual interface to display spindle temperature distribution, thermal error prediction curve, compensation command value, key real-time performance indicators of the system, and machine tool operating status.
8. The spindle thermal error compensation system based on dual-stream spatiotemporal fusion according to claim 7, characterized in that: The programmable logic controller is based on the predicted thermal error value. Generate compensation instruction u t The machine tool CNC system has an interpolation cycle T. s Within, the compensation command u t The position controller is written to perform thermal error compensation; the end-to-end delay L within the interpolation period satisfies the deterministic real-time constraint L. max ≤T s and jitter constraint J≤J budget ,and: L∈E2E delay of periodic measurements in: The time t for sensor and PLC preprocessing S Maximum allowed value; The time t for PLC to edge transmission X Maximum allowed value; The time t for edge reasoning I Maximum allowed value; The time t for edge-to-PLC / CNC write-back W Maximum allowed value; The execution time t for the position loop A Maximum allowed value; L max The maximum allowable delay; J budget This is the maximum allowable budget value for end-to-end delay jitter, used to constrain the statistical fluctuation range of the end-to-end delay within consecutive interpolation periods.
9. The spindle thermal error compensation system based on dual-stream spatiotemporal fusion according to claim 7, characterized in that: It also includes uncertainty gating and arbitrary time-based compensation and backoff mechanisms: The uncertainty gating mechanism is based on the rolling residual set. Calculate the security gain g t : Where: q α λ is the 1-α empirical quantile of the residual; λ is the adjustable safety gain; ε>0 is a small constant; the output compensation command u t Updated to g t u t ;y k The actual thermal error observation value of the spindle obtained by the machine tool measurement system at the kth sampling time is the displacement error or equivalent displacement error of the spindle caused by thermal deformation. The predicted value of the spindle thermal error is output by the dual-stream spatiotemporal fusion prediction model at the k-th sampling time. The arbitrary time compensation and rollback mechanism applies when the single inference time exceeds the deadline t. ddl =T s When activated, the rollback compensation value is: in: It is at a strict boundary The low-order observer obtained through internal computation; β t This is the fallback fusion coefficient.
10. The spindle thermal error compensation system based on dual-stream spatiotemporal fusion according to claim 7, characterized in that: The system supports online graph refresh and hot model switching. The online graph refresh is performed once every R control cycles, and the time similarity matrix A is recalculated based on the latest temperature data. t and fusion weight α t Update the spatiotemporal fusion adjacency matrix Furthermore, the worst-case time cost of the refresh operation satisfy: The model hot switching is achieved by maintaining A / B dual model channels on the edge computing node and seamlessly switching the quantized model weights during the compensation process. The additional latency introduced by the switching is incorporated into real-time budget management.