Mechanical arm external torque estimation method based on improved CNN-LSTM

By improving the CNN-LSTM model and combining convolutional attention and LSTM units, the problem of adaptability of external torque estimation for robotic arms to complex environments is solved, and high-precision and stable external torque estimation is achieved.

CN120901938APending Publication Date: 2025-11-07SICHUAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511011087.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-22
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

Existing methods for estimating the external torque of robotic arms rely on complex physical models, which are difficult to adapt to complex environments and unknown loads, and are easily affected by noise and uncertainties, resulting in large estimation errors.

Method used

An improved CNN-LSTM model is used to construct the dynamic equations of an N-axis robotic arm, establish a CALSTM model, combine a convolutional attention module and an LSTM unit, build a training dataset and optimize the model parameters to estimate the external torque of the robotic arm.

Benefits of technology

It improves the accuracy and stability of external torque estimation for robotic arms, has high adaptability and robustness, and can effectively estimate the external torque of a seven-joint robotic arm, reducing the dependence on precise dynamic models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120901938A_ABST
    Figure CN120901938A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of mechanical arm external torque estimation, and particularly relates to an improved CNN-LSTM-based mechanical arm external torque estimation method, which comprises the following steps of: constructing a dynamic equation of an N-axis mechanical arm, and converting the dynamic equation of the N-axis mechanical arm; a CALSTM model is established, the CALSTM model is provided with a convolution attention module and an LSTM unit, and the convolution attention module is provided with a convolution attention module; constructing a model training data set, training the CALSTM model, and optimizing and updating model parameters; and collecting and processing specified data of the mechanical arm, inputting the processed data of the mechanical arm into the trained CALSTM model, and estimating the external torque of the mechanical arm through the CALSTM model. Effective estimation of the external torque of the seven-joint mechanical arm can be achieved, and compared with a traditional model, estimation precision and stability are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of mechanical arm external torque estimation, and particularly relates to a mechanical arm external torque estimation method based on an improved CNN-LSTM. BACKGROUND

[0002] Mechanical arms are widely used in modern industry in the fields of automatic production, precise operation, service robots, etc., and have become an important tool for promoting intelligent manufacturing. With the increase of task complexity, how to ensure that the mechanical arm can stably and accurately estimate the external load during execution has become one of the key problems to ensure system safety, work efficiency and operation precision. Load estimation directly affects the control accuracy, motion stability and working life of the mechanical arm, especially in tasks such as force control operation, polishing and collision detection, which have very high precision requirements. Real-time and accurate load estimation is crucial to ensure the smooth progress of the task.

[0003] Traditional load estimation methods are mostly based on the physical model of the mechanical arm, such as force measurement based on force / torque sensors, momentum observers, etc. The force measurement based on force / torque sensors is to obtain the external environmental force [3] Although the sensor-based method has sensitivity and accuracy, it is often costly and increases the complexity of the mechanical arm system. The observer-based method solves this problem, but it needs to construct an accurate system dynamics model and obtain the mechanical arm parameters through dynamics parameter identification, then obtain the control torque, collect the mechanical arm joint position and speed information, and finally use the designed observer to derive the joint external torque and convert it to the end force through the Jacobian matrix.

[0004] Currently, in the field of observer-based external load estimation, many researchers have conducted certain research on it. Some people use a generalized momentum observer (GMO) based on the design of the observer to estimate the external torque, which excludes the acceleration term from the robot dynamic model, avoiding the use of acceleration sensors or the error caused by the acceleration obtained by the second difference of the position information. Some people have designed a high-order finite-time observer (HOFTO) to estimate time-varying (especially fast time-varying) interaction forces. Some people have designed a sliding film momentum observer, which is used to estimate the external torque and estimate the joint acceleration. Some people have designed a composite observer composed of a momentum observer and an extended state observer, the former provides high-precision tracking, and the latter reduces the peak at the beginning, and finally the observer is optimized to a certain extent in sensitivity and peak reduction. However, in the actual work of the manipulator, the uncertainty of the load, the friction, the nonlinear characteristics of the joint and the external disturbance often make it difficult for these estimation methods based on physical models to adapt to complex environments. Especially when it comes to unknown loads or complex work scenarios, traditional methods require high parameter identification and model accuracy, and are easily affected by noise and uncertainty factors, resulting in large estimation errors.

[0005] With the development of deep learning, data-driven methods based on deep learning have shown great potential in tackling the nonlinear problems in the estimation of the external load of the manipulator. In the field of load estimation, some people have used back propagation (BP) neural networks to create data-driven models of model errors to improve model accuracy in solving how to establish and identify accurate dynamic models. Some people propose a whole grey box structure method, which uses a static friction model to compensate for the friction torque in the dynamic model, and builds a neural network to predict dynamic uncertain torque. By using the data of the free movement of the manipulator without external load as a sample to train the neural network, a model from joint position and velocity to control torque is obtained, and finally the external torque / force acting on the joint is estimated by subtracting the internal torque / force (neural network output) from the measured torque under load. An observer is used to estimate the external torque, and a deep neural network model is trained to learn the robot collision signal and identify any collisions. This data-driven method unifies the feature extraction and decision-making process from high-dimensional signals. The above fusion of data-driven methods to a certain extent reduces the difficulty of accurately establishing the dynamics model of the manipulator or reduces the dependence on accurate dynamic models.

[0006] According to the above analysis, in order to calculate the external load at the end of the mechanical arm, without using a six-dimensional force sensor, it is necessary to first calculate the external torque of each joint, but the lack of an accurate dynamic model of the mechanical arm is still an important factor limiting accurate load estimation. In order to avoid the need for accurate modeling of the dynamics of the mechanical arm, the present application provides a data-driven mechanical arm external load estimation method to solve the above technical problems existing in the prior art. SUMMARY

[0007] The purpose of the present application is to provide an improved CNN-LSTM mechanical arm external torque estimation method based on the CALSTM model, which does not rely on a complex physical model and can solve the above technical problems existing in the prior art.

[0008] To solve the above technical problems, the technical solution adopted by the present application is as follows:

[0009] The improved CNN-LSTM mechanical arm external torque estimation method comprises the following steps:

[0010] S1: constructing the dynamic equation of an N-axis mechanical arm, and converting the dynamic equation of the N-axis mechanical arm;

[0011] S2: establishing a CALSTM model, the CALSTM model setting a convolution attention module and an LSTM unit, the convolution attention module setting a convolution attention module;

[0012] S3: constructing a model training data set, training the CALSTM model, and optimizing and updating the model parameters;

[0013] S4: collecting and processing specified data of the mechanical arm, inputting the processed mechanical arm data into the trained CALSTM model, and estimating the external torque of the mechanical arm through the CALSTM model.

[0014] Preferably, the specific process of step S1 is as follows:

[0015] S11: constructing the dynamic equation of an N-axis mechanical arm, the specific formula being as follows:

[0016]

[0017] wherein M(q), G(q) are respectively the inertia matrix, the Coriolis force, the gravity vector, q are respectively the angular acceleration, the velocity and the position of each joint, f is the friction torque of the mechanical arm joint, which is mainly viscous friction at normal temperature and moderate speed, τ un is the random torque caused by uncertain factors, τ extis the external torque suffered by the joint, τ c is the control torque of the joint;

[0018] S12: converting the dynamic equation of the N-axis mechanical arm, and the conversion formula is as follows:

[0019]

[0020] Preferably, the convolution attention module in step S2 extracts local features of the mechanical arm data, and uses the convolution attention module to improve the feature extraction capability of the convolution attention module, and identifies the spatial correlation pattern in each time window;

[0021] The LSTM unit captures the dynamic information of the time sequence, including the time sequence dependence of the current joint state and the previous state;

[0022] The CALSTM model combines the spatial correlation pattern in each time window, the time sequence dependence of the current joint state and the previous state, and realizes the estimation of the external force of the mechanical arm joint.

[0023] Preferably, the convolution attention module includes a channel attention module and a spatial attention module, and before the convolution attention module operates on the input data, two one-dimensional convolution layers are used to extract the short-term pattern of the data in each time window, and a ReLU activation function is used after each convolution operation to introduce nonlinear characteristics:

[0024] The specific formula of the first layer convolution operation is as follows:

[0025] Q1 = ReLU (W1 * X);

[0026] The specific formula of the second layer convolution operation is as follows:

[0027] Q2 = ReLU (W2 * X"1);

[0028] Wherein, * represents convolution operation, W1 and W2 are convolution kernels, X is input tensor, and X"1 is refined output after the first convolution attention module;

[0029] S22: The output data of the convolution layer is processed by the channel attention module: the information of the feature tensor is aggregated by average pooling and maximum pooling operations to generate two different context descriptors: and The average pooling feature and the maximum pooling feature are represented by and respectively;

[0030] and are forwarded to a shared network to complete splicing, and a channel attention tensor M cThe shared network is a multi-layer perceptron composed of one hidden layer and two convolutional layers, and in order to reduce the calculation amount of the hidden layer parameters, the output channel number of the convolutional layer before the hidden layer is set as C / ratio, C is the input channel number, and ratio is the channel reduction rate;

[0031] The output of the hidden layer is then input into another convolutional layer with an input channel number of C / ratio and an output channel number of C to be weighted and fused with the original input channel;

[0032] After the shared network is applied to each descriptor, the output feature vectors are combined using the element summation method:

[0033] σ represents a sigmoid function, AvgPool is an average pooling operation, MaxPool is a maximum pooling operation, W co , W c1 is a convolution kernel, * is a convolution operation, and wherein W c0 , W c1 is shared by two input ends;

[0034] S23: The spatial attention module performs average pooling and maximum pooling operations along the channel axis, and then concatenates them to highlight the information region and generate efficient feature descriptors, specifically: the channel information of the feature map is collected through two kinds of pooling operations to generate two tensors and represent the average pooling features and the maximum pooling features of the entire channel, respectively, and then the average pooling features and the maximum pooling features are concatenated and convolved through a standard convolutional layer:

[0035]

[0036] σ represents a sigmoid function, AvgPool is an average pooling operation, MaxPool is a maximum pooling operation, W s0 is a convolution kernel, * is a convolution operation, and represent the average pooling features and the maximum pooling features of the entire channel, respectively.

[0037] Preferably, the LSTM unit in step S2 captures the dynamic change relationship in time through multiple layers and hidden unit numbers to model the sequence data and learn the short-term dependency across time steps. The dependency modeling between the current time step and the previous time steps is realized through the memory cell and the forgetting gate mechanism, and the input gate, the forgetting gate and the output gate are calculated through the following formulas, respectively:

[0038] i t = σ(W i xt +U i h t-1 +b i );

[0039] f t =σ(W f x t +U f h t-1 +b f );

[0040] o t =σ(W o x t +U o h t-1 +b o );

[0041] The state update formula of the memory cell is as follows:

[0042] C t =f t ☉C t-1 +i t ☉tanh(W c x t +U c h t-1 +b c );

[0043] The calculation formula of the hidden state of each time step is as follows:

[0044] h t =o t ⊙tanh(c t );

[0045] Wherein, σ represents the sigmoid function, ⊙ is the element-wise multiplication, W i , W f , W o , W c , U i , U f , U o , U c are weights and biases of the LSTM layer respectively;

[0046] Through the time series modeling of the LSTM, the dynamic pattern between multiple time steps is identified, and the time sequence information is provided for the external torque estimation. The last hidden state h T of the time window in the LSTM layer output is taken as the final feature, which is mapped to the output space through the fully connected layer to estimate the external torque of each joint:

[0047]

[0048] where W fc and b fc are the weights and biases of the fully connected layer, and the output is the torque estimation of the seven joints.

[0049] Preferably, in step S3, the mechanical arm motion parameters at continuous time points, including the position, velocity, control torque information of each joint and the corresponding joint external torque, are added to the model input as a new feature in the form of an increasing time window when constructing the training data set, and the hidden acceleration information in the multi-time motion state change is found through the CALSTM model to make up for the lack of acceleration signals.

[0050] The specific way of increasing the time window when constructing the training data set is that, in a continuous sequence of data samples, each time point and the continuous T time points before the time point are cut as a whole to be a single input of the model q t ,

[0051]

[0052] q t = [q t-T … q t-1 q t ];

[0053]

[0054] q t , respectively represent the velocity, position and control torque information of each joint of the tth sequence;

[0055] In the model training process, the root mean square error is used as the loss function, and the specific formula is as follows:

[0056]

[0057] where N is the total number of samples, is the estimated external torque vector of the ith sample, τ ext,i is the true external torque vector of the ith sample, and ||·|| represents the square norm of the vector 2 , where θ represents all trainable parameters of the neural network.

[0058] In the model training process, the specified optimizer is used to adaptively adjust the learning rate of different parameters, so that the parameter update is more efficient and stable. The model parameters θ are iteratively updated, and finally the loss function is minimized, and the update rule is as follows:

[0059] For the current model parameters θ k , the gradient g k of the loss function is calculated:

[0060]

[0061] Update the first-order momentum estimate:

[0062] m k = β1m k-1 + (1-β1)g k ;

[0063] where m k represents the exponential weighted average of the current gradient, used to smooth the optimization process, and β1∈[0,1) is the first-order momentum decay coefficient;

[0064] Update the second-order momentum estimate:

[0065]

[0066] where v k is the exponential weighted average of the gradient square, used to control the adaptive adjustment of the learning rate, and β2∈[0,1) is the second-order momentum decay coefficient.

[0067] To alleviate the deviation of the momentum estimate in the initial stage, Adam introduces a bias correction mechanism:

[0068]

[0069] where and are the momentum estimates after bias correction, and k is the iteration number;

[0070] The optimizer updates the model parameters according to the following formula:

[0071]

[0072] where α is the learning rate control parameter, and ∈ is a small value to prevent division by zero.

[0073] Preferably, the data acquisition process in step S4 is as follows:

[0074] S41: Design a flexible controller to control the right arm of the dual-arm robot, and then use external force to pull the robot arm to move freely in space. The relationship between the external force moment and the joint position of the robot arm during movement is:

[0075]

[0076] where q d and qr are the desired trajectory and the reference trajectory of the robot arm respectively, M d is the mass matrix, D d is the damping coefficient matrix, K d is the stiffness coefficient matrix;

[0077] The joint position is collected by the position sensor built in the robot arm, the external torque is collected by the torque sensor installed, the control torque is converted into torque size according to a certain proportion by the current information collected by the current loop, and the speed information is obtained by differentiating the position information:

[0078]

[0079] wherein q(t) is the joint speed and position information under discrete time, and Δt is the sampling time interval;

[0080] The noise of data collection is processed, and the selection formula of the noise point is as follows:

[0081] |x i -μ1|>3σ1;

[0082] wherein, μ1 is the average value of the data set, σ1 is the standard deviation, x i is the original data collected.

[0083] Preferably, the model is evaluated after the model training, and the specific process is as follows:

[0084] The evaluation indexes are selected: mean absolute error (MAE), determination coefficient R 2 and normalized root mean square error (NRMSE), and the respective calculation formulas are as follows:

[0085]

[0086] wherein, τ ext,i is the true external torque value, is the predicted external torque value, is the average value of the true external torque, τ ext,max is the maximum value of the true external torque, τ ext,min is the minimum value of the true external torque, and n is the sample quantity.

[0087] The beneficial effects of the present application include:

[0088] The application provides an improved CNN-LSTM based external torque estimation method for a mechanical arm, and particularly relates to an improved CNN-LSTM based external torque estimation method for a mechanical arm, a dynamic equation of an N-axis mechanical arm is constructed, and the dynamic equation of the N-axis mechanical arm is converted; a CALSTM model is established, the CALSTM model is provided with a convolution attention module and an LSTM unit, the convolution attention module is provided with a convolution attention module; a model training data set is constructed, the CALSTM model is trained, and model parameters are optimized and updated; specified data of the mechanical arm are collected and processed, the processed mechanical arm data are input into the trained CALSTM model, and the CALSTM model is used to estimate the external torque of the mechanical arm. The external torque of the seven-joint mechanical arm can be effectively estimated, and the estimation accuracy and stability are significantly improved compared with a traditional model.

[0089] Firstly, the external torque estimation method based on the CALSTM model does not depend on a complex physical model, has high adaptability and robustness in the case of model uncertainty or dynamic load change, and has strong generalization ability.

[0090] Secondly, the CALSTM combines the feature extraction ability of the CNN and the sequence modeling ability of the LSTM, so that it is very effective in estimating the external torque of the mechanical arm joint.

[0091] Thirdly, the CALSTM model combines the convolution attention module, greatly enhances the feature extraction ability, and improves the accuracy of the external torque estimation of the mechanical arm joint. DETAILED DESCRIPTION

[0092] Figure 1 It is a component structure diagram of the improved CNN-LSTM based external torque estimation method for a mechanical arm.

[0093] Figure 2 It is an architecture diagram of the CALSTM model.

[0094] Figure 3 It is a channel attention module structure diagram.

[0095] Figure 4 It is a spatial attention module structure diagram.

[0096] Figure 5 It is a 1-joint external force estimation result diagram.

[0097] Figure 6 It is a 2-joint external force estimation result diagram.

[0098] Figure 7 It is a 3-joint external force estimation result diagram.

[0099] Figure 8 A 4-joint external force estimation result diagram of the present application.

[0100] Figure 9 A 5-joint external force estimation result of the present application

[0101] Figure 10 A 6-joint external force estimation result of the present application

[0102] Figure 11 A 7-joint external force estimation result of the present application

[0103] Figure 12 An external force estimation comparison diagram of different models of the present application. DETAILED DESCRIPTION

[0104] The following will be described in conjunction with the accompanying Figures 1-12 The present application will be further described in detail:

[0105] Example 1

[0106] Referring to the accompanying Figure 1 As shown, the improved CNN-LSTM robot arm external torque estimation method comprises the following steps:

[0107] S1: constructing a dynamic equation of an N-axis robot arm, and converting the dynamic equation of the N-axis robot arm;

[0108] S2: establishing a CALSTM model, the CALSTM model being provided with a convolution attention module and an LSTM unit, and the convolution attention module being provided with a convolution attention module;

[0109] S3: constructing a model training data set, training the CALSTM model, and optimizing and updating the model parameters;

[0110] S4: collecting and processing specified data of the robot arm, inputting the processed robot arm data into the trained CALSTM model, and estimating the robot arm external torque through the CALSTM model.

[0111] The CALSTM network structure fusing a convolution attention mechanism is adopted, the local space features in the mechanical arm motion data are extracted by using the convolution attention module of the CNN, the time sequence dependency is captured in combination with the LSTM, and the feature extraction capability is improved through the convolution attention module. The external torque of the seven-joint mechanical arm can be effectively estimated, and compared with the traditional model, the estimation accuracy and stability are both significantly improved. A new solution is provided for the external torque estimation of a complex nonlinear system. The external torque estimation method based on the CALSTM model does not depend on a complex physical model, has high adaptability and robustness in the case of model uncertainty or dynamic load change, and has strong generalization capability. The CALSTM combines the feature extraction capability of the CNN and the sequence modeling capability of the LSTM, so that it is very effective in estimating the external torque of the mechanical arm joint. The CALSTM model combines the convolution attention module, greatly enhances the feature extraction capability, and improves the accuracy of the external torque estimation of the mechanical arm joint.

[0112] In the embodiment, the specific process of step S1 is as follows:

[0113] S11: The dynamic equation of the N-axis mechanical arm is constructed, and the specific formula is as follows:

[0114]

[0115] Wherein, M(q), G(q) are inertia matrix, Coriolis force, gravity vector, q are angular acceleration, velocity and position of each joint respectively, f is the friction torque of the mechanical arm joint, which is mainly viscous friction at normal temperature and medium speed, τ un is the random torque caused by uncertain factors, τ ext is the external torque of the joint, τ c is the control torque of the joint.

[0116] S12: The dynamic equation of the N-axis mechanical arm is converted, and the conversion formula is as follows:

[0117]

[0118] In the multi-joint mechanical arm dynamic model, the process of obtaining the inertia matrix, Coriolis force and gravity vector through mechanical arm dynamics parameter identification is complex and tedious, and the accuracy is difficult to guarantee. It is also very difficult to establish a suitable model to accurately reflect the characteristics of the friction torque f of the mechanical arm joint and the random torque characteristics caused by uncertain factors. Therefore, it is tedious and difficult to guarantee the accuracy to realize the estimation process of the external torque of the mechanical arm joint by establishing a dynamics model and using the joint position, velocity and acceleration information at a certain moment.

[0119] On the other hand, the inertia matrix, Coriolis force and gravity vector in the dynamic equation of the robot arm are mainly related to the joint speed and joint position, the friction torque is mainly affected by the joint speed (at room temperature, the viscous friction and Coulomb friction are mainly affected by the joint speed), and the random torque is a parameter related to the joint position, speed and control torque. As for the acceleration term, the use of an acceleration sensor will bring about the cost problem, but the acceleration term involved in the dynamic model is calculated by using the second difference of the joint position signal, and the estimation of the external torque will introduce new errors. Therefore, through the above analysis, it is very appropriate to use a data-driven scheme to estimate the external torque of the robot arm joint.

[0120] Embodiment 2

[0121] Referring to FIG. 2, on the basis of Embodiment 1, the convolutional attention module in step S2 extracts local features of the robot arm data, and uses the convolutional attention module to improve the feature extraction capability of the convolutional attention module, and identifies the spatial correlation pattern in each time window; Figure 2

[0122] The LSTM unit captures the dynamic information of the time sequence, including the time sequence dependence of the current joint state and the previous state;

[0123] The CALSTM model combines the spatial correlation pattern in each time window, the time sequence dependence of the current joint state and the previous state to estimate the external force of the robot arm joint.

[0124] The convolutional attention module includes a channel attention module and a spatial attention module. Before the convolutional attention module operates on the input data, two one-dimensional convolution layers are used to extract the short-term pattern of the data in each time window, and a ReLU activation function is used after each convolution operation to introduce non-linear characteristics:

[0125] The specific formula of the first layer convolution operation is as follows:

[0126] Q1 = ReLU (W1 * X);

[0127] The specific formula of the second layer convolution operation is as follows:

[0128] Q2 = ReLU (W2 * X"1);

[0129] Where * represents convolution operation, W1 and W2 are convolution kernels, X is input tensor, and X"1 is the refined output after the first convolution attention module;

[0130] S22: The output data of the convolution layer is processed by the channel attention module, as shown in FIG. 4; Figure 3 ​As shown: the information of the feature tensor is aggregated by the average pooling and the maximum pooling operation to generate two different context descriptors: and respectively represent the average pooling feature and the maximum pooling feature;

[0131] and are forwarded to a shared network to complete splicing, and a channel attention tensor M c is generated, and the shared network is a multilayer perceptron composed of a hidden layer and two convolutional layers, in order to reduce the calculation amount of the hidden layer parameters, the output channel number of the convolutional layer before the hidden layer is set to C / ratio, C is the input channel number, and ratio is the channel reduction rate;

[0132] The output of the hidden layer is then input into another convolutional layer with an input channel number of C / ratio and an output channel number of C to facilitate weighted fusion with the original input channel;

[0133] After the shared network is applied to each descriptor, the output feature vector is combined using the element summation method:

[0134] σ represents the sigmoid function, AvgPool is the average pooling operation, MaxPool is the maximum pooling operation, W co , and W c1 are convolutional kernels, * is a convolution operation, and wherein W c0 , and W c1 are shared at two input ends;

[0135] S23: Referring to Figure 4 , the spatial attention module performs average pooling and maximum pooling operations along the channel axis, and then concatenates them to highlight the information region to generate an efficient feature descriptor, specifically: the channel information of the feature map is collected by two pooling operations to generate two tensors and respectively represent the average pooling feature and the maximum pooling feature of the entire channel, and then the average pooling feature and the maximum pooling feature are concatenated and convolved by a standard convolutional layer:

[0136]

[0137] wherein σ represents the sigmoid function, AvgPool is the average pooling operation, MaxPool is the maximum pooling operation, W s0 is a convolutional kernel, and * is a convolution operation, and respectively represent the average pooling feature and the maximum pooling feature of the entire channel.

[0138] The LSTM unit in step S2 captures the dynamic change relationship over time through multiple layers and hidden units to model the sequence data and learn the short-term dependency across time steps. The dependency modeling between the current time step and the previous time steps is achieved through the memory unit and the forgetting gate mechanism. The input gate, forgetting gate, and output gate are calculated by the following formulas:

[0139] i t = σ(W i x t + U i h t-1 + b i );

[0140] f t = σ(W f x t + U f h t-1 + b f );

[0141] o t = σ(W o x t + U o h t-1 + b o );

[0142] The state update formula of the memory unit is as follows:

[0143] C t = f t ⊙C t-1 + i t ⊙ tanh(W c x t + U c h t-1 + b c );

[0144] The calculation formula of the hidden state of each time step is as follows:

[0145] h t = o t ⊙ tanh(c t );

[0146] Where σ represents the sigmoid function, ⊙ is the element-wise multiplication, W i , W f , W o , W c , U i , U f , U o , and U c are the weights and biases of the LSTM layer, respectively.

[0147] Through the time series modeling of LSTM, the dynamic pattern between multiple time steps is identified to provide time sequence information for the external torque estimation, and the hidden state h of the last time step in the time window is taken in the LSTM layer output T As the final feature, the external torque of each joint is estimated by mapping to the output space through the fully connected layer:

[0148]

[0149] where W fc and b fc are the weights and biases of the fully connected layer, and the output is the torque estimation value of the seven joints.

[0150] Embodiment 3

[0151] Based on Embodiment 1 or Embodiment 2, without using the acceleration sensor and avoiding the acceleration error caused by the second difference of the position signal, when estimating the external torque at a certain time, the continuous multi-time robot motion parameters including the position, velocity, control torque information and corresponding joint external torque of each joint are added to the model input as a new feature by increasing the time window when constructing the training data set, and the hidden acceleration information in the multi-time motion state change is found through the CALSTM model to make up for the lack of acceleration signal.

[0152] The specific way of increasing the time window when constructing the training data set is: in a continuous sequence of data samples, each time and the previous T continuous times are cut as a whole to be a single input of the model q t ,

[0153]

[0154] q t = [q t-T … q t-1 q t ];

[0155]

[0156] q t , respectively represent the velocity, position and control torque information of each joint of the tth sequence;

[0157] In the model training process, the root mean square error is used as the loss function, and the specific formula is as follows:

[0158]

[0159] where N is the total number of samples, is the estimated external torque vector of the ith sample, τ ext,i is the true external torque vector of the ith sample, ||·|| 2 denotes the squared norm of a vector, where θ represents all trainable parameters of the neural network;

[0160] During the model training process, the specified optimizer is used to adaptively adjust the learning rate of different parameters, making the parameter update more efficient and stable. The model parameters θ are iteratively updated, and finally the loss function is minimized, and the update rule is as follows:

[0161] For the current model parameters θ k , the gradient g k of the loss function is calculated:

[0162]

[0163] Update the first-order momentum estimate:

[0164] m k = β1m k-1 +(1-β1)g k ;

[0165] where m k represents the exponential weighted average of the current gradient, which is used to smooth the optimization process, and β1∈[0, 1) is the first-order momentum decay coefficient;

[0166] Update the second-order momentum estimate:

[0167]

[0168] where v k is the exponential weighted average of the gradient square, which is used to control the adaptive adjustment of the learning rate, and β2∈[0, 1) is the second-order momentum decay coefficient.

[0169] To alleviate the bias of the momentum estimate in the initial stage, Adam introduces a bias correction mechanism:

[0170]

[0171] where and are the momentum estimates after bias correction, and k is the iteration number;

[0172] The optimizer updates the model parameters according to the following formula:

[0173]

[0174] wherein, a is a learning rate control parameter update step, ∈ is a minimum value, used to prevent division by zero problem.

[0175] Example 4

[0176] On the basis of example 1 or example 2 or example 3, the process of data collection in step S4 is as follows:

[0177] S41: design a flexible controller to control the right arm of the dual-arm robot, and then drag the robot arm through an external force for uninterrupted free movement in space, and the relationship between the external torque and the position of the robot arm joint during movement is:

[0178]

[0179] wherein, q d and q r are the desired trajectory and reference trajectory of the robot arm respectively, M d is the mass matrix, D d is the damping coefficient matrix, and K d is the stiffness coefficient matrix.

[0180] The joint position is collected by the position sensor built in the robot arm, the external torque is collected by the torque sensor installed, the control torque is converted into torque size according to a certain proportion by the current information collected by the current loop, and the speed information is obtained by differentiating the position information:

[0181]

[0182] wherein q(t) is the joint speed and position information at discrete time, and Δt is the sampling time interval.

[0183] The noise of data collection is processed, and the selection formula of noise points is as follows:

[0184] |x i -μ1|>3σ1;

[0185] wherein, μ1 is the average value of the data set, σ1 is the standard deviation, and x i is the original data collected.

[0186] Preferably, the model is evaluated after the model training, and the specific process is as follows:

[0187] Select evaluation indexes: mean absolute error (MAE), determination coefficient R 2 and normalized root mean square error (NRMSE), and the calculation formulas are as follows:

[0188]

[0189]

[0190] where, τ ext,i is the true external torque value, is the predicted external torque value, is the average value of the true external torque, τ ext,max is the maximum value of the true external torque, τ ext,min is the minimum value of the true external torque, and n is the sample number.

[0191] In this embodiment, an experimental platform is used, which is composed of a dual-arm robot Baxter machine of Rethink Robotics and a computer workstation. The workstation is used to run a main program on a robot operating system (ROS) using Ubuntu 14.0, for mechanical arm control.

[0192] A total of 3077952 data samples are collected. Due to the dependence of the model on the time series, the entire data set is not randomly shuffled. 95% of the samples are used for training and verification, and in the 95% of the data set, 5% of the continuous data set at the beginning or end of the time series is taken out as a verification set for adjusting hyperparameters to obtain the optimal setting of the model parameters, and the rest is taken as a training set. The remaining 5% is used as a final test set to verify the model effect.

[0193] In order to accelerate the training convergence, improve the numerical stability, reduce the imbalance between features, and enhance the generalization ability of the model, the samples are preprocessed by Z-score normalization, and the data is converted to a distribution with a mean of 0 and a standard deviation of 1.

[0194] Regarding the hyperparameter setting of the neural network model, the present application selects several hyperparameters that have a significant impact on the results, and an approximate range that tends to produce favorable results. Including the size of the time window of the CNN and LSTM layers, the learning rate, the training batch size, the dropout rate, the channel size of the input and output layers of the CNN, the kernel size and step size of the convolution layer, the channel reduction rate in the channel attention mechanism of the CNN, the kernel size in the spatial attention mechanism, and the number of hidden units and layers of the LSTM. Then, a step-by-step adjustment strategy is adopted to select a set of hyperparameters that can make the neural network perform well on the validation set. The results are as follows: the network training traverses the training set for 200 epochs, the learning rate a is 0.001, the batch size of the training data is 512, and the random inactivation ratio of the CNN and LSTM layers is 0.1. The size of the time window t is set to 6. The first-order momentum initialization m0 and the second-order momentum initialization v0 in the Adam optimizer are both 0, the first-order momentum decay coefficient β1 is 0.1, the second-order momentum decay coefficient β2 is 0.999, and ∈ is 10 -8 .

[0195] In the training of the neural network proposed in this paper, in order to avoid the influence of randomness and test the stability of the neural network at the same time, the average value of the test evaluation index after multiple training is used to determine the estimation performance and stability of the neural network. Referring to Figure 5 , after a certain training is completed, the test set is used to verify the effect of external torque estimation, Figure 6 The evaluation index of external torque estimation of each joint is shown in the figure. It can be determined from the information shown in the figure that the external torque tracking effect of joints 1, 4, 5, 6, and 7 is better. From the NRMSE and R2 evaluation indexes, the external torque estimation effect of joints 1, 5, and 7 is the best. From the estimation accuracy, the absolute error of joints 6 and 7 is the smallest, reaching 0.199±0.0236 and 0.168±0.0237, respectively. The external torque estimation accuracy of joint 2 is slightly insufficient. This can be verified in Figure 6 and Table 2. The R2 index of joint 2 is slightly low, and the NRMSE and MAE indexes are slightly high. The reason for this situation may be that the instability of the sensor at joint 2 during sample data collection causes the internal regularity of the sample to fail, which weakens the connection between the test set and the training set, and cannot get better verification on the test set. In addition Figure 6 It also shows another information that the change of the evaluation index of each joint in the multiple training and test results of the data set is small, which proves the stability of the neural network.

[0196] In order to verify the accuracy of the model proposed in this paper, we compared the model proposed in this paper with the CNN+LSTM model, the MLR model, and the SVR model. The evaluation indexes are still NRMSE, R 2 , MAE, and the average value of multiple experiments is used for each model to reduce random error. Referring to Figures 7-11 , which reflects the effectiveness of the proposed method in estimating the external torque of each joint of the robot arm. The specific role is as follows:

[0197] (1) For the benchmark model MLR, it is a linear fitting of the relationship between input features and output, which lacks the ability to capture complex nonlinear patterns. Therefore, the CALSTM model proposed in this paper has a clear advantage in performance, with performance improvements of 14.06%, 7.40%, and 11.48% in the three evaluation indexes.

[0198] (2) When comparing the CALSTM model with SVR, its performance improvement is 11.29%, 4.72%, and 4.64% in the three indexes. The reason why CALSTM is superior to the SVR model is that SVR relies on fixed kernel functions, lacks adaptive characteristics compared to CALSTM, and has relatively weak performance in handling complex time series patterns.

[0199] (3) Compared with CNN-LSTM, CALSTM has channel attention module and spatial attention module in the convolution network, which can enhance the attention to the most useful channel by weighting the features of different channels, and focus on the key area in the spatial dimension. Therefore, the convolution attention mechanism can adaptively enhance the expression ability of the features, and finally make CALSTM more efficient and accurate in feature extraction. This is also proved in the prediction results, and the performance of CALSTM is compared with that of CNN-LSTM, and the performance improvement of the three evaluation indexes is 8.33%, 3.44% and 9.09% respectively.

[0200] Therefore, the traditional mechanical arm joint external torque estimation method usually depends on an accurate dynamic model, which may be very complex and difficult to obtain. In order to overcome this limitation, the external torque estimation method provided by the present application is improved on the basis of the neural network model of CNN-LSTM, and a new neural network CALSTM is formed by introducing channel attention mechanism and spatial attention mechanism in the convolution layer. Compared with the traditional CNN-LSTM model, the convolution network cannot adaptively select and focus on the most important features, resulting in information redundancy or neglect of important features, and has stronger adaptive feature extraction capability, so that the final external torque estimation result is more accurate than other three models.

[0201] In summary, the improved CNN-LSTM based mechanical arm external torque estimation method provided by the present application constructs the dynamic equation of N-axis mechanical arm, converts the dynamic equation of the N-axis mechanical arm, establishes a CALSTM model, sets a convolution attention module and an LSTM unit in the CALSTM model, sets a convolution attention module in the convolution attention module, constructs a model training data set, trains the CALSTM model, optimizes and updates the model parameters, collects and processes specified data of the mechanical arm, inputs the processed mechanical arm data into the trained CALSTM model, and estimates the external torque of the mechanical arm through the CALSTM model. The external torque of the seven-joint mechanical arm can be effectively estimated, and the estimation accuracy and stability are significantly improved compared with the traditional model.

[0202] The external torque estimation method based on the CALSTM model does not depend on a complex physical model, has high adaptability and robustness in the case of model uncertainty or dynamic load change, and has strong generalization ability. CALSTM combines the feature extraction ability of CNN and the sequence modeling ability of LSTM, so it is very effective in estimating the external torque of the mechanical arm joint. The CALSTM model combines the convolution attention module, greatly enhances the feature extraction ability, and improves the accuracy of the external torque estimation of the mechanical arm joint.

Claims

1. An improved CNN-LSTM based robot arm external torque estimation method, characterized in that, The method comprises the following steps: S1: constructing a dynamic equation of an N-axis mechanical arm, and converting the dynamic equation of the N-axis mechanical arm; S2: establishing a CALSTM model, the CALSTM model being provided with a convolution attention module and an LSTM unit, and the convolution attention module being provided with a convolution attention module; S3: constructing a model training data set, training the CALSTM model, and optimizing and updating model parameters; S4: collecting specified data of the mechanical arm, processing the data, inputting the processed mechanical arm data into the trained CALSTM model, and estimating an external torque of the mechanical arm through the CALSTM model.

2. The improved CNN-LSTM based robot arm external force torque estimation method according to claim 1, wherein, The specific process of step S1 is as follows: S11: constructing a dynamic equation of an N-axis mechanical arm, and the specific formula is as follows: Among them, M(q), G(q) represents the inertia matrix, Coriolis force, and gravity vector, respectively. q represents the angular acceleration, velocity, and position of each joint, respectively; f is the frictional torque of the robotic arm joints, which is mainly viscous friction at room temperature and medium speeds; τ un τ is the random torque caused by uncertain factors. ext τ is the external torque acting on the joint. c For the control torque of the joint; S12: converting the dynamic equation of the N-axis mechanical arm, and the conversion formula is as follows:

3. The improved CNN-LSTM based robot outer force torque estimation method according to claim 1, wherein, The convolution attention module in step S2 extracts local features of mechanical arm data, and uses the convolution attention module to improve the feature extraction capability of the convolution attention module, and identifies the spatial correlation mode in each time window; The LSTM unit captures dynamic information of a time sequence, including time sequence dependency of a current joint state and a previous state; The CALSTM model combines the spatial correlation mode in each time window, the time sequence dependency of the current joint state and the previous state, and realizes estimation of the external force of the mechanical arm joint.

4. The improved CNN-LSTM based robot arm external force torque estimation method according to claim 3, characterized in that, The convolution attention module comprises a channel attention module and a spatial attention module, and before the convolution attention module operates on the input data, two one-dimensional convolution layers are used to extract short-term patterns of the data in each time window, and a ReLU activation function is used after each convolution operation to introduce nonlinear characteristics: The specific formula of the first layer of convolution operation is as follows: Q1 = ReLU (W1 * X); The specific formula of the second layer of convolution operation is as follows: Q2 = ReLU (W2 * X"1); Wherein, * represents convolution operation, W1 and W2 are convolution kernels, X is input tensor, and X"1 is refined output after the first convolution attention module; S22: the output data of the convolution layer is processed by the channel attention module: The specific operation is to aggregate the information of the feature tensor by the average pooling and the maximum pooling operation on the output of the previous convolution layer to generate two different context descriptors: and respectively represent the average pooled features and the maximum pooled features; and is forwarded to a shared network to complete splicing, and the attention tensor M is generated c , the shared network is a multilayer perceptron composed of a hidden layer and two convolutional layers, in order to reduce the calculation amount of the hidden layer parameters, the output channel number of the convolutional layer before the hidden layer is set to C / ratio, C is the input channel number, and ratio is the channel reduction rate Then the output of the hidden layer is input into another convolution layer with an input channel number of C / ratio and an output channel number of C, so as to be weighted and fused with the original input channel; After the shared network is applied to each descriptor, the output feature vectors are combined using the element summation method: σ denotes a sigmoid function, AvgPool is an average pooling operation, MaxPool is a max pooling operation, W co , W c1 is a convolution kernel, * is a convolution operation and wherein W c0 , W c1 is shared by both inputs. S23: the spatial attention module performs average pooling and maximum pooling operations along the channel axis, then concatenates them to highlight the information area, and generates an efficient feature descriptor: Specifically, the channel information of the feature map is collected through two pooling operations to generate two tensors and respectively represent the average pooling feature and the maximum pooling feature of the entire channel, and then the average pooling feature and the maximum pooling feature are concatenated and convolved through a standard convolution layer: wherein, sigma represents a sigmoid function, AvgPool represents an average pooling operation, MaxPool represents a maximum pooling operation, W s0 is a convolution kernel, and * represents a convolution operation. and respectively represent an average pooling feature and a maximum pooling feature of the entire channel.

5. The improved CNN-LSTM based robot outer force torque estimation method according to claim 1, wherein, The LSTM unit in step S2 captures the dynamic change relationship in time through multiple layers and hidden unit numbers, models the sequence data, learns the short-term dependency across time steps, and realizes dependency modeling of the current time step and the previous time steps through the memory unit and the forgetting gate mechanism. The input gate, the forgetting gate and the output gate are calculated by the following formulas respectively: i t = σ(W i x t + U i h t-1 + b i ); f t = σ(W f x t + U f h t-1 + b f ); o t = σ(W o x t + U o h t-1 + b o ); The state updating formula of the memory unit is as follows: c t = f t ☉c t-1 + i t ☉ tanh(W c x t + U c h t-1 + b c ); The calculation formula of the hidden state of each time step is as follows: h t = o t tanh(c t ); wherein, σ represents a sigmoid function, and is an element-wise multiplication, W i , W f , W o , W c , U i , U f , U o , U c are weights and biases of the LSTM layer, respectively. Through time series modeling by LSTM, dynamic patterns between multiple time steps are identified to provide timing information for external torque estimation, and the hidden state h of the last time step in the time window is taken in the LSTM layer output T As the final feature, the external torque of each joint is estimated by mapping to the output space through the fully connected layer: where W fc and b fc are the weights and biases of the fully connected layer, and output is the torque estimate for the seven joints.

6. The improved CNN-LSTM based robot arm outer force torque estimation method according to claim 1, characterized in that, In step S3, the continuous multi-time mechanical arm motion parameters including the position, velocity, control torque information and corresponding joint external torque of each joint are added to the model input as a new feature in the form of increasing time window when constructing the training data set, and the hidden acceleration information in the multi-time motion state change is found through the CALSTM model to make up for the lack of acceleration signal; In constructing the training data set, the specific way of increasing the time window is: in a continuous sequence of data samples, each moment and the continuous T moments before this moment are cut as a whole to cut the single input of the model q t 、 q t = [q t-T … q t-1 q t ]; q t 、 respectively represent the velocity, position and control torque information of each joint of the tth sequence. In the model training process, the root mean square error is used as the loss function, and the specific formula is as follows: where N is the total number of samples, is the estimated external moment vector of the ith sample, ext,i is the true external moment vector of the ith sample, ||·|| is the squared norm of a vector, 2 denotes the squared norm of a vector, where θ represents all trainable parameters of the neural network; In the model training process, the specified optimizer is used to adaptively adjust the learning rate of different parameters, which makes the parameter update more efficient and stable. The model parameters θ are iteratively updated, and finally the loss function is minimized, and the update rule is as follows: For the current model parameters θ k , compute the gradient g k of the loss function: Update the first order momentum estimate: m k = β1m k-1 + (1 - β1)g k ; where m k denotes the exponentially weighted average of the current gradients for smoothing the optimization process, and β1∈[0, 1) is the first-order momentum decay coefficient. Update the second order momentum estimate: where v k is the exponentially weighted average of the squared gradient, and β2∈[0, 1) is the second-order momentum decay coefficient. In order to reduce the deviation of the momentum estimate in the initial stage, Adam introduces a bias correction mechanism: wherein, and is the bias-corrected momentum estimate, k is the iteration number; The optimizer updates the model parameters according to the following formula: Wherein, α is the learning rate control parameter update step, ∈ is a minimum value, which is used to prevent division by zero problem.

7. The improved CNN-LSTM based robot outer force torque estimation method according to claim 1, wherein, In step S4, the data acquisition process is as follows: S41: design a flexible controller to control the right arm of the dual-arm robot, and then pull the mechanical arm through the external force to move freely in space without interruption. The relationship between the external torque and the joint position of the mechanical arm during movement is: wherein q d and q r are the desired trajectory and the reference trajectory of the robot arm, respectively, M d is the mass matrix, D d is the damping coefficient matrix, and K d is the stiffness coefficient matrix. The joint position is collected by the built-in position sensor of the mechanical arm, the external torque is collected by the installed torque sensor, the control torque is converted into torque size according to a certain proportion by the current information collected by the current loop, and the speed information is obtained by differentiating the position information: wherein q(t) is joint speed and position information at discrete time, and Δt is a sampling time interval.

8. The improved CNN-LSTM based robot outer force torque estimation method according to claim 7, characterized in that, After the model is trained, the model is evaluated, and the specific process is as follows: Evaluation index: mean absolute error (MAE), coefficient of determination (R) 2 and normalized root mean square error (NRMSE), whose formulas are as follows, respectively: where τ ext,i is the true external torque value, is the predicted external torque value, is the average value of the true external torque, τ ext,max is the maximum value of the true external torque, τ ext,min is the minimum value of the true external torque, and n is the number of samples.