A robot positioning prediction method, device, medium and equipment

CN120480928BActive Publication Date: 2025-09-16NORTHWESTERN POLYTECHNICAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510976548.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-16
Publication Date
2025-09-16
Estimated Expiration
2045-07-16

AI Technical Summary

Technical Problem

Existing robot forward kinematic models, such as the Denavit-Hartenberg parameter method, are unable to fully characterize nonlinear errors in actual assembly, resulting in the accumulation of absolute positioning errors to the millimeter level, which limits the realization of high-precision positioning tasks, especially the insufficient real-time response capability to nonlinear errors under dynamic conditions.

Method used

A position prediction model that combines physical-driven branches and data-driven branches is adopted. The DH parameter method is used to predict the theoretical position coordinates, and the coordinate compensation value is predicted through an improved Transformer network. The model parameters are optimized with the hybrid loss function to achieve the fusion of theoretical position and coordinate compensation value, thereby improving positioning accuracy.

Benefits of technology

The absolute positioning accuracy of the robot's end effector is improved, the physical interpretability and geometric rationality are enhanced, the limitations of a single modeling paradigm are avoided, and high-precision end point prediction is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120480928B_ABST
    Figure CN120480928B_ABST
Patent Text Reader

Abstract

The present application provides a robot positioning prediction method, device, medium and equipment, which relate to the field of industrial robot motion control. On the one hand, this method designs a physical-data dual-branch collaborative network, and uses the DH parameter method to predict the theoretical position coordinates of the target robot, and uses the improved Transformer network to predict the coordinate compensation value of the target robot, so as to decouple the theoretical value from the compensation value and avoid the limitations of a single modeling paradigm. Then, the two are integrated, and by combining the robot kinematics prior knowledge and the nonlinear expression ability of deep learning, high-precision end point prediction for the target robot is achieved. On the other hand, a spatial physical information hybrid loss function is proposed, and the spatial topological structure output by the DH model is used to guide the distribution of the predicted values ​​of the entire position prediction model to improve the geometric rationality of the target robot end point prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of industrial robot motion control, and in particular to a robot positioning prediction method, device, medium and equipment. Background Art

[0002] Forward kinematics (FK), a core branch of robotic kinematics, aims to calculate the spatial position of a robot's end effector using known joint parameters (such as angles and displacements). In related technologies, forward kinematic models for robots are often constructed using Denavit-Hartenberg (DH) parameters. This method uses the robot's geometric parameters to describe the transformation relationship between link coordinate systems, allowing theoretical end coordinates to be derived from joint angles.

[0003] However, the DH parameter method only relies on the length of the joint link, torsion angle, offset, and joint angle. The nonlinear errors in actual assembly are difficult to be fully represented by the mechanism model, resulting in the accumulation of absolute positioning errors to the millimeter level, which seriously restricts the realization of high-precision positioning tasks. Although some scholars have improved the DH parameter method and achieved the coordinated optimization of geometric errors and dynamic errors through multi-source error coupling modeling and compensation strategies, it still faces bottlenecks such as high model complexity, high computing resource consumption, and strong dependence on training data. In particular, the real-time response capability to nonlinear errors under dynamic conditions still needs to be improved. Summary of the Invention

[0004] The present application provides a robot positioning prediction method, device, medium and equipment, which can improve the absolute positioning accuracy of the end effector of an industrial robot and promote the realization of high-precision tasks such as CNC machining.

[0005] A first aspect of an embodiment of the present application provides a robot positioning prediction method, the method comprising:

[0006] Acquire multiple batches of sample data, wherein each sample data includes joint angle data and actual position coordinates of the target robot;

[0007] Constructing an initial position prediction model and initializing model parameters and hyperparameters; wherein the position prediction model includes a physical drive branch and a data drive branch;

[0008] The physical drive branch uses the DH parameter method to predict the theoretical position coordinates of the target robot based on the joint angle data;

[0009] By using the data-driven branch and an improved Transformer network, a coordinate compensation value of the target robot is predicted based on the joint angle data;

[0010] Obtaining a first predicted position coordinate of the target robot based on the theoretical position coordinate and the coordinate compensation value;

[0011] Constructing a data-driven residual term based on a geometric error between the actual position coordinates of a batch of sample data and the first predicted position coordinates;

[0012] Constructing a spatial physical information residual term based on a spatial distribution difference between the theoretical position coordinates and the first predicted position coordinates of a batch of sample data;

[0013] Constructing a hybrid loss function based on the data-driven residual term and the spatial physical information residual term;

[0014] Optimizing the initial position prediction model based on the hybrid loss function, updating the model parameters until a first preset termination condition is reached, then stopping the updating to obtain a trained position prediction model;

[0015] The current joint angle data of the target robot is input into the trained position prediction model to predict the current position coordinates of the target robot.

[0016] Based on the same inventive concept, a second aspect of an embodiment of the present application provides a robot positioning prediction device, the device comprising:

[0017] A sample acquisition module is used to acquire multiple batches of sample data, wherein each sample data includes joint angle data and actual position coordinates of the target robot;

[0018] A model building module, configured to construct an initial location prediction model and initialize model parameters and hyperparameters; wherein the location prediction model includes a physical drive branch and a data drive branch;

[0019] a theoretical coordinate determination module, configured to predict the theoretical position coordinates of the target robot using the DH parameter method based on the joint angle data through the physical drive branch;

[0020] A coordinate compensation determination module is configured to predict a coordinate compensation value of the target robot based on the joint angle data and using an improved Transformer network through the data-driven branch;

[0021] A predicted coordinate determination module, configured to obtain a first predicted position coordinate of the target robot based on the theoretical position coordinate and the coordinate compensation value;

[0022] A first loss determination module is configured to construct a data-driven residual term based on a geometric error between the actual position coordinates of a batch of sample data and the first predicted position coordinates;

[0023] a second loss determination module, configured to construct a spatial physical information residual term based on a spatial distribution difference between the theoretical position coordinates and the first predicted position coordinates of a batch of sample data;

[0024] A loss function construction module, configured to construct a hybrid loss function based on the data-driven residual term and the spatial physical information residual term;

[0025] A model training module is used to optimize the initial position prediction model based on the hybrid loss function and update the model parameters until a first preset termination condition is reached, then stop updating to obtain a trained position prediction model;

[0026] The current coordinate prediction module is used to input the current joint angle data of the target robot into the trained position prediction model to predict the current position coordinates of the target robot.

[0027] Based on the same inventive concept, the third aspect of the embodiment of the present application provides a readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements the robot positioning prediction method proposed in the first aspect of the present application.

[0028] Based on the same inventive concept, the fourth aspect of an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes, the robot positioning prediction method proposed in the first aspect of the present application is implemented.

[0029] Compared with the prior art, this application has the following advantages:

[0030] The embodiment of the present application provides a robot positioning prediction method. On the one hand, by designing a physical-data dual-branch collaborative network, that is, a position prediction model, the theoretical position coordinates of the target robot are predicted using the DH parameter method, and the coordinate compensation value of the target robot is predicted using an improved Transformer network, so as to decouple the theoretical position coordinates predicted by the DH model from the positioning error compensation driven by the Transformer, thereby avoiding the limitations of a single modeling paradigm. Then, the theoretical position coordinates and the coordinate compensation value are further integrated, and by combining the robot kinematics prior knowledge with the nonlinear expression ability of deep learning, high-precision terminal point prediction for the target robot is achieved. On the other hand, by proposing a spatial physical information hybrid loss function, the spatial topological structure output by the DH model is used to guide the distribution of the predicted values ​​of the entire position prediction model, so that the position prediction model can effectively learn the spatial information of the target robot's workspace, improve the geometric rationality of the target robot's terminal point prediction, enhance physical interpretability, and avoid the situation where the terminal positioning prediction effect is poor due to excessive errors between physical values ​​and measured values. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0032] Figure 1 This is a flow chart of a robot positioning prediction method in one embodiment of the present application;

[0033] Figure 2 Schematic diagram of the framework of the position prediction model in one embodiment of the present application;

[0034] Figure 3 is a processing flow chart of a position prediction model in one embodiment of the present application;

[0035] Figure 4 This is a schematic structural diagram of a serial six-axis industrial robot in one embodiment of the present application;

[0036] Figure 5 This is a simulation diagram of optimizing a batch of sample data using a hybrid loss function in one embodiment of the present application;

[0037] Figure 6 This is a logical framework diagram for performing reverse angle compensation in one embodiment of the present application;

[0038] Figure 7is a schematic diagram of a process for performing reverse angle compensation in one embodiment of the present application;

[0039] Figure 8 This is a schematic diagram of the functional modules of a robot positioning prediction device in one embodiment of the present application;

[0040] Figure 9 It is a structural diagram of an electronic device in one embodiment of the present application. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0042] Forward Kinematics (FK) is a core branch of robotic kinematics, aiming to calculate the position of the robot's end effector in space using the robot's known joint parameters (such as angles and displacements). In related technologies, the robot's forward kinematics model is often modeled using the Denavit-Hartenberg (DH) parameters. This method describes the transformation relationship between link coordinate systems using the robot's geometric parameters and can derive theoretical end coordinates from joint angles. However, the DH parameter method only relies on the joint link length, torsion angle, offset, and joint angle. The nonlinear errors in actual assembly are difficult to fully represent using the mechanism model, resulting in the accumulation of absolute positioning errors to the millimeter level, which seriously restricts the realization of high-precision positioning tasks.

[0043] Based on the DH parameter method, many scholars have proposed improvement plans for robot positioning errors. Some scholars believe that due to the thermal expansion effect of the robot's connecting parts, the two-dimensional positioning error of the planar robot arm will increase significantly. By accurately identifying the DH parameters, namely the connecting rod length and the rotation axis angular offset, this thermal effect can be effectively compensated, thereby significantly reducing the positioning error. Another group of scholars has made a breakthrough in integrating the DH parameter error with the axis tilt error, constructed a multi-source error coupling model for collaborative robots, and established for the first time the mapping relationship between the axis tilt joint position and the end effector error in the calibration coordinate system. To a certain extent, it solves the modeling bottleneck of the traditional non-geometric error compensation method and improves the positioning reliability in collaborative operation scenarios. Some scholars have proposed a posture-dependent DH error model, which achieves adaptive compensation of positioning accuracy by introducing a dynamic correction coefficient for the joint angle.

[0044] The aforementioned methods for improving the DH parameter method share the advantage of achieving coordinated optimization of geometric and dynamic errors through multi-source error coupling modeling and compensation strategies. While significant progress has been made in improving robot positioning accuracy, they still face bottlenecks such as high model complexity, high computational resource consumption, and a strong dependence on training data. In particular, the ability to respond to nonlinear errors in real time under dynamic conditions remains to be improved.

[0045] In view of this, this application proposes a robot positioning prediction method, please refer to Figure 1 , Figure 1 This is a flow chart of a robot positioning prediction method proposed in one embodiment of the present application. Figure 1 As shown, the method includes the following steps:

[0046] S101: Acquire multiple batches of sample data, wherein each sample data includes joint angle data and actual position coordinates of the target robot.

[0047] In this embodiment, the target robot is the robot for which positioning prediction is to be performed. Specifically, the target robot can be a robot used in key aspects of intelligent manufacturing such as precision assembly, welding, and CNC high-precision machining, such as a tandem six-axis industrial robot.

[0048] First, relevant data is collected during the target robot's operation. This primarily includes the joint angle data of each joint and the actual position coordinates of the target robot's end effector within its workspace. The joint angle data and actual position coordinates generated at the same moment are then collated to produce a single piece of sample data.

[0049] It is easy to understand that the joint angle data in each sample data is a multi-dimensional array, which is composed of all the joint angle values ​​of the target robot. For example, when the target robot is a serial six-axis industrial robot, its joint angle data is a 6-dimensional array, which can be expressed as The actual position coordinates in each sample data are a three-dimensional coordinate vector, which can be expressed as .

[0050] Multiple consecutive sample data pieces form a batch of sample data, for example, 20, 50, or 100 consecutive sample data pieces form a batch. This application does not impose any restrictions on this, and the specific batch size may be determined based on the actual motion trajectory of the target robot and the sample collection requirements.

[0051] Furthermore, considering the needs of algorithm processing, the joint angle data in the sample data needs to be converted from degree system to radian system to ensure the correctness and efficiency of the mathematical model and algorithm implementation.

[0052] S102: Construct an initial position prediction model and initialize model parameters and hyperparameters; wherein the position prediction model includes a physical drive branch and a data drive branch.

[0053] In this embodiment, the position prediction model takes as input the joint angle data of the target robot and outputs its corresponding position coordinates. Exemplarily, the position prediction model can be constructed based on deep learning models, Bayesian optimization long short-term memory networks, convolutional neural networks (CNNs), Transformer models, and the like.

[0054] In this embodiment, the position prediction model may be a Body-Transformer Enhanced Residual Network (BoTER model for short) composed of a Transformer model and a residual network.

[0055] Model parameters primarily include the weights of each network layer in the location prediction model and are automatically optimized and updated during model training. Hyperparameters are configuration items set before training begins to control the model structure, training strategy, and optimization behavior. They are not automatically updated with training data.

[0056] For example, the hyperparameters can be configured as follows: the input dimension of the Transformer encoder is 126, the number of encoder layers is 4, and the number of attention heads is 6; the hidden layer dimension of the residual network is 512. The optimizer uses the AdamW optimizer, and the learning rate is , the weight decay rate is , the batch size of the sample data is 256, the maximum number of training rounds of the model is 5000, and the gradient clipping threshold is 1.0.

[0057] For further information, please refer to Figure 2 , Figure 2 Schematic diagram of the framework of the position prediction model in one embodiment of the present application. Figure 2 As shown in Figure 1, the position prediction model consists of a physical-driven branch and a data-driven branch. The physical-driven branch is used to predict the theoretical position coordinates of the target robot based on the joint angle data. The data-driven branch is used to predict the coordinate compensation values ​​of the target robot based on the joint angle data.

[0058] S103: Through the physical drive branch, based on the joint angle data, the theoretical position coordinates of the target robot are predicted using the DH parameter method.

[0059] In this embodiment, the physical drive branch is a robot kinematic model driven by a mechanism formula. This branch constructs a kinematic mechanism subnetwork based on the Denavit-Hartenberg (DH) parameterization method. By inputting the multi-dimensional joint angle data of the target robot, the theoretical position coordinates of the target robot's end effector can be output.

[0060] Specifically, for a serial six-axis industrial robot, input six-dimensional joint angle data ( is a real number), the DH parameter method is used to predict and output the theoretical position coordinates of the target robot The specific process is as follows:

[0061] First, obtain the preset DH parameter table. For example, the DH parameter table of a tandem six-axis industrial robot is shown in Table 1 below:

[0062] Table 1 DH parameters of serial six-axis industrial robots

[0063]

[0064] in, Indicates the connecting rod offset in millimeters; Indicates the length of the connecting rod in millimeters; Indicates torsion, the unit is radian; Represents the joint angle in radians.

[0065] Then, according to the relevant data in the DH parameter table, calculate the 6 joint angles respectively The corresponding homogeneous transformation matrix :

[0066]

[0067] Then, according to the connecting rod sequence of the six-axis industrial robot, the angles of each joint are adjusted. The homogeneous transformation matrix of the end coordinate system is multiplied step by step to obtain the cumulative transformation matrix of the end coordinate system relative to the base coordinate system .

[0068] Finally, the accumulated transformation matrix Multiply by the external tool coordinate system offset matrix (i.e., the identity matrix) to finally extract the translation part As the theoretical position coordinates.

[0069] S104: Through data-driven branching, based on joint angle data, using the improved Transformer network, the coordinate compensation value of the target robot is predicted.

[0070] In this embodiment, the data-driven branch is a deep learning model based on the Transformer network. By inputting the multi-dimensional joint angle data of the target robot, the coordinate compensation value of the end effector of the target robot can be output.

[0071] The Transformer network is a sequence model based on an attention mechanism. Unlike traditional recurrent neural networks (RNNs) and convolutional neural networks (CNNs), the Transformer uses a self-attention mechanism to process input and output sequences, enabling parallel computation and significantly improving computational efficiency.

[0072] In this embodiment, a preset sparse self-attention mask matrix is ​​introduced into the Transformer architecture, and a residual network is combined with the output end for prediction to form an improved Transformer network, which is then applied to industrial robot positioning error compensation, and the error propagation path is explained through attention weight visualization.

[0073] S105: Based on the theoretical position coordinates and the coordinate compensation value, obtain the first predicted position coordinates of the target robot.

[0074] In this embodiment, if Figure 2 As shown in the figure, the input joint angle data of the target robot, after passing through the two feedforward branches described above, can be used to obtain the theoretical position coordinates calculated by the mechanism-driven DH model and the coordinate compensation values ​​predicted by the data-driven Transformer network. Then, by combining the theoretical position coordinates and the coordinate compensation values, the first predicted position coordinates of the target robot can be obtained.

[0075] Specifically, the theoretical position coordinates and coordinate compensation values ​​can be combined using the following formula:

[0076]

[0077] in, represents the first predicted position coordinate of the target robot, Indicates the theoretical position coordinates of the target robot, Indicates the coordinate compensation value of the target robot, Represents the scaling parameter.

[0078] It should be noted that Initialized to 0.1, and set as a trainable scaling parameter, that is, during the training process of the entire position prediction model, the scaling parameter It is one of the model parameters that needs to be updated to ensure that the position prediction model can achieve the best fusion effect of theoretical value and compensation value while converging stably.

[0079] S106: Constructing a data-driven residual term based on the geometric error between the actual position coordinates of a batch of sample data and the first predicted position coordinates.

[0080] In this embodiment, the data-driven residual term is the most basic optimization term of the loss function, which is defined as the geometric error between the first predicted position coordinates obtained by the position prediction model based on the joint angle data of the target robot and the actual position coordinates corresponding to the joint angle data, so as to ensure the alignment between the predicted position and the actual end effector position.

[0081] Specifically, the formula for constructing the data-driven residual term is as follows:

[0082]

[0083] in, represents the data-driven residual term, Indicates the first The first predicted position coordinates corresponding to the sample data, Indicates the first The actual position coordinates corresponding to the sample data, Indicates the number of sample data contained in the training batch.

[0084] S107: Constructing a spatial physical information residual term based on the spatial distribution difference between the theoretical position coordinates of a batch of sample data and the first predicted position coordinates.

[0085] In this implementation, for a batch of n sample data, location prediction is performed using the DH parameter method to obtain n corresponding theoretical location coordinates. Simultaneously, location prediction is performed using the location prediction model to obtain n corresponding first-order predicted location coordinates. The spatial distribution of the n theoretical location coordinates and the spatial distribution of the n first-order predicted location coordinates are then statistically analyzed. Based on the difference in their spatial distribution, a spatial physical information residual term is constructed.

[0086] The spatial physical information residual term is another optimization term of the loss function, which is defined as the spatial distance difference between the first predicted position coordinates predicted by the position prediction model based on the joint angle data of the target robot and the theoretical position coordinates corresponding to the joint angle data predicted by the DH parameter method.

[0087] This embodiment innovatively introduces a spatial structure preservation mechanism, using the spatial topological structure output by the theoretical model (DH parameter method) to guide the distribution of prediction values ​​of the data model (position prediction model) to improve the geometric rationality of the industrial robot positioning prediction.

[0088] S108: Construct a hybrid loss function based on the data-driven residual term and the spatial physical information residual term.

[0089] In this embodiment, a hybrid loss function for the position prediction model is constructed by combining the data-driven residual term and the spatial physical information residual term, namely, the spatial physical information hybrid loss (SPI).

[0090] Specifically, the process mainly includes: determining the first weight corresponding to the data-driven residual term and the second weight corresponding to the spatial physical information residual term; based on the first weight and the second weight, weighting the data-driven residual term and the spatial physical information residual term to obtain a hybrid loss function.

[0091] To avoid negative values ​​in weight parameters during training (because weights must be non-negative to ensure physical meaning), the following constraints are imposed on the weights:

[0092]

[0093] in, represents the original first weight or second weight, Indicates the effective first weight or second weight that actually participates in the calculation after being constrained.

[0094] Then, the data-driven residual term and the spatial physical information residual term are dynamically weighted to construct a hybrid loss function:

[0095]

[0096] in, represents the mixed loss function, represents the data-driven residual term, represents the spatial physical information residual term, represents the first weight corresponding to the data-driven residual term, Represents the second weight corresponding to the residual term of spatial physical information.

[0097] It should be noted that the first and second weights are trainable parameters. This means that during the entire position prediction model training process, they are among the model parameters that need to be updated. Consequently, with each training round, the first and second weights are automatically updated using gradient backpropagation, dynamically balancing the importance of the data-driven residual term and the spatial physical information residual term, ultimately adaptively finding the optimal weight combination.

[0098] Purely data-driven models have "black box" characteristics, and their predictions may violate physical laws, limiting their application in scenarios requiring high reliability. They also typically require thousands of training samples to ensure model stability. In this embodiment, a hybrid loss function is constructed based on a data-driven residual term and a spatial physics residual term to improve the geometric rationality of the target robot's end-point position prediction and achieve high-precision positioning error prediction for small samples.

[0099] S109: Optimize the initial position prediction model based on the hybrid loss function and update the model parameters until a first preset termination condition is reached, then stop updating to obtain a trained position prediction model.

[0100] In this embodiment, the first preset termination condition includes convergence of the loss function, reaching the maximum number of iterations, learning rate decay, early stopping method, etc.

[0101] Specifically, during training, if the loss value of the hybrid loss function no longer decreases significantly within a certain number of iterations (e.g., the change is below a set threshold), the location prediction model is considered to have converged, and training updates are stopped. Alternatively, when the number of training iterations exceeds the maximum number of iterations, training is forcibly terminated. Alternatively, when the learning rate decreases to a certain level, training updates are stopped (as training progresses, the learning rate gradually decreases, the model update amplitude decreases accordingly, and the training speed slows down). Alternatively, when the performance of the location prediction model does not improve for multiple consecutive epochs (rounds), training is stopped. This helps to stop training in a timely manner when the model reaches optimal performance and avoid overfitting.

[0102] This embodiment optimizes the initial position prediction model based on a hybrid loss function. On the one hand, by aligning the predicted position with the actual end-effector position, the positioning prediction effect of the position prediction model is ensured; on the other hand, by aligning the spatial topological structure of the positioning prediction results of the position prediction model with the spatial topological structure output by the theoretical model (DH parameter method), the model is forced to maintain the spatial topological consistency of the robot motion. At the same time, a dynamic weight mechanism is introduced to balance the multi-loss term optimization process to improve the geometric rationality of the industrial robot positioning prediction.

[0103] S110: Input the current joint angle data of the target robot into the trained position prediction model to predict the current position coordinates of the target robot.

[0104] In this embodiment, the trained position prediction model can be directly used to predict and output the current position coordinates of the end effector of the target robot based on the current joint angle data of the target robot.

[0105] In this application, due to factors such as joint clearance, connecting rod deformation, and thermal drift, the robot's end effector's trajectory often deviates from the theoretically planned path during actual operation, resulting in positioning deviation. Although the DH parameter method can derive theoretical position coordinates from joint angles, the nonlinear errors in actual assembly are still difficult to fully represent using the mechanism model. Therefore, there is still an error between the derived theoretical position coordinates and the actual position coordinates.

[0106] Based on this, this application proposes a Body-Transformer Enhanced Residual Network (BoTER) optimized with a spatially informed loss (SPI), namely the SPI-BoTER position prediction model, to achieve high-precision prediction of the target robot's end-effector position. Specifically, by designing a physical-data dual-branch collaborative network, namely the position prediction model, the theoretical position coordinates of the target robot are predicted using the DH parameter method, and the coordinate compensation values ​​of the target robot are predicted using an improved Transformer network. This decouples the theoretical position coordinates predicted by the DH model from the positioning error compensation driven by the Transformer, thus avoiding the limitations of a single modeling paradigm. The theoretical position coordinates and the coordinate compensation values ​​are then further fused, and by combining the robot's kinematic prior knowledge with the nonlinear expression capabilities of deep learning, high-precision end-point position prediction for the target robot is achieved.

[0107] On the other hand, by proposing a spatial physical information hybrid loss function and using the spatial topological structure output by the DH model, the distribution of the predicted values ​​of the entire position prediction model is guided, so that the position prediction model can effectively learn the spatial information of the target robot's workspace and improve the geometric rationality of the target robot's terminal point prediction. This not only enhances the physical interpretability, but also avoids the poor terminal positioning prediction effect caused by excessive errors between physical values ​​and measured values.

[0108] Please refer to Figure 3 , Figure 3 This is a processing flow chart of the position prediction model in one embodiment of the present application. Figure 3 As shown in Figure 2, the entire model framework processes joint angles through two collaborative branches: physical drive and data drive. Assume that the target is a serial six-axis industrial robot, where Convert the 6 joint angles of the robot arm into radians Then it is input into the location prediction model. This is the feedforward calculation result of the physical driven robotic arm kinematic model, Coordinate compensation value for Transformer network data-driven branch prediction, is the final first predicted position coordinate.

[0109] The improved Transformer network includes an independent linear layer, a masked multi-head self-attention encoding module, and a residual prediction module. The above step S104 predicts the coordinate compensation value of the target robot based on the joint angle data using the improved Transformer network through data-driven branching, including:

[0110] S104-1: Through independent linear layers, each joint angle in the joint angle data is independently embedded and dimensionally increased to obtain an embedding vector.

[0111] In this implementation, the traditional Transformer model embeds multiple variables at each time step into the same tag, which may make the learned attention map meaningless and greatly weaken its modeling ability on time series. Align and perform high-level feature decoupling. In this embodiment, each joint radian value of a set of joint samples is projected into a high-dimensional feature representation through an independent linear layer, that is, each passes through a 6 to The linear layer is linearly transformed, so that for a batch of sample data, a [batch size, 6, ]’s embedding vector :

[0112]

[0113] in, Indicates the number of The embedding vector of sample data, It is the activation function used in each linear layer to introduce nonlinear features. 、 are the trainable weights and biases used in each linear layer, which are randomly initialized with a random number seed 139 before training begins.

[0114] For example, for a batch of sample data with a size of 5, the embedded vector formed is It can be expressed as:

[0115]

[0116] S104-2: Through the masked multi-head self-attention encoding module, feature extraction is performed on the embedding vector based on the self-attention weight matrix to obtain a feature vector; wherein the self-attention weight matrix is ​​obtained by applying a preset sparse self-attention mask matrix to the initial attention score matrix and then performing Softmax activation.

[0117] In this implementation, the self-attention mechanism is the core component of the Transformer. It allows the model to compare each joint angle in the input joint angle data sequence with other joint angles when processing the sequence, so as to correctly process each joint angle in different contexts. On this basis, a multi-head attention mechanism is introduced. The multi-head attention mechanism learns different contextual representations by applying the self-attention mechanism to multiple sets of different query matrices Q, key matrices K, and value matrices V. Specifically, the input joint angle data sequence is subjected to different linear transformations to obtain multiple sets of different query matrices Q, key matrices K, and value matrices V, which are then input into multiple parallel self-attention mechanisms for processing.

[0118] like Figure 3 As shown, this embodiment adopts =4-layer pytorch version of the standard Transformer encoder, with an input dimension of , the feedforward layer dimension is , each layer contains The head self-attention mechanism and the feedforward network are combined, and the global dependency between joint angles is calculated using the self-attention mechanism to obtain the initial attention score matrix:

[0119]

[0120] in, is the initial attention score matrix, which indicates the “degree of attention” of each position in the input sequence to all other positions; is the query matrix, which is obtained by linear transformation of the input sequence; is the bond matrix, and The dimensions are the same, and multiplication by transposition reflects the strength of the association between positions; Represents the square root of the key vector dimension, used to scale the dot product result to prevent gradient disappearance.

[0121] The preset sparse self-attention mask matrix is ​​a sparse masking matrix set according to the attention relationship between the joint positions reflected by the structural characteristics of the target robot itself.

[0122] This embodiment applies a preset sparse self-attention mask matrix to the initial attention score matrix determined by the self-attention mechanism to obtain a masked self-attention score matrix:

[0123]

[0124] in, represents the masked self-attention score matrix, Represents the preset sparse self-attention mask matrix.

[0125] The masked self-attention score matrix is ​​then activated by the Softmax function to obtain the self-attention weight matrix, which is used to extract global features from the embedding vector, enabling the position prediction model to focus on important position areas more effectively, reducing the complexity of the model's attention processing, and ultimately improving the model's positioning prediction ability.

[0126] S104-3: Through the residual prediction module, the feature vector is dimensionally adjusted, and after activation using the ReLU function, the coordinate compensation value of the target robot is output.

[0127] In this embodiment, the residual prediction module is an output layer composed of a multi-layer residual block network, which is used to adjust the dimension of the feature vector and further extract features, and then activate it through the ReLU function to finally output the coordinate compensation value of the target robot.

[0128] Specifically, such as Figure 3 As shown, the residual prediction module includes a first linear layer, a second linear layer, and a fully connected linear layer in sequence, wherein the first linear layer and the second linear layer have the same dimension, and the dimension of the fully connected linear layer is three. The processing process of the residual prediction module mainly includes:

[0129] The feature vector is reduced in dimension by the first linear layer and activated by the ReLU function to obtain the first intermediate vector; the first intermediate vector is extracted by the second linear layer and activated by the ReLU function to obtain the second intermediate vector; the first intermediate vector and the second intermediate vector are jump-fused to obtain the vector to be predicted; the vector to be predicted is regressed by the fully connected linear layer to output the coordinate compensation value of the target robot.

[0130] In this embodiment, the calculation formula of the coordinate compensation value of the target robot is as follows:

[0131]

[0132] in, Indicates the coordinate compensation value, represents the feature vector extracted by the multi-head self-attention encoding module, The first linear layer and the second linear layer The residual block composed of skip connections, ReLU represents the activation function, represents a fully connected linear layer.

[0133] like Figure 3 As shown, the dimension of the feature vector extracted by the multi-head self-attention encoding module is (The target robot has 6 joints, and the dimension of each joint is ), after the feature vector is input into the residual prediction module, it first passes through the first linear layer Perform feature dimensionality reduction and use the ReLU function to activate and enhance nonlinearity. The output dimension is The first intermediate vector. Then, through the second linear layer Perform feature extraction and activate using the ReLU function. The output dimension is The second intermediate vector. Then, the first intermediate vector and the second intermediate vector are jump-fused to obtain the vector to be predicted. Finally, through the fully connected linear layer Perform regression analysis on the predicted vector, map the predicted vector to the three-dimensional output space, and output the coordinate compensation value of the target robot ,Right now .

[0134] This embodiment uses the Transformer encoding framework with sparse attention mask for six-axis robotic arms for feature extraction, and constructs a residual network (ResidualNet) at the output of the Transformer encoder to enhance the coordinate compensation value through residual connections. prediction stability.

[0135] Optionally, when the target robot is a serial six-axis industrial robot, the method for constructing a preset sparse self-attention mask matrix includes:

[0136] The six joints of a serial six-axis industrial robot are hierarchically grouped, with the first three joints divided into a position adjustment group and the last three joints into a posture adjustment group. The first three joints pay attention to each other, the last three joints pay attention to each other, and adjacent joints pay attention to each other. A unidirectional cross-group attention is set, so that the first three joints in the position adjustment group pay unidirectional attention to the last three joints in the posture adjustment group, and a sparse self-attention mask matrix for the target robot is constructed.

[0137] Please refer to Figure 4 , Figure 4 Schematic diagram of the structure of a serial six-axis industrial robot in one embodiment of the present application. Figure 4 As shown, the serial six-axis industrial robot includes 、 、 、 、 、 , a total of six joints.

[0138] In this embodiment, considering that the position and posture of the end effector of a serial six-axis industrial robot is determined by the coordination of six joints, but the influence weight of each joint on the end is different (for example, the joint close to the base has a larger influence range), this embodiment designs a sparse self-attention mask matrix adapted to the structural characteristics of the serial six-axis industrial robot and follows the physical connection rules and kinematic characteristics of its robotic arm links to control the attention range of different joints through masking (for example, the joints at the base can pay attention to all joints, while the joints at the end only pay attention to themselves). The sparse self-attention mask matrix is ​​then applied to the data-driven branch of the position prediction model to adjust the attention weight distribution in the Transformer network to improve the efficiency of feature extraction (traditional Transformer networks do not take into account the kinematic characteristics of the serial six-axis industrial robot, which may cause the attention weights to be dispersed across irrelevant joints, affecting the effect of feature extraction).

[0139] Specifically, the kinematic characteristics of the serial six-axis industrial robot are that the front three joints control the coarse adjustment of the position, and the rear three joints control the fine adjustment of the posture. Therefore, this application groups the serial six-axis industrial robot into hierarchical groups according to its functions, and divides the front three joints into the position adjustment group (including joints 、 、 ), control the coarse adjustment of the position, so that the joint close to the base can obtain a larger "receptive field", which is consistent with the physical fact that its global influence is stronger; the last three joints are divided into the posture adjustment group (including joints 、 、 ), controls pose fine-tuning so that the local attention of the end joints is focused on fine pose adjustment. Furthermore, each joint is allowed to pay attention to its direct parent / child joints, meaning that adjacent joints are visible. At the same time, the first three joints in the same group are visible to each other, and the last three joints in the same group are visible to each other.

[0140] Furthermore, to ensure the directionality of the kinematic chain, we set the cross-group unidirectional visibility, that is, the first three joints are visible and the last three joints are invisible, and vice versa. Finally, the constructed sparse self-attention mask matrix is ​​as follows:

[0141]

[0142] Where 0 = visible, 1 = blocked.

[0143] For example, the element "1" in the 4th row and 1st column of the sparse self-attention mask matrix represents the joint Invisible joints (Visible in one direction across groups), the element "0" in the 4th row and 3rd column represents the joint Visible joints (adjacent joints are visible), the element "0" in the 4th row and 6th column represents the joint Visible joints (Groups in the same group are visible to each other).

[0144] In specific implementation, the sparse self-attention mask matrix is ​​applied to the multi-head self-attention encoding module of the improved Transformer network. The initial attention score matrix determined by the self-attention mechanism is combined with the sparse self-attention mask matrix to obtain a masked self-attention score matrix. This is then activated through a Softmax function to obtain the self-attention weight matrix attn_weights. This is then combined with the V matrix obtained by projecting the input sequence for feature aggregation. Feature extraction is then performed through a series of feedforward networks and residual normalization layers, ultimately resulting in a feature vector. During this process, the positions masked by the sparse self-attention mask matrix are set to zero in the self-attention weight matrix attn_weights after the Softmax activation, forcing the entire position prediction model to ignore invalid connections between robot joints. This design reduces the time complexity of the traditional fully connected self-attention mechanism from O(n²) (where n is the sequence length) to O(kn) (where k is the number of non-zero connections), improving the model's computational efficiency. Furthermore, this approach avoids the possibility of the model learning behaviors that violate mechanical structure dependencies, eliminates invalid interference, and enhances physical plausibility while improving the accuracy of model predictions. Furthermore, the predefined sparse self-attention mask matrix can be transferred to similar robots to improve the model's generalization capabilities.

[0145] Optionally, step S107 constructs a spatial physical information residual term based on the spatial distribution difference between the theoretical position coordinates of a batch of sample data and the first predicted position coordinates, including:

[0146] S107-1: Based on the theoretical position coordinates corresponding to each joint angle data in a batch of sample data, determine the Euclidean distance between any two theoretical position coordinates to obtain a theoretical distance matrix.

[0147] In this embodiment, for a batch of sample data, the DH parameter method is first used to predict the theoretical position coordinates corresponding to the sample data based on the joint angle data:

[0148]

[0149] in, Indicates the The joint angle data of sample data, It represents the first The theoretical position coordinates corresponding to the sample data are: Indicates the number of samples contained in a training batch.

[0150] Then, calculate the Euclidean distance between any two theoretical position coordinates and construct a theoretical distance matrix:

[0151]

[0152] in, It represents the first The theoretical position coordinates corresponding to the sample data are: It represents the first The theoretical position coordinates corresponding to the sample data are: Indicates the The theoretical position coordinates corresponding to the sample data are The theoretical distance matrix is ​​composed of the Euclidean distances of the theoretical position coordinates corresponding to the sample data.

[0153] S107-2: Based on the first predicted position coordinates corresponding to each joint angle data in the sample data of this batch, determine the Euclidean distance between any two first predicted position coordinates to obtain a predicted distance matrix.

[0154] In this embodiment, for the sample data of this batch, the position prediction model is used to predict the first predicted position coordinates corresponding to the sample data based on the joint angle data. Then, the Euclidean distance between any two first predicted position coordinates is calculated to construct a prediction distance matrix:

[0155]

[0156] in, Represents the first The first predicted position coordinates corresponding to the sample data, Represents the first The first predicted position coordinates corresponding to the sample data, Indicates the The first predicted position coordinates corresponding to the sample data are The prediction distance matrix is ​​composed of the Euclidean distances of the first predicted position coordinates corresponding to the sample data.

[0157] S107-3: Based on the mean square error between the theoretical distance matrix and the predicted distance matrix, construct the spatial physical information residual term.

[0158] In this implementation, in order to eliminate absolute scale differences and focus on preserving relative spatial relationships, the theoretical distance matrix and the predicted distance matrix can be normalized first:

[0159]

[0160]

[0161] in, represents the normalized theoretical distance matrix, Represents the normalized predicted distance matrix, and max represents the maximum value.

[0162] Then, based on the normalized theoretical distance matrix and the predicted distance matrix, the mean square error between the theoretical position coordinates of the sample data of this batch and the first predicted position coordinates is calculated to construct the spatial physical information residual term:

[0163]

[0164] This loss term calculates the MSE loss (mean square error loss) of the theoretical distance matrix and the predicted distance matrix of each training batch. During the training process of the position prediction model, the model parameters of the position prediction model are updated according to the hybrid loss function composed of this loss term (spatial physical information residual term) and the above-mentioned data-driven residual term, thereby integrating the advantages of kinematic constraints and data-driven modeling, forcing the predicted points to maintain the same spatial topological structure as the DH theoretical model, and improving the geometric rationality of the industrial robot point prediction.

[0165] For details, please refer to Figure 5 , Figure 5 This is a simulation diagram of optimizing a batch of sample data using a mixed loss function in an embodiment of the present application. Figure 5 As shown, the first figure reflects the spatial distribution of the 7 theoretical position coordinates corresponding to each joint angle data in the 7 sample data with a batch size of 7 (theoretical distance matrix), the second figure reflects the spatial distribution of the 7 first predicted position coordinates corresponding to each joint angle data in the 7 sample data (prediction distance matrix), and the third figure reflects the predicted position coordinates output by the position prediction model for each joint angle data in the 7 sample data after training using the mixed loss function SPI.

[0166] This embodiment innovatively introduces a spatial structure-preserving mechanism, using the Euclidean distance matrix as a representation of the spatial structure. The spatial topology output by the DH theoretical model guides the distribution of predicted values ​​from the data model (position prediction model). Specifically, by constructing a theoretical distance matrix and a predicted distance matrix, and using matrix alignment constraints for the Euclidean distances between samples within a batch, the position prediction model is forced to maintain topological consistency in the kinematic space. This improves the geometric rationality of position prediction for industrial robot end-effectors. This enhances physical interpretability while avoiding poor positioning prediction results caused by large errors between physical and measured values.

[0167] Robot inverse kinematics (IK) is the process of calculating the joint angles of a robot from the known end-effector's target position. Robot IK is also crucial in practical machining scenarios. Traditional analytical methods (such as the DH parameter model) and numerical iterative approaches are not suitable for building forward robot models using neural networks. Heuristic algorithms such as genetic algorithms (GAs) and particle swarm optimization (PSOs) are computationally slow and unsuitable for the efficiency demands of real-world scenarios.

[0168] Given that traditional numerical methods have limited ability to compensate for nonlinear angle errors, how to reverse-calculate the angles of each joint of the robot through the end target position to obtain the angle compensation value is another problem that needs to be solved in this application.

[0169] For this issue, please refer to Figure 6 , Figure 6 This is a logical framework diagram for reverse angle compensation in one embodiment of the present application. Figure 6 As shown, this application freezes the optimal parameters of the trained SPI-BoTER model (i.e., the position prediction model obtained by training the hybrid loss function as mentioned above) and uses it as a forward kinematics calculator. Then, a trainable input layer is designed to achieve end-to-end high-precision angle solution through the Adam optimizer and gradient descent algorithm.

[0170] Specifically, the process is as follows Figure 7 As shown, Figure 7 : This is a flow chart of reverse angle compensation in one embodiment of the present application. The angle compensation process mainly includes the following steps:

[0171] S701: Determine the target position coordinates, and use the DH parameter method to reversely obtain the theoretical joint angle data corresponding to the target position coordinates.

[0172] In this embodiment, the target position coordinates that the target robot needs to reach are first set, and then the task space instructions are converted into specific motion parameters in the joint space through inverse kinematics calculation. For example, the DH parameter method can be used to inversely obtain the theoretical joint angle data corresponding to the target position coordinates.

[0173] It's easy to understand that, theoretically, controlling the target robot to execute motions according to theoretical joint angle data will allow it to reach the target position coordinates. However, due to issues such as joint play, link deformation, and thermal drift, the actual position reached after controlling the target robot to execute motions according to theoretical joint angle data often deviates from the set target position coordinates. Therefore, when controlling the target robot's joint angles, it is necessary to compensate for each joint angle to ensure that it successfully reaches the set target position coordinates.

[0174] S702: Freeze the trained position prediction model, add an input layer before the position prediction model, and set the theoretical joint angle data as the initial weight value of the input layer; wherein the number of joints contained in the theoretical joint angle data is the same as the dimension of the input layer.

[0175] In this implementation, the best trained position prediction model (SPI-BoTER model) is first loaded, its network parameters are frozen, and the model is switched to application evaluation mode. A multidimensional input layer is then added before the position prediction model with the best frozen parameters. The output of this layer serves as the input to the position prediction model, namely the theoretical joint angle data.

[0176] The number of joints contained in the theoretical joint angle data is the same as the dimension of the input layer. Figure 6 As shown in the figure, for a serial six-axis industrial robot, the dimension of the input layer is 6.

[0177] S703: Input the multidimensional full tensor into the input layer, output the theoretical joint angle data through the input layer, and use the position prediction model to predict the second predicted position coordinates corresponding to the theoretical joint angle data.

[0178] In this implementation, the theoretical joint angle data is set as the initial weight value of the input layer, and then a multidimensional full tensor is input into the input layer for processing, thereby outputting the theoretical joint angle data. The theoretical joint angle data is then used as input to a position prediction model, which predicts the second predicted position coordinate corresponding to the theoretical joint angle data. Ultimately, the three-axis error (i.e., the error in the x, y, and z dimensions) between the target position coordinate and the second predicted position coordinate is output.

[0179] S704: Determine an error loss function based on the mean square error between the target position coordinates and the second predicted position coordinates.

[0180] In this embodiment, if Figure 6 As shown in Figure 1, the error loss function, namely the MSE loss function, is constructed by calculating the mean square error between the target position coordinates and the second predicted position coordinates.

[0181] S705: Based on the error loss function, the initial weight value of the input layer is updated with reverse gradient until a second preset termination condition is reached, then the update is stopped to obtain the optimized joint angle.

[0182] In this implementation, the optimization target is set as a tensor of all zeros in the x, y, and z dimensions. The error between the output and the optimization target is then measured using mean squared error (MSE). Ultimately, after multiple iterations of training (backpropagation updates the weights of the input layer), the resulting input layer weights are the angles that are solved.

[0183] Specifically, by calculating the gradient of the loss value of the error loss function with respect to the input layer weight, gradient descent is performed to update the weight parameters of the input layer. At the same time, to prevent gradient explosion, the implicit constraint update step size is set through the built-in gradient clipping mechanism of Adam. For example, the learning rate of the Adam optimizer can be set to In this network, only the input layer weights are optimized. The Adam optimizer is used because its adaptive momentum feature can accelerate the convergence of non-convex optimization problems.

[0184] During the optimization process, if the MSE loss value of the current round is lower than the threshold, the iteration cycle is terminated early, the update is stopped, and the optimized joint angle is obtained.

[0185] S706: Determine an angle compensation value based on the optimized joint angle and the theoretical joint angle.

[0186] In this implementation, after the optimization is completed, the input layer weight is the optimized joint angle. Converting it from radians back to degrees and subtracting the initial theoretical joint angle will give the angle compensation value:

[0187]

[0188] in, Indicates the angle compensation value, represents the optimized joint angle, represents the theoretical joint angle.

[0189] S707: Adjust the joint angles of the target robot based on the angle compensation value so that the target robot reaches the target position coordinates.

[0190] In this embodiment, after the target position coordinates are set, the target robot is originally controlled to perform actions according to the theoretical joint angle data. However, after the angle compensation value is calculated through the above steps of this application, the joint angle of the target robot is first adjusted using the angle compensation value. For example, the angle compensation value is added to the theoretical joint angle data to obtain the actual adjusted angle value, and then the target robot is controlled to perform actions according to the actual adjusted angle value, so that the target robot accurately reaches the set target position coordinates.

[0191] In this embodiment, by giving the target robot a target position coordinate and the corresponding theoretical joint angle data, a gradient descent algorithm based on the Adam optimizer is used to perform inverse angle solution, and a set of actual joint angles that can reach the target position coordinates in actual industrial scenarios are obtained, and then the required angle compensation value is solved, so that the target robot can accurately reach the target point after angle compensation, thereby making the industrial robot applicable to more motion control scenarios under high-precision and complex working conditions.

[0192] This application provides a solution for high-precision control of industrial robots that is both physically interpretable and data adaptable, which is expected to promote the reliable execution of high-precision tasks in intelligent manufacturing, and provides a solution for angular error compensation of serial six-axis industrial robots that is both physically interpretable and data flexible.

[0193] Please refer to Figure 8 Based on the same inventive concept, a second aspect of an embodiment of the present application provides a robot positioning prediction device, the robot positioning prediction device 800 comprising:

[0194] The sample acquisition module 801 is used to acquire multiple batches of sample data, wherein each sample data includes joint angle data and actual position coordinates of the target robot;

[0195] Model building module 802, used to build an initial location prediction model and initialize model parameters and hyperparameters; wherein the location prediction model includes a physical drive branch and a data drive branch;

[0196] Theoretical coordinate determination module 803 is used to predict the theoretical position coordinates of the target robot based on the joint angle data using the DH parameter method through the physical drive branch;

[0197] The coordinate compensation determination module 804 is used to predict the coordinate compensation value of the target robot based on the joint angle data using the improved Transformer network through data-driven branching;

[0198] The predicted coordinate determination module 805 is used to obtain the first predicted position coordinates of the target robot based on the theoretical position coordinates and the coordinate compensation value;

[0199] A first loss determination module 806 is configured to construct a data-driven residual term based on a geometric error between the actual position coordinates of a batch of sample data and the first predicted position coordinates;

[0200] A second loss determination module 807 is configured to construct a spatial physical information residual term based on a spatial distribution difference between the theoretical position coordinates of a batch of sample data and the first predicted position coordinates;

[0201] A loss function construction module 808 is used to construct a hybrid loss function based on the data-driven residual term and the spatial physical information residual term;

[0202] The model training module 809 is used to optimize the initial position prediction model based on the hybrid loss function and update the model parameters until a first preset termination condition is reached, then stop updating to obtain a trained position prediction model;

[0203] The current coordinate prediction module 810 is used to input the current joint angle data of the target robot into the trained position prediction model to predict the current position coordinates of the target robot.

[0204] Optionally, the improved Transformer network includes an independent linear layer, a masked multi-head self-attention encoding module and a residual prediction module;

[0205] The coordinate compensation determination module 804 includes:

[0206] The dimension-raising submodule is used to independently embed and raise the dimension of each joint angle in the joint angle data through an independent linear layer to obtain an embedding vector;

[0207] The encoder module is used to extract features from the embedding vector based on the self-attention weight matrix through the masked multi-head self-attention encoder module to obtain a feature vector; wherein the self-attention weight matrix is ​​obtained by applying a preset sparse self-attention mask matrix to the initial attention score matrix and then performing a softmax activation;

[0208] The mapping submodule is used to adjust the dimension of the feature vector through the residual prediction module, and output the coordinate compensation value of the target robot after activation using the ReLU function.

[0209] Optionally, when the target robot is a serial six-axis industrial robot, the encoding submodule includes:

[0210] The joint grouping unit is used to hierarchically group the six joints of the serial six-axis industrial robot, dividing the first three joints into a position adjustment group and the last three joints into a posture adjustment group; the first three joints pay attention to each other, the last three joints pay attention to each other, and adjacent joints pay attention to each other;

[0211] The cross-group permission unit is used to set cross-group unidirectional attention, so that the first three joints in the position adjustment group unidirectionally pay attention to the last three joints in the posture adjustment group, and construct a sparse self-attention mask matrix for the target robot.

[0212] Optionally, the residual prediction module includes a first linear layer, a second linear layer, and a fully connected linear layer in sequence, wherein the first linear layer and the second linear layer have the same dimension, and the dimension of the fully connected linear layer is three;

[0213] The above mapping submodules include:

[0214] A dimensionality reduction unit, configured to reduce the dimensionality of the feature vector through a first linear layer and activate it using a ReLU function to obtain a first intermediate vector;

[0215] an extraction unit, configured to extract features from the first intermediate vector using a second linear layer and activate it using a ReLU function to obtain a second intermediate vector;

[0216] a residual fusion unit, configured to perform jump fusion on the first intermediate vector and the second intermediate vector to obtain a vector to be predicted;

[0217] The mapping unit is used to perform regression analysis on the prediction vector through a fully connected linear layer and output the coordinate compensation value of the target robot.

[0218] Optionally, the second loss determination module 807 includes:

[0219] Theoretical distance matrix determination submodule is used to determine the Euclidean distance between any two theoretical position coordinates based on the theoretical position coordinates corresponding to each joint angle data in a batch of sample data to obtain a theoretical distance matrix;

[0220] A prediction distance matrix determination submodule is used to determine the Euclidean distance between any two first prediction position coordinates based on the first prediction position coordinates corresponding to each joint angle data in the sample data of the batch, and obtain a prediction distance matrix;

[0221] The residual term determination submodule is used to construct the spatial physical information residual term based on the mean square error between the theoretical distance matrix and the predicted distance matrix.

[0222] Optionally, the loss function construction module 808 includes:

[0223] A weight determination submodule, configured to determine a first weight corresponding to a data-driven residual term and a second weight corresponding to a spatial physical information residual term;

[0224] a weighting submodule, configured to weight the data-driven residual term and the spatial physical information residual term based on the first weight and the second weight to obtain a hybrid loss function;

[0225] The above-mentioned model training module 809 includes:

[0226] The weight updating submodule is used to perform reverse gradient update on the first weight and the second weight.

[0227] Optionally, the device further comprises:

[0228] The target coordinate setting module is used to determine the target position coordinates and use the DH parameter method to reversely obtain the theoretical joint angle data corresponding to the target position coordinates;

[0229] The model adjustment module is used to freeze the trained position prediction model and add an input layer before the position prediction model. The theoretical joint angle data is set as the initial weight value of the input layer. The number of joints included in the theoretical joint angle data is the same as the dimension of the input layer.

[0230] A coordinate prediction module is used to input a multidimensional full tensor into an input layer, output theoretical joint angle data through the input layer, and use a position prediction model to predict a second predicted position coordinate corresponding to the theoretical joint angle data;

[0231] A loss determination module, configured to determine an error loss function based on a mean square error between the target position coordinates and the second predicted position coordinates;

[0232] The weight update module is used to perform reverse gradient update on the initial weight value of the input layer based on the error loss function until a second preset termination condition is reached, then stop updating to obtain the optimized joint angle;

[0233] An angle compensation determination module, used to determine an angle compensation value based on the optimized joint angle and the theoretical joint angle;

[0234] The angle adjustment module is used to adjust the joint angles of the target robot based on the angle compensation value so that the target robot reaches the target position coordinates.

[0235] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0236] On the third aspect, based on the same inventive concept, an embodiment of the present application provides a readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements the robot positioning prediction method proposed in the first aspect of the present application.

[0237] It should be noted that the specific implementation of the storage medium of the embodiment of the present application refers to the specific implementation of the robot positioning prediction method proposed in the first aspect of the embodiment of the present application, and will not be repeated here.

[0238] In the fourth aspect, based on the same inventive concept, refer to Figure 9 An embodiment of the present application provides an electronic device 900, including a processor 901 and a memory 902; the memory 902 stores machine executable instructions that can be executed by the processor 901, and the processor 901 is used to execute the machine executable instructions to implement the robot positioning prediction method proposed in the first aspect of the present application.

[0239] It should be noted that the specific implementation of the electronic device 900 in the embodiment of the present application refers to the specific implementation of the robot positioning prediction method proposed in the first aspect of the embodiment of the present application, and will not be repeated here.

[0240] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0241] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, apparatuses, or computer program products. Therefore, the embodiments of the present application may take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware.

[0242] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0243] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0244] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0245] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0246] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0247] The above is a detailed introduction to the robot positioning prediction method, device, medium and equipment provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A robot positioning prediction method, characterized in that: The method comprises: Acquire multiple batches of sample data, wherein each sample data includes joint angle data and actual position coordinates of the target robot; Constructing an initial position prediction model and initializing model parameters and hyperparameters; wherein the position prediction model includes a physical drive branch and a data drive branch; The physical drive branch uses the DH parameter method to predict the theoretical position coordinates of the target robot based on the joint angle data; By using the data-driven branch and an improved Transformer network, a coordinate compensation value of the target robot is predicted based on the joint angle data; Obtaining a first predicted position coordinate of the target robot based on the theoretical position coordinate and the coordinate compensation value; Constructing a data-driven residual term based on a geometric error between the actual position coordinates of a batch of sample data and the first predicted position coordinates; Constructing a spatial physical information residual term based on a spatial distribution difference between the theoretical position coordinates and the first predicted position coordinates of a batch of sample data; Constructing a hybrid loss function based on the data-driven residual term and the spatial physical information residual term; Optimizing the initial position prediction model based on the hybrid loss function, updating the model parameters until a first preset termination condition is reached, then stopping the updating to obtain a trained position prediction model; The current joint angle data of the target robot is input into the trained position prediction model to predict the current position coordinates of the target robot.

2. The method according to claim 1, characterized in that The improved Transformer network includes an independent linear layer, a masked multi-head self-attention encoding module and a residual prediction module; The data-driven branch predicts the target robot's coordinate compensation value based on the joint angle data using an improved Transformer network, including: By means of the independent linear layer, each joint angle in the joint angle data is independently embedded and dimensionally increased to obtain an embedding vector; Performing feature extraction on the embedding vector based on a self-attention weight matrix using the masked multi-head self-attention encoding module to obtain a feature vector; wherein the self-attention weight matrix is ​​obtained by applying a preset sparse self-attention mask matrix to the initial attention score matrix and then performing a softmax activation; The residual prediction module adjusts the dimension of the feature vector and activates it using the ReLU function to output the coordinate compensation value of the target robot.

3. The method according to claim 2, characterized in that In the case where the target robot is a serial six-axis industrial robot, the method for constructing the preset sparse self-attention mask matrix includes: The six joints of the serial six-axis industrial robot are hierarchically grouped, with the first three joints being divided into a position adjustment group and the last three joints being divided into a posture adjustment group; wherein the first three joints pay attention to each other, the last three joints pay attention to each other, and adjacent joints pay attention to each other; A cross-group unidirectional attention is set so that the first three joints in the position adjustment group unidirectionally pay attention to the last three joints in the posture adjustment group, and a sparse self-attention mask matrix for the target robot is constructed.

4. The method according to claim 2, characterized in that The residual prediction module includes a first linear layer, a second linear layer, and a fully connected linear layer in sequence, wherein the dimensions of the first linear layer and the second linear layer are the same, and the dimension of the fully connected linear layer is three; The residual prediction module adjusts the dimension of the feature vector and activates it with the ReLU function to output the coordinate compensation value of the target robot, including: Performing dimensionality reduction on the feature vector through the first linear layer and activating it using a ReLU function to obtain a first intermediate vector; Performing feature extraction on the first intermediate vector through the second linear layer and activating it using the ReLU function to obtain a second intermediate vector; Perform jump fusion on the first intermediate vector and the second intermediate vector to obtain a vector to be predicted; The fully connected linear layer performs regression analysis on the vector to be predicted, and outputs the coordinate compensation value of the target robot.

5. The method according to claim 1, characterized in that Based on the spatial distribution difference between the theoretical position coordinates and the first predicted position coordinates of a batch of sample data, a spatial physical information residual term is constructed, including: Based on the theoretical position coordinates corresponding to each joint angle data in a batch of sample data, determine the Euclidean distance between any two theoretical position coordinates to obtain a theoretical distance matrix; Based on the first predicted position coordinates corresponding to each joint angle data in the sample data of the batch, determining the Euclidean distance between any two of the first predicted position coordinates to obtain a predicted distance matrix; The spatial physical information residual term is constructed based on the mean square error between the theoretical distance matrix and the predicted distance matrix.

6. The method according to claim 1, wherein Based on the data-driven residual term and the spatial physical information residual term, a hybrid loss function is constructed, including: Determining a first weight corresponding to the data-driven residual term and a second weight corresponding to the spatial physical information residual term; weighting the data-driven residual term and the spatial physical information residual term based on the first weight and the second weight to obtain the hybrid loss function; The updating of model parameters includes: Perform a reverse gradient update on the first weight and the second weight.

7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: Determine the target position coordinates, and use the DH parameter method to reversely obtain the theoretical joint angle data corresponding to the target position coordinates; Freezing the trained position prediction model, adding an input layer before the position prediction model, and setting the theoretical joint angle data as the initial weight value of the input layer; wherein the number of joints included in the theoretical joint angle data is the same as the dimension of the input layer; Inputting a multidimensional full tensor into the input layer, outputting the theoretical joint angle data through the input layer, and using the position prediction model to predict a second predicted position coordinate corresponding to the theoretical joint angle data; Determining an error loss function based on a mean square error between the target position coordinates and the second predicted position coordinates; Based on the error loss function, performing reverse gradient update on the initial weight value of the input layer until a second preset termination condition is reached, then stopping the update to obtain the optimized joint angle; determining an angle compensation value based on the optimized joint angle and the theoretical joint angle; The joint angle of the target robot is adjusted based on the angle compensation value so that the target robot reaches the target position coordinates.

8. A robot positioning prediction device, characterized in that: The device comprises: A sample acquisition module is used to acquire multiple batches of sample data, wherein each sample data includes joint angle data and actual position coordinates of the target robot; A model building module, configured to construct an initial location prediction model and initialize model parameters and hyperparameters; wherein the location prediction model includes a physical drive branch and a data drive branch; a theoretical coordinate determination module, configured to predict the theoretical position coordinates of the target robot using the DH parameter method based on the joint angle data through the physical drive branch; A coordinate compensation determination module is configured to predict a coordinate compensation value of the target robot based on the joint angle data and using an improved Transformer network through the data-driven branch; A predicted coordinate determination module, configured to obtain a first predicted position coordinate of the target robot based on the theoretical position coordinate and the coordinate compensation value; A first loss determination module is configured to construct a data-driven residual term based on a geometric error between the actual position coordinates of a batch of sample data and the first predicted position coordinates; a second loss determination module, configured to construct a spatial physical information residual term based on a spatial distribution difference between the theoretical position coordinates and the first predicted position coordinates of a batch of sample data; A loss function construction module, configured to construct a hybrid loss function based on the data-driven residual term and the spatial physical information residual term; A model training module is used to optimize the initial position prediction model based on the hybrid loss function and update the model parameters until a first preset termination condition is reached, then stop updating to obtain a trained position prediction model; The current coordinate prediction module is used to input the current joint angle data of the target robot into the trained position prediction model to predict the current position coordinates of the target robot.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the robot positioning prediction method according to any one of claims 1 to 7 is implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the robot positioning prediction method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Industrial robot pose precision compensation method based on deep learning

    CN112497216A

  • Robot milling track precision compensation method

    CN114750146A