Mechanical arm inverse kinematics resolving method and system based on grey wolf optimization algorithm and attention time domain convolutional network

Through the combination of Gray Wolf Optimization Algorithm and attention time domain convolution network, the calculation speed and accuracy problems of the traditional robotic arm inverse kinematics solution method under high accuracy and high real-time performance are solved, and efficient and accurate inverse kinematics solution is achieved, which is suitable for robotic arm operation in industrial automation.

CN120234910APending Publication Date: 2025-07-01SHANDONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510342771.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-21
Publication Date
2025-07-01

AI Technical Summary

Technical Problem

The traditional inverse kinematics solution method of robot arm has problems such as slow calculation speed, complex solution and easy to fall into singular points under the requirements of high accuracy and high real-time, which is difficult to meet the real-time and high-precision requirements of modern industry.

Method used

Using a combination method based on gray wolf optimization algorithm and attention time domain convolution network, the attention time domain convolution network model is constructed, combined with the time domain convolution network and self-attention mechanism, hyperparameter optimization is carried out to extract the local and global features of the robotic arm pose data to achieve efficient and accurate inverse kinematics solution.

Benefits of technology

It significantly improves the accuracy and calculation efficiency of the inverse kinematic solution of the robot arm, and can complete the inverse kinematic solution in a few milliseconds, which is better than the traditional method's hundreds of milliseconds, meeting the requirements of high accuracy and high real-time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234910A_ABST
    Figure CN120234910A_ABST
Patent Text Reader

Abstract

The invention relates to a mechanical arm inverse kinematics resolving method and system based on a grey wolf optimization algorithm and an attention time domain convolutional network, and the method comprises the steps: 1, constructing an attention time domain convolutional network model, and inputting collected mechanical arm data into the attention time domain convolutional network model for training; performing intelligent optimization on hyper-parameters of the attention time-domain convolutional network model in a training process to obtain an optimal hyper-parameter combination, and obtaining a trained attention time-domain convolutional network model; 2, the trained attention time domain convolutional network model is used for predicting the angle value of the mechanical arm joint. The hyper-parameters of the TCN network are intelligently adjusted and optimized by applying the grey wolf optimization algorithm, so that the reasoning and expression ability of the model is improved, and the inverse kinematics calculation, namely the joint angle prediction task, of the mechanical arm can be more efficiently and accurately completed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and system for solving the inverse kinematics of a robotic arm based on a grey wolf optimization algorithm and an attention time-domain convolutional network, belonging to the technical field of artificial intelligence. Background Art

[0002] With the continuous progress of technology, robot technology has penetrated into various fields of modern society and become a key force driving industrial and social progress. Countries around the world have strengthened investment and research and development in the field of robotics, promoting the rapid development of robot technology, greatly replacing traditional manual labor. Especially in high-intensity and high-risk working environments, robots can not only improve production efficiency but also ensure the safety of workers and improve the working environment. In China, more and more research institutions and enterprises have emerged and invested in the research and development of robot technology, gradually catching up and connecting with the international advanced level, showing a strong development momentum.

[0003] As an important part of robot technology, robotic arms have been widely used in industrial automation and can replace humans to complete heavy, dangerous or precise tasks. The accuracy of robotic arms and their ability to adapt to complex working environments have enabled them to be widely used in multiple industries. Nevertheless, with the continuous change of work requirements, especially in high-precision and high-speed scenarios, the performance of traditional robotic arms can no longer meet the growing demands. The grasping accuracy and operation speed of robotic arms particularly depend on the inverse kinematics solution algorithm. The core problem of inverse kinematics is how to solve for a suitable combination of joint angles based on the given pose (position and orientation) of the end effector. Inverse kinematics solution not only involves the motion analysis of the robotic arm but also includes aspects such as path planning and item grasping. Therefore, its computational efficiency and accuracy directly affect the overall performance of the robotic arm.

[0004] Currently, common methods for solving the inverse kinematics of robotic arms include the analytical method, numerical method, graphical method, etc. However, traditional methods generally have problems such as slow computational speed, complex solution processes, and being prone to falling into singular points, and cannot meet the requirements of modern industry for real-time performance and high precision. With the rapid development of deep learning technology, more and more research has shown that deep learning has obvious advantages in solving the inverse kinematics of robotic arms. Compared with traditional numerical and analytical methods, deep learning can effectively extract the complex non-linear relationship between pose and joint angles, simplify the calculation process, and significantly improve the solution speed and accuracy. Deep learning methods can not only better meet the requirements of robotic arms in high-precision and high-real-time tasks but also solve complex problems that traditional methods cannot handle.

[0005] In recent years, in the research of robotic arm inverse kinematics solution algorithms, many studies have attempted to optimize them through deep learning methods. Deep learning techniques have indeed shown great potential in inverse kinematics solution tasks, capable of effectively improving the solution accuracy and speed. However, these methods still face some challenges in practical applications. Especially in complex environments and high real-time requirements, traditional deep learning models may have difficulty fully capturing the key features in the input data.

[0006] As an important technology in deep learning, the attention mechanism has been widely applied in many fields such as natural language processing, computer vision, and signal processing. In these tasks, the attention mechanism can help the model focus on the most critical information in the input data, thereby improving the model's reasoning ability and decision-making accuracy. In recent years, researchers have introduced the attention mechanism into deep learning models, further enhancing the model's feature extraction ability and expressiveness.

[0007] Moreover, the robotic arm inverse kinematics solution algorithm faces two major problems, namely:

[0008] (1) Due to the problem that traditional inverse kinematics solution algorithms cannot obtain solutions in certain specific situations, especially when encountering singular points, these algorithms often fall into a dilemma of being unable to solve.

[0009] (2) In current application scenarios with increasingly high real-time requirements for robotic arms, traditional inverse kinematics solution algorithms often face speed bottlenecks and are difficult to meet the requirements of high efficiency and real-time. Summary of the Invention

[0010] Aiming at the deficiencies of the existing technology, the present invention provides a robotic arm inverse kinematics solution method and system based on the grey wolf optimization algorithm and the attention time-domain convolutional network, adopting a network structure that combines the grey wolf hyperparameter optimization algorithm, the time-domain convolutional network (TCN), and the attention mechanism. This network can quickly extract features from the input robotic arm pose data and efficiently output the corresponding joint angle values, thereby realizing accurate and real-time inverse kinematics solution.

[0011] The present invention intelligently tunes the hyperparameters of the TCN network by applying the grey wolf optimization algorithm to obtain the optimal hyperparameter combination, thereby enhancing the model's reasoning and expression abilities and enabling it to complete the robotic arm inverse kinematics solution task more efficiently and accurately. By combining the time-domain convolutional network and the attention mechanism, a fusion network of time-domain convolutional features and attention features is created, combining the local features extracted by the time-domain convolutional network with the global features of attention, enabling the model to not only focus on local patterns during learning but also understand the context of the entire signal, and accurately grasp the robotic arm data.

[0012] Term Explanation:

[0013] 1. ReduceLROnPlateau (Automatically Adjust Learning Rate Based on Performance): It is a strategy for dynamically adjusting the learning rate. It reduces the learning rate according to the model performance on the validation set (such as changes in loss value or evaluation metrics), avoiding overfitting and improving the generalization ability of the model. Its core idea is that if the model fails to improve within a certain number of training epochs (i.e., the validation loss value does not decrease significantly), then reduce the learning rate, so that the model continues to optimize with a smaller step size, avoiding training oscillations or non-convergence caused by too large a learning rate.

[0014] 2. EarlyStopping (Early Stopping Mechanism): It is a technique to prevent overfitting, aiming to terminate the training in advance when the model performance stops improving. Its main role is to avoid overfitting during the training process of the model, reduce unnecessary computational costs, and effectively improve the generalization ability of the model. Specifically, when the loss or metric on the validation set does not improve significantly after several epochs of training, the training process will automatically stop, thus saving training time.

[0015] 3. Dropout: It is a commonly used regularization technique, aiming to reduce the complexity of the neural network, reduce the risk of model overfitting, and thus improve its generalization ability; its basic idea is that during the training process, randomly "drop out" a certain proportion of neurons in the neural network (even if the activation values of these neurons are zero), so that these neurons do not participate in the calculation of forward propagation and backward propagation in the current iteration; each time during training, through this random dropout operation, each training step of the network becomes different, thus avoiding overly strong dependency relationships between neurons and effectively reducing the overfitting phenomenon.

[0016] 4. WeightNorm: It is weight normalization, which decomposes the weight vector in the neural network into two parts: magnitude (scale) and direction, to improve the training stability and accelerate the convergence speed. Suppose a weight vector in the neural network is: WeightNorm adopts L2 normalization and re-expresses w as: where g is a learnable scalar parameter (scale factor), and v is a learnable un-normalized weight vector, representing the L2 norm (i.e., the length of v). In this way, the model actually learns the values of g and v, rather than directly learning w, so that the size of the weight can be effectively controlled, making the training more stable and improving the efficiency of gradient propagation.

[0017] The technical solution of the present invention is as follows:

[0018] The first aspect of the present invention provides a method for solving the inverse kinematics of a robotic arm based on the Grey Wolf Optimization Algorithm and the Attention Temporal Convolutional Network, including:

[0019] Step 1: Construct an Attention Temporal Convolutional Network model (TCN), and input the collected robotic arm data into the Attention Temporal Convolutional Network model for training;

[0020] During the training process, the hyperparameters of the Attention Temporal Convolutional Network model are intelligently tuned to obtain the optimal hyperparameter combination, thereby improving the inference and expression ability of the model, enabling it to complete the inverse kinematics calculation task of the robotic arm more efficiently and accurately, and obtaining the trained Attention Temporal Convolutional Network model;

[0021] The Attention Temporal Convolutional Network model includes a Temporal Convolutional Network, a self-attention mechanism, and a linear layer linear;

[0022] The Temporal Convolutional Network includes residual blocks to extract local features; the self-attention mechanism extracts global features; combining the Temporal Convolutional Network and the self-attention mechanism enables the network to pay more attention to the parts with greater influence on the output, thereby enhancing the ability to capture key data; obtaining the Attention Temporal Convolutional Network model; the linear layer linear performs feature output;

[0023] Step 2: Use the trained Attention Temporal Convolutional Network model to predict the joint angle values of the robotic arm, including inputting the robotic arm data into the stacked residual blocks in the Temporal Convolutional Network. Each residual block internally extracts features through dilated causal convolutional layers, and uses the self-attention mechanism to extract global features, enabling the network to pay more attention to the parts with greater influence on the output, thereby enhancing the ability to capture key data and further improving the inference speed; combining the local features extracted by the Temporal Convolutional Network with the global features of the self-attention mechanism enables the model to not only focus on local patterns during learning but also understand the context of the entire signal, and complete the accurate grasp of the robotic arm data; finally, through the linear layer Linear, obtain output, that is, the joint angle value.

[0024] According to the preference of the present invention, constructing the Attention Temporal Convolutional Network model; including:

[0025] In the Attention Temporal Convolutional Network model, the Temporal Convolutional Network includes residual blocks to replace the traditional single-layer convolutional structure. A self-attention mechanism is introduced between every two residual blocks. Each residual block includes 5 dilated causal convolutional layers, where the dilation rates of the dilated causal convolutional layers are 1, 2, 4, 8, and 16 respectively, and a non-linear activation function ReLU, WeightNorm, and Dropout mechanism are introduced in each layer to regularize the network, prevent overfitting, and improve the generalization ability of the model;

[0026] The dilated causal convolution layer includes causal convolution and dilated convolution for local feature extraction.

[0027] Preferably according to the present invention, the collected robotic arm data is input into the attention time-domain convolutional network model for training, including:

[0028] Collect the pose data (x, y, z, rx, ry, rz) of the robotic arm, where x, y, z are the coordinates of the end effector in the robotic arm coordinate system, and rx, ry, rz are the poses of the end effector, that is, the angles with the three coordinate axes, and the joint angle value data (j1, j2, j3, j4, j5, j6), where j1, j2, j3, j4, j5, j6 are the rotation angle values of the 6 joints of the robotic arm relative to the initial position; save them in a.CSV file, and divide the data into a training set, a validation set and a test set;

[0029] The pose data of the robotic arm is first normalized by Reshape and transformed into the form of (batch_size, timesteps, input_dim), and then input into the attention time-domain convolutional network model for training; where batch_size represents the number of training samples processed by the attention time-domain convolutional network model in one iteration, timesteps represents the time step (i.e., the length of the sequence), which is used to represent how many previous groups of data are used to predict the current joint angle value. Since the robotic arm pose and the joint angle are in one-to-one correspondence, it is 1 here, and input_dim represents the feature dimension of each time step, that is, at each time point, the dimension of the input data. Since the input is pose data, it is 6 here.

[0030] Preferably according to the present invention, in the time-domain convolutional network, feature extraction is performed through a dilated causal convolution layer inside the residual block, including:

[0031] The dilated causal convolution layer includes causal convolution (Causal Convolution) and dilated convolution (Dilated Convolution);

[0032] When dealing with time series problems, traditional CNN models usually cannot be directly used for time series data because they cannot effectively handle the temporal dependence of the data; to solve this problem, the concept of causal convolution (Causal Convolution) is proposed, aiming to ensure the causal relationship of the time series, that is, the output of the current time step only depends on the current and previous input data;

[0033] Causal convolution depends only on the values at time step t of the previous layer and those at time step t and earlier of the next layer. Different from traditional convolutional neural networks, causal convolution cannot see future data. It is a unidirectional structure, not bidirectional, and is a strict time-constrained model.

[0034] For a time series problem, it is transformed into: based on the input sequence X = (x1, x2, …, x t ), predict the output sequence Y = (y1, y2, …, y t ); in this process, the filter F = (f1, f2,..., f k ) is applied to the input sequence to generate the corresponding output.

[0035] In causal convolution, the input sequence at time step t is X = (x1, x2, …, x t ), that is, the robotic arm pose data. The filter F (convolution kernel) is of a fixed size and is defined as F = (f1, f2,..., f k ). Then the causal convolution operation at time step t is:

[0036]

[0037] where K represents the size of the filter (convolution kernel) F, k represents the index within the filter, used to traverse each element in the convolution kernel, f k represents the k-th weight parameter of the filter F, that is, the parameter value at each position in the convolution kernel, x t represents the value of the input sequence at time step t, that is, the input data at the current moment; (F * X) (t) represents the causal convolution output value at time step t.

[0038] The causal convolution operation ensures that the output at each time step depends only on the current and previous input data without leaking future information. The last two nodes of the input sequence are x t-1 and x t , and the last node of the first hidden layer, that is, the network layer where the first causal convolution calculation is performed, is y t . Then the filter F1 = (f1, f2) will be applied to the input sequence, and the calculation gives:

[0039] y t = f1x t-1 + f2x t ;

[0040] where f1 represents the influence weight of the convolution kernel on the data x t-1 at the previous time step, and f2 represents the influence weight of the convolution kernel on the data x t at the current time step.

[0041] Atrous convolution increases the receptive field by introducing a dilation rate in the standard convolution operation, avoiding the information loss problem caused by pooling operations; atrous convolution controls the spacing of the convolutional kernel by introducing a hyperparameter, namely the dilation rate, and the dilation rate determines the spacing between elements in the convolutional kernel; in a standard convolutional neural network, the default value of the dilation rate is 1, indicating no spacing; while in atrous convolution, when the dilation rate is greater than 1, the receptive field of the convolutional kernel will be effectively expanded without losing information;

[0042] Atrous convolution introduces a dilation rate on the basis of causal convolution, which not only maintains causality but also expands the receptive field. For the filter F=(f1,f2,...,f k ), and the input sequence X=(x1,x2,…,x t ), the atrous convolution with a dilation rate of d at x t is:

[0043]

[0044] where d represents the dilation rate, which is used to control the spacing between input data points, and (F*X) (xt) represents the output value of the atrous convolution at time step t;

[0045] In the residual block, after the manipulator pose data is calculated by atrous convolution and causal convolution, it passes through the WeightNorm layer, the non-linear activation function ReLU layer, and the Dropout layer in sequence to obtain local features.

[0046] According to the preference of the present invention, a self-attention mechanism is introduced between every two residual blocks to extract global features; including:

[0047] The self-attention mechanism is a mechanism that can enhance the model's ability to understand the context of input information by modeling the relationships between different parts of the input data; the core idea of the self-attention mechanism is: given an input sequence, the representation of each position not only depends on the information of that position itself, but also enhances its own representation by paying attention to (attending to) the information of other positions in the input sequence; this process is achieved by calculating the attention weights of each position; the process of the self-attention mechanism includes the following steps:

[0048] Input Representation: Each element of the input sequence is mapped to a vector space of a fixed dimension;

[0049] Calculating Attention Weights: For each element in the input sequence, first calculate the relationship between this element and all other elements, and then obtain the attention weight of this element; the attention weight represents the degree of attention of each element to other elements;

[0050] Weighted Sum: Weightedly sum the input elements according to the attention weights to obtain a new representation of this element;

[0051] Output Representation: The new representation obtained through weighted summation, and each element of the output sequence carries the information of all other elements in the input sequence;

[0052] The input sequence is X = (x1, x2,..., x t ), where x i is the representation vector of the i-th element in the input sequence, with a length of n;

[0053] First, calculate the query, key, and value vectors. For each element x i of the input, obtain the query vector q i , key vector k i , and value vector v i through different linear transformations. These vectors are used to calculate the attention weights, and the formulas are as follows:

[0054] q i = W Q x i ;

[0055] k i = W K x i ;

[0056] v i = W V x i ;

[0057] Among them, W Q , W K , W V are the weight matrices of the query, key, and value obtained through learning respectively;

[0058] Then calculate the attention weights. For the query vector q i and the key vector k j , obtain the correlation score (also called the attention score) by calculating the dot product of q i and k j , and perform scaling. The formula is as follows:

[0059]

[0060] Among them, d k is the dimension of the key vector, which plays a scaling role to avoid the vanishing gradient caused by too large dot product values; then for each query vector q i , the attention scores of all keys are normalized through the softmax function to obtain the attention weights at each position:

[0061]

[0062] Among them, a ij is the input element x i For the element x j 's attention weight;

[0063] Finally, use the obtained attention weight a ij to perform weighted summation on the value vector v j to obtain the output representation at each position:

[0064]

[0065] Among them, z i is the final representation of the i-th position in the input sequence, that is, the context information representation calculated based on the current query position i.

[0066] According to the preference of the present invention, during the training process, the hyperparameters of the attention time-domain convolutional network model are intelligently tuned to obtain the best combination of hyperparameters, so that it can complete the inverse kinematics solution task of the robotic arm more efficiently and accurately; including:

[0067] (1) Initialize the gray wolf population and a, A, and C;

[0068] Initialize the number of wolves wolf_num, that is, the number of groups of hyperparameter combinations searched in each iteration; the maximum number of iterations max_iter, that is, the number of rounds of search iteration; the dimension dim, that is, the number of hyperparameters; the hunting range of the wolf pack Lb, ub, that is, the search range of the hyperparameters; whether to provide the initial hyperparameter combination for the initialization of the alpha wolf initial_alpha_pos; alpha_pos, beta_pos, delta_pos are the positions of the alpha, beta, and delta wolves respectively; alpha_score, beta_score, delta_score are the fitness values of the alpha, beta, and delta wolves respectively;

[0069] Among them, each wolf in the gray wolf population represents a set of hyperparameter combinations, namely, the number of convolution operations nb_filters, the number of convolution kernels kernel_size, the number of residual blocks nb_stacks, the dropout rate dropout_rate, the learning rate learning_rate, and the training batch size batch_size in the attention time-domain convolutional network model;

[0070] a is a linearly decreasing coefficient that controls convergence (gradually decreasing from 2 to 0). By gradually linearly reducing the value of a, the fluctuation range of A also linearly decreases, thereby simulating the behavior of the wolf pack approaching the prey (the prey refers to the best hyperparameter combination);

[0071] C is a random value between [0, 2], representing the random weight of the position of the wolf on the prey, that is, the best hyperparameter combination. Since the value of C is a random value, it is used to prevent the algorithm from being unable to get rid of the local optimum during optimization, and plays a very important role in searching for the global optimum, that is, the best hyperparameter combination, enhancing the global search ability, robustness, and convergence of the algorithm; A is a random coefficient used to adjust the search direction and exploration ability of the wolf pack;

[0072] (2) Calculate the fitness of the gray wolf individuals, and save the top three wolves α, β, and δ with the best fitness;

[0073] The fitness of the gray wolf individual represents the training loss obtained by training each set of hyperparameters, that is, val_loss;

[0074] The wolves α, β, and δ represent the first, second, and third optimal solutions, that is, hyperparameter combinations, determined by val_loss, that is, the loss on the validation set;

[0075] (3) Update the position of the current gray wolf;

[0076] The position of the gray wolf represents the hyperparameter combination, that is, position = (hyperparameter combination);

[0077] The position update formula for wolf α:

[0078]

[0079] The position update formula for wolf β:

[0080]

[0081] The position update formula for wolf δ:

[0082]

[0083] Among them, respectively represent the positions of wolves α, β, and δ; Indicate the positions of α, β, and δ wolves in the previous generation; A1, A2, and A3 are random coefficients, namely random coefficient A, used to adjust the search direction and exploration ability of the wolf pack; D1, D2, and D3 are the distances between the prey and the wolves, and the calculation method is:

[0084]

[0085] Among them, is the best position in the current population, indicates the position vector of the current individual i, that is, the current solution of this individual in the search space, C i is a coefficient used to balance the change of the search range;

[0086] The wolf pack adjusts its own position according to the positions of α, β, and δ wolves, as shown in the following formula:

[0087] Da = ∣C1·X α - X∣;

[0088] D β = ∣C2·X β - X∣;

[0089] D δ = ∣c3·X δ - X∣;

[0090] X1 = X α - A1·D α ;

[0091] X2 = X β - A2·D β ;

[0092] X3 = X δ - A3·D δ ;

[0093]

[0094] Among them, X represents the position of the current gray wolf (the position in the previous iteration, the position where it was before this update), C1, C2, and C3 represent random values between [0, 2], X α , X β , X δ respectively represent the positions of α, β, and δ wolves, Da, D β , D δ respectively represent the distances between the current gray wolf and α, β, and δ wolves, X1, X2, and X3 respectively represent the candidate positions obtained after the current gray wolf is updated according to the positions of α, β, and δ wolves, X new represents the new position of the current gray wolf after update;

[0095] (4) Update a, A, and C, and the formula is as follows:

[0096] A = 2a·r - a;

[0097] C = 2·r;

[0098] where r represents a random vector, C is a random value between [0, 2], and a is a linearly decreasing coefficient that controls convergence;

[0099] (5) Calculate the fitness of all gray wolves, that is, the training loss val_loss obtained by training with hyperparameters;

[0100] (6) Update the positions of the α, β, and δ wolves;

[0101] Compare the existing wolf packs and select the three with the lowest training loss val_loss as the α, β, and δ wolves respectively;

[0102] (7) Determine whether the maximum number of iterations has been reached. If not, execute step (3). If so, output the position of the final α wolf, that is, the optimal hyperparameter combination;

[0103] Repeat the above steps of training and updating until the predetermined number of iterations max_iter is reached. The output optimal hyperparameter combination is used to finally train the attention time-domain convolutional network model to obtain the trained attention time-domain convolutional network model.

[0104] Further preferably, the training loss obtained by training each group of hyperparameters includes:

[0105] Determine the search range of the wolf pack by providing the initial hyperparameter combination initial_alpha_pos; first, use the initial hyperparameter combination for training and compare the training results with the results obtained by training with the hyperparameter combination of the randomly generated α wolf to select the initial hyperparameter combination; to evaluate the quality of the hyperparameters, the mean squared error MSE (Mean Squared Error) is used as the evaluation criterion, that is, the mean squared error is used to calculate the loss val_loss of the validation set; MSE is a commonly used evaluation index for regression problems, and it calculates the average of the squares of the errors between the predicted values and the actual values; the formula is:

[0106]

[0107] where: y i is the true value, y' i is the predicted value, and n is the number of data points; the smaller the value of MSE, the higher the prediction accuracy of the model and the smaller the error;

[0108] Perform max_iter iterations. In each iteration of the Grey Wolf Optimizer algorithm (for example, if the number of wolves in the wolf_num wolf pack is set to 30, then in one iteration, these 30 sets of hyperparameter combinations are all trained. After all 30 are trained, a position update is performed, that is, the best 3 wolves are found, and then the position of each wolf in the next iteration is updated through the above position update formula), each wolf in the population, that is, each hyperparameter combination, is trained, and the score of the current wolf, that is, the best hyperparameter combination determined by the loss on the validation set, is recorded. Subsequently, the positions of the α, β, and δ wolves are updated according to the scores, and the score of the α wolf in this generation is recorded. After completing this process, enter the next iteration. To save excessive unnecessary time overhead that may occur during training, the ReduceLROnPlateau and EarlyStopping mechanisms are introduced during training, aiming to control the training duration and avoid overtraining, thereby improving the efficiency of model training.

[0109] A computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the inverse kinematics solution method of the robotic arm based on the Grey Wolf Optimization algorithm and the Attention Time Domain Convolutional Network.

[0110] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps of the inverse kinematics solution method of the robotic arm based on the Grey Wolf Optimization algorithm and the Attention Time Domain Convolutional Network.

[0111] The second aspect of the present invention provides an inverse kinematics solution system of a robotic arm based on the Grey Wolf Optimization algorithm and the Attention Time Domain Convolutional Network, including:

[0112] A model training module, configured to: construct an Attention Time Domain Convolutional Network model, and input the collected robotic arm data into the Attention Time Domain Convolutional Network model for training;

[0113] During training, the hyperparameters of the Attention Time Domain Convolutional Network model are intelligently tuned to obtain the best hyperparameter combination, and the trained Attention Time Domain Convolutional Network model is obtained;

[0114] The Attention Time Domain Convolutional Network model includes a Time Domain Convolutional Network, a Self-Attention mechanism, and a linear layer linear;

[0115] The Time Domain Convolutional Network includes residual blocks to extract local features; the Self-Attention mechanism extracts global features; the Time Domain Convolutional Network and the Self-Attention mechanism are combined to obtain the Attention Time Domain Convolutional Network model; the linear layer linear performs feature output;

[0116] The model prediction module is configured to: use the trained attention time-domain convolutional network model to predict the joint angle values of the robotic arm, including:

[0117] Input the robotic arm data into the stacked residual blocks in the time-domain convolutional network, extract features through the dilated causal convolutional layer, and use the self-attention mechanism to extract global features. Combine the local features extracted by the time-domain convolutional network with the global features of the self-attention mechanism. Finally, obtain the output, that is, the joint angle value, through the linear layer Linear.

[0118] The beneficial effects of the present invention are as follows:

[0119] 1. The intelligent tuning algorithm for the hyperparameters of the TCN network proposed by the present invention based on the grey wolf optimization algorithm demonstrates powerful strength in the field of deep learning hyperparameter optimization. This algorithm innovatively applies the grey wolf optimization algorithm to the time-domain convolutional network (TCN) based on the self-attention mechanism to optimize various parameters and training hyperparameters of the network, thereby finding the best hyperparameter combination that minimizes the loss of the network model on the validation set. This method can choose whether to provide the initial hyperparameter combination according to actual needs, and then perform a global search in the hyperparameter space through the grey wolf optimization algorithm to gradually optimize the training process of the network. In each iteration, the algorithm will evaluate the performance of the current hyperparameter combination according to evaluation indicators such as MSE (mean square error) and R 2 (coefficient of determination) on the validation set, and continuously update the best hyperparameter combination according to the evaluation results. Through this process, the finally selected best hyperparameter combination will be used for the TCN network model, significantly reducing the time overhead in the model training process and enhancing the inference ability and generalization ability of the model.

[0120] 2. Compared with the traditional inverse kinematics algorithm, the time-domain convolutional network based on the self-attention mechanism proposed by the present invention can complete the inverse kinematics calculation task within a few milliseconds, while the traditional algorithm requires hundreds of milliseconds. This method shows great potential in the inverse kinematics calculation task of the robotic arm. First, the collected robotic arm data is preprocessed and converted into a format suitable for input to the TCN network. Then, the model learns the complex non-linear mapping relationship between the robotic arm pose data and the joint angle values by stacking a custom residual connection network and a self-attention mechanism module. In the residual network, in order to further improve the expression ability of the model, causal convolution and dilated convolution are introduced, and at the same time, module normalization and Dropout layers are combined to effectively prevent overfitting and enhance the learning ability of the model. Finally, the final predicted joint angle value is generated through the linear layer. This method significantly improves the accuracy and calculation efficiency of the inverse kinematics calculation of the robotic arm by combining advanced network structures and optimization techniques. Description of the Drawings

[0121] Figure 1 This is the social structure diagram of the wolf pack in the present invention;

[0122] Figure 2 This is the hunting distribution map of the wolf pack in the present invention;

[0123] Figure 3 This is the flow chart of the grey wolf algorithm in the present invention;

[0124] Figure 4 This is the structural diagram of the attention time-domain convolutional network model in the present invention;

[0125] Figure 5 This is the causal convolution structure diagram in the present invention;

[0126] Figure 6 This is the dilated convolution structure diagram in the present invention;

[0127] Figure 7 This is the schematic diagram of the MSE performance of the GWO proposed in the present invention on the robotic arm dataset;

[0128] Figure 8(a) is a comparison diagram of the predicted value and the true value of the first joint angle value of the present invention on the robotic arm dataset;

[0129] Figure 8(b) is a comparison diagram of the predicted value and the true value of the second joint angle value of the present invention on the robotic arm dataset;

[0130] Figure 8(c) is a comparison diagram of the predicted value and the true value of the third joint angle value of the present invention on the robotic arm dataset;

[0131] Figure 8(d) is a comparison diagram of the predicted value and the true value of the fourth joint angle value of the present invention on the robotic arm dataset;

[0132] Figure 8(e) is a comparison diagram of the predicted value and the true value of the fifth joint angle value of the present invention on the robotic arm dataset;

[0133] Figure 8(f) is a comparison diagram of the predicted value and the true value of the sixth joint angle value of the present invention on the robotic arm dataset. Detailed implementation manners

[0134] The present invention will be further described below through embodiments in conjunction with the accompanying drawings, but is not limited thereto.

[0135] Embodiment 1

[0136] A method for solving the inverse kinematics of a robotic arm based on the grey wolf optimization algorithm and the attention time-domain convolutional network, comprising:

[0137] Step 1: Construct an attention time-domain convolutional network model (TCN), and input the collected robotic arm data into the attention time-domain convolutional network model for training;

[0138] During the training process, the hyperparameters of the attention time-domain convolutional network model are intelligently tuned to obtain the optimal hyperparameter combination, thereby improving the inference and expression ability of the model, enabling it to more efficiently and accurately complete the inverse kinematics solution of the robotic arm, that is, the joint angle prediction task, and obtaining the trained attention time-domain convolutional network model;

[0139] The attention time-domain convolutional network model includes a time-domain convolutional network, a self-attention mechanism, and a linear layer linear;

[0140] The time-domain convolutional network includes residual blocks to extract local features; the self-attention mechanism extracts global features; combining the time-domain convolutional network and the self-attention mechanism enables the network to pay more attention to the parts that have a greater impact on the output, thereby enhancing the ability to capture key data; obtaining the attention time-domain convolutional network model; the linear layer linear performs feature output;

[0141] Step 2: Use the trained attention time-domain convolutional network model to predict the joint angle values of the robotic arm. The robotic arm data is input into the stacked residual blocks in the time-domain convolutional network (the number of stacked residual blocks is determined by the hyperparameter nb_stacks. In the hyperparameter combination finally obtained through the grey wolf optimization algorithm, the residual blocks are stacked 3 layers). Each residual block internally extracts features through dilated causal convolutional layers, and uses the self-attention mechanism to extract global features, enabling the network to pay more attention to the parts that have a greater impact on the output, thereby enhancing the ability to capture key data and further improving the inference speed; combining the local features extracted by the time-domain convolutional network with the global features of the self-attention mechanism enables the model to not only focus on local patterns during learning, but also understand the context of the entire signal, and accurately grasp the robotic arm data; finally, through the linear layer Linear, obtain output, that is, the joint angle value.

[0142] Embodiment 2

[0143] A method for inverse kinematics solution of a robotic arm based on the grey wolf optimization algorithm and the attention time-domain convolutional network according to Embodiment 1, wherein:

[0144] Construct an attention time-domain convolutional network model (TCN); including:

[0145] In the attention time-domain convolutional network model, the time-domain convolutional network includes residual blocks to replace the traditional single-layer convolutional structure. A self-attention mechanism is introduced between every two residual blocks. Each residual block includes 5 dilated causal convolutional layers, where the dilation rates of the dilated causal convolutional layers are 1, 2, 4, 8, and 16 respectively, and a non-linear activation function ReLU, WeightNorm, and Dropout mechanism are introduced in each layer to regularize the network, prevent overfitting, and improve the generalization ability of the model;

[0146] The dilated causal convolutional layer includes causal convolution and dilated convolution for local feature extraction.

[0147] The collected robotic arm data is input into the attention time-domain convolutional network model for training, including:

[0148] Collect the pose data (x, y, z, rx, ry, rz) of the robotic arm, where x, y, z are the coordinates of the end effector in the robotic arm coordinate system, and rx, ry, rz are the poses of the end effector, i.e., the angles with the three coordinate axes, and the joint angle value data (j1, j2, j3, j4, j5, j6), where j1, j2, j3, j4, j5, j6 are the rotation angle values of the 6 joints of the robotic arm relative to the initial position, save them in a.CSV file, and divide the data into a training set, a validation set, and a test set.

[0149] The pose data of the robotic arm is first normalized through Reshape and transformed into the form of (batch_size, timesteps, input_dim), and then input into the attention time-domain convolutional network model for training. Among them, batch_size represents the number of training samples processed by the attention time-domain convolutional network model in one iteration, timesteps represents the time step (i.e., the length of the sequence), which is used to indicate how many previous groups of data are used to predict the current joint angle value. Since the robotic arm pose and the joint angle are in one-to-one correspondence, it is 1 here, and input_dim represents the feature dimension of each time step, that is, at each time point, the dimension of the input data. Since the input is the pose, it is 6 here.

[0150] In the time-domain convolutional network, feature extraction is performed through the dilated causal convolutional layer inside the residual block, including:

[0151] The dilated causal convolutional layer includes causal convolution (Causal Convolution) and dilated convolution (Dilated Convolution).

[0152] When dealing with time series problems, traditional CNN models usually cannot be directly used for time series data because they cannot effectively handle the temporal dependence of the data. To solve this problem, the concept of causal convolution (Causal Convolution) is proposed, aiming to ensure the causal relationship of the time series, that is, the output of the current time step only depends on the current and previous input data.

[0153] Causal convolution, for the value at time step t of the previous layer, only depends on the values at time step t and before of the next layer; different from traditional convolutional neural networks, causal convolution cannot see future data, it is a unidirectional structure, not bidirectional, and is a strict time-constrained model;

[0154] For a time series problem, it is transformed into: based on the input sequence X = (x1, x2, …, x t ), predict the output sequence Y = (y1, y2, …, y t ); in this process, the filter F = (f1, f2,..., f k ) is applied to the input sequence to generate the corresponding output;

[0155] In causal convolution, the input sequence at time step t is X = (x1, x2, …, x t ), that is, the manipulator pose data. The filter F (convolution kernel) is of a fixed size, defined as F = (f1, f2,..., f k ), then the causal convolution operation at time step t is:

[0156]

[0157] where K represents the size of the filter (convolution kernel) F, k represents the index within the filter, used to traverse each element in the convolution kernel, f k represents the k-th weight parameter of the filter F, that is, the parameter value at each position in the convolution kernel, x t represents the value of the input sequence at time step t, that is, the input data at the current moment; (F * X) (t) represents the causal convolution output value at time step t;

[0158] The causal convolution operation ensures that the output at each time step only depends on the current and previous input data, without leaking future information; the last two nodes of the input sequence are x t-1 and x t , and the last node of the first hidden layer, that is, the network layer where the first causal convolution calculation is performed, is y t , then the filter F1 = (f1, f2) will be applied to the input sequence, and the calculation is:

[0159] y t = f1x t-1 + f2x t ;

[0160] where f1 represents the influence weight of the convolution kernel on the data x t-1 at the previous time step, and f2 represents the influence weight of the convolution kernel on the data x t at the current time step;

[0161] Although simple causal convolution can effectively model time series, there are still some problems with traditional CNNs. In particular, the length of the modeling of time-dependent relationships is limited by the size of the convolutional kernel. If we want to capture dependencies over a longer time span, we often need to stack multiple convolutional layers linearly, which increases the computational complexity. Traditional CNNs usually expand the receptive field by adding a pooling layer, but the pooling operation inevitably loses some information while expanding the receptive field.

[0162] Dilated convolution increases the receptive field by introducing a dilation rate in the standard convolution operation, avoiding the information loss problem caused by the pooling operation. Dilated convolution introduces a hyperparameter, namely the dilation rate, to control the spacing of the convolutional kernel. The dilation rate determines the spacing between the elements in the convolutional kernel. In a standard convolutional neural network, the default value of the dilation rate is 1, indicating no spacing. In dilated convolution, when the dilation rate is greater than 1, the receptive field of the convolutional kernel is effectively expanded without losing information.

[0163] Dilated convolution introduces the dilation rate on the basis of causal convolution, maintaining causality while expanding the receptive field. For the filter F=(f1, f2,..., f k ), and the input sequence X=(x1, x2,…, x t ), the dilated convolution at position x t with a dilation rate of d is:

[0164]

[0165] where d represents the dilation rate, which is used to control the spacing between input data points, and (F*X) (xt) represents the output value of the dilated convolution at time step t;

[0166] In the residual block, after the robotic arm pose data is calculated by dilated convolution and causal convolution, it passes through the WeightNorm layer, the non-linear activation function ReLU layer, and the Dropout layer in sequence to obtain local features.

[0167] The self-attention mechanism is introduced between every two residual blocks to extract global features, including:

[0168] The Self-Attention Mechanism is a mechanism that can enhance the model's ability to understand the context of input information by modeling the relationships between different parts of the input data. The core idea of the self-attention mechanism is that given an input sequence, the representation of each position not only depends on the information of that position itself, but also enhances its own representation by paying attention (attending) to the information of other positions in the input sequence. This process is achieved by calculating the attention weights for each position. The process of the self-attention mechanism includes the following steps:

[0169] Input Representation: Each element of the input sequence is mapped to a vector space of a fixed dimension;

[0170] Calculate Attention Weights: For each element in the input sequence, first calculate the relationship between this element and all other elements, and then obtain the attention weight of this element. The attention weight represents the degree of attention of each element to other elements;

[0171] Weighted Sum: Weighted sum the input elements according to the attention weights to obtain a new representation of this element;

[0172] Output Representation: Through the new representation obtained by weighted sum, each element of the output sequence carries the information of all other elements in the input sequence;

[0173] The input sequence is X = (x1, x2, …, x t ), where x i is the representation vector of the i-th element in the input sequence, with a length of n;

[0174] First, calculate the query (Query), key (Key), and value (Value) vectors. For each element x i of the input, obtain the query vector q i , key vector k i , and value vector v i through different linear transformations. These vectors are used to calculate the attention weights, and the formula is as follows:

[0175] q i = W Q x i ;

[0176] k i = W K x i ;

[0177] vi = W V x i ;

[0178] Among them, W Q , W K , W V are the weight matrices of query, key, and value obtained through learning respectively;

[0179] Then calculate the attention weights. For the query vector q i and the key vector k j , calculate the dot product of q i and k j to obtain the correlation score (also called the attention score), and perform scaling. The formula is as follows:

[0180]

[0181] Among them, d k is the dimension of the key vector, which plays a role in scaling to avoid the vanishing gradient caused by too large dot product value; then for each query vector q i , normalize the attention scores of all keys through the softmax function to obtain the attention weights at each position:

[0182]

[0183] Among them, a ij is the attention weight of the input element x i for the element x j ;

[0184] Finally, use the obtained attention weights a ij to perform weighted summation on the value vector v j to obtain the output representation at each position:

[0185]

[0186] Among them, z i is the final representation of the i-th position in the input sequence, that is, the context information representation calculated based on the current query position i.

[0187] During the training process, intelligently optimize the hyperparameters of the attention time-domain convolutional network model to obtain the best combination of hyperparameters, so that it can complete the inverse kinematics solution task of the robotic arm more efficiently and accurately; including:

[0188] (1) Initialize the gray wolf population and a, A, and C;

[0189] Initialize the number of wolves wolf_num, which is the number of groups of hyperparameter combinations searched in each iteration; the maximum number of iterations max_iter, which is the number of rounds of search iteration; the dimension dim, which is the number of hyperparameters; the hunting range of the wolf pack Lb, ub, which is the search range of hyperparameters; the initialization of the alpha wolf initial_alpha_pos, which is whether to provide the initial hyperparameter combination; alpha_pos, beta_pos, and delta_pos are the positions of the alpha, beta, and delta wolves respectively; alpha_score, beta_score, and delta_score are the fitness values of the alpha, beta, and delta wolves respectively.

[0190] Among them, each wolf in the gray wolf population represents a group of hyperparameter combinations, that is, the number of convolution operations nb_filters, the number of convolution kernels kernel_size, the number of residual blocks nb_stacks, the dropout rate dropout_rate, the learning rate learning_rate, and the training batch size batch_size in the attention time-domain convolutional network model.

[0191] a is a linearly decreasing coefficient that controls convergence (gradually decreasing from 2 to 0). By gradually linearly reducing the value of a, the fluctuation range of A also decreases linearly, thereby simulating the behavior of the wolf pack approaching the prey (the prey refers to the best hyperparameter combination).

[0192] C is a random value between [0, 2], which represents the random weight of the position of the wolf on the prey, that is, the best hyperparameter combination. Since the value of C is a random value, it is used to prevent the algorithm from being unable to get rid of the local optimum during optimization, and plays a very important role in searching for the global optimum, that is, the best hyperparameter combination, enhancing the global search ability, robustness, and convergence of the algorithm; A is a random coefficient used to adjust the search direction and exploration ability of the wolf pack.

[0193] (2) Calculate the fitness of the gray wolf individuals and save the top three wolves with the best fitness, alpha, beta, and delta.

[0194] The fitness of the gray wolf individual represents the training loss obtained by training each group of hyperparameters, that is, val_loss.

[0195] The alpha, beta, and delta wolves represent the first, second, and third optimal solutions, that is, hyperparameter combinations, which are determined by val_loss, that is, the loss on the validation set.

[0196] (3) Update the position of the current gray wolf.

[0197] The position of the gray wolf represents the hyperparameter combination, that is, position = (hyperparameter combination).

[0198] The position update formula of the alpha wolf:

[0199]

[0200] Position update formula for β wolf:

[0201]

[0202] Position update formula for δ wolf:

[0203]

[0204] Wherein, respectively represent the positions of α wolf, β wolf, and δ wolf; represents the position of the wolves in the previous generation; A1, A2, and A3 are random coefficients, namely random coefficient A, used to adjust the search direction and exploration ability of the wolf pack; D1, D2, and D3 are the distances between the prey and the wolves, and the calculation method is:

[0205]

[0206] Wherein, is the best position in the current group, represents the position vector of the current individual i, that is, the current solution of this individual in the search space, C i is a coefficient used to balance the change of the search range;

[0207] The wolf pack adjusts its own position according to the positions of α, β, and δ wolves, as shown in the following formula:

[0208] Da = ∣C1·X α - X∣;

[0209] D β = ∣C2·X β - X∣;

[0210] D δ = ∣C3·X δ - X∣;

[0211] X1 = X α - A1·D α ;

[0212] X2 = X β - A2·D β ;

[0213] X3 = X δ - A3·D δ ;

[0214]

[0215] Where X represents the position of the current grey wolf (the position in the previous iteration, the position before this update), C1, C2, and C3 represent random values between [0, 2], and X α , X β , X δ represent the positions of the α, β, and δ wolves respectively. Da, D β , and D δ represent the distances between the current grey wolf and the α, β, and δ wolves respectively. X1, X2, and X3 represent the candidate positions obtained after the current grey wolf is updated according to the positions of the α, β, and δ wolves, and X new represents the new position of the current grey wolf after update;

[0216] (4) Update a, A, and C, and the formulas are as follows:

[0217] A = 2a·r - a;

[0218] C = 2·r;

[0219] where r represents a random vector, C is a random value between [0, 2], and a is a linear decreasing coefficient that controls convergence;

[0220] (5) Calculate the fitness of all grey wolves, that is, the training loss val_loss obtained by training the hyperparameters;

[0221] (6) Update the positions of the α, β, and δ wolves;

[0222] Compare the existing wolf pack, and select the three with the lowest training loss val_loss as the α, β, and δ wolves respectively;

[0223] (7) Determine whether the maximum number of iterations has been reached. If not, execute step (3). If so, output the position of the final α wolf, that is, the optimal hyperparameter combination;

[0224] Repeat the above training and update steps until the predetermined number of iterations max_iter is reached. The output optimal hyperparameter combination is used to finally train the attention time-domain convolutional network model to obtain the trained attention time-domain convolutional network model.

[0225] The training losses obtained by training each group of hyperparameters include:

[0226] Determine the search range of the wolf pack by providing an initial combination of hyperparameters initial_alpha_pos; first, train using the initial combination of hyperparameters and compare the training results with those obtained by training with a randomly generated combination of alpha-wolf hyperparameters to select the initial combination of hyperparameters; to evaluate the quality of the hyperparameters, use the mean squared error MSE (Mean Squared Error) as the evaluation criterion, that is, calculate the loss val_loss of the validation set using the mean squared error; MSE is a commonly used evaluation metric for regression problems, which calculates the average of the squares of the errors between the predicted values and the actual values; the formula is:

[0227]

[0228] where: y i is the true value, y i ′ is the predicted value, and n is the number of data points; the smaller the value of MSE, the higher the prediction accuracy of the model and the smaller the error;

[0229] Perform max_iter iterations. In each iteration of the Grey Wolf Optimization algorithm (for example, if the number of wolves wolf_num is set to 30, then in one iteration, all 30 combinations of hyperparameters are trained, and after all 30 are trained, a position update is performed, that is, the best 3 wolves are found, and then the position of each wolf in the next iteration is updated using the above position update formula), each wolf in the population, that is, each combination of hyperparameters, is trained, and the score of the current wolf, that is, the best combination of hyperparameters determined by the loss on the validation set, is recorded; subsequently, update the positions of the alpha, beta, and delta wolves according to the scores, and record the score of the alpha wolf in this generation. After completing this process, enter the next iteration; to save excessive unnecessary time overhead that may occur during training, the ReduceLROnPlateau and EarlyStopping mechanisms are introduced during training, aiming to control the training duration and avoid overfitting, thereby improving the efficiency of model training.

[0230] The Grey Wolf Optimization (GWO) algorithm is a heuristic optimization algorithm that simulates the behavior of a grey wolf pack. This algorithm is based on the social structure and hunting behavior of grey wolves and conducts global search by simulating the interaction between the leadership (alpha, beta, delta) wolves and followers in the grey wolf pack, aiming to solve complex optimization problems. The basic idea of the Grey Wolf Optimization algorithm is to simulate the leadership and cooperation behaviors demonstrated by grey wolf packs during the hunting process. Grey wolves work together to find the location of the prey, thereby solving optimization problems. The population in GWO consists of 4 types of wolves: alpha wolves, beta wolves, delta wolves, and omega wolves. Each wolf has a different role and position in the population, which determines its role in the search process. Its social structure is as Figure 1 shown;

[0231] In GWO, the social structure of gray wolves is divided into the following types from top to bottom:

[0232] α wolf: The leader, responsible for guiding the search direction of the entire group, usually the individual with the best fitness.

[0233] β wolf: The second-level leader, assists α wolf in searching and transmits information to the group through certain strategies.

[0234] δ Wolf: The third-level leader, relying on the guidance of α and β wolves, assists the group in optimizing the objective function.

[0235] ω Wolf: Follower, at the lowest level in the group, whose task is to follow other wolves in the group and adjust their behavior according to their position.

[0236] In the gray wolf optimization algorithm, α wolf, β wolf and δ wolf cooperate with each other to search for the optimal solution, while ω wolf optimizes its position in the search space by imitating the behavior of the previous ones. GWO searches by simulating the hunting strategy of gray wolves. Each wolf adjusts its position to approach the best position (optimal solution) in the current group. The hunting process is divided into the following steps:

[0237] Tracking prey: Each wolf in the wolf pack approaches the prey by updating its own position (optimal solution).

[0238] Besieging prey: The wolves form a circle, constantly adjusting their positions and approaching the prey until they find the prey's location (optimal solution).

[0239] Surrounding prey: By constantly updating their position, the wolves eventually find their prey and optimize their goal.

[0240] Figure 2 It shows how ω wolf or other wolves (candidate wolves) update their positions according to α, β, δ wolves in the two-dimensional search space. It can be seen that the final position will be a random position within the circle defined by the positions of α, β, δ wolves in the search space. That is, α, β, δ wolves estimate the position of the prey, and other wolves randomly update their positions around the prey.

[0241] In order to demonstrate the superiority of the method of the present invention, the present invention tested the model proposed by the present invention by collecting robot arm data on the jakaminicobo robot arm. The data set involved in the present invention includes more than 20,000 sets of robot arm posture and joint angle data.

[0242] exist Figure 7It can be seen that as the Grey Wolf Algorithm iterates, the value of the mean squared error (MSE) on the validation set gradually stabilizes from the initial fluctuations. The initial MSE value fluctuates greatly, indicating that in the optimization process, the initial setting of the hyperparameters is not ideal, resulting in large errors in the model's prediction results. As the Grey Wolf Algorithm continues to iterate, the model gradually approaches the optimal solution by optimizing the hyperparameters, the MSE value gradually decreases, and finally stabilizes. This change shows that as the algorithm iterates, the adjustment of the hyperparameters enables the model to gradually find the best parameter combination that adapts to the data during the training process. Thus, it can be concluded that the Grey Wolf hyperparameter optimization algorithm adopted has strong global search ability during the optimization process, can effectively adjust each parameter of the network structure and the hyperparameters during the training process, thereby improving the model performance. Guided by the Grey Wolf Algorithm, the training process of the model becomes more efficient, can achieve a higher accuracy in a shorter time, and the optimization process is more stable, avoiding problems such as improper parameter selection, overfitting, or slow convergence that may occur during traditional manual parameter tuning.

[0243] Figure 8 shows the comparison between the joint angle values predicted by the network model of the present invention and the true joint angle values on the test set, where True represents the true value and Predicted represents the predicted value. The figure lists the comparison of the angle prediction results and the actual data of 6 joints respectively, and each joint angle shows the first 15 groups of data. By observing these results, it can be seen that the model performs excellently in the inverse kinematics solution of the robotic arm, can accurately predict the angles of each joint, and meets the requirements in different task scenarios. Table 1 shows the performance of the model under multiple evaluation indexes, as shown in the following table:

[0244] Table 1

[0245] Model <![CDATA[R 2 > MAPE(%) MAE MSE RMSE Prediction Time(s) GWOATTCN 0.96754 9.455514 0.008288 0.000114 0.01068 0.007791

[0246] Among them, R 2It is an index used to measure the goodness of fit of a regression model, indicating the closeness of the relationship between the predicted values and the true values of the model; MAE is another commonly used evaluation index for regression models, which calculates the average of the absolute values of the errors between the predicted values and the true values; MAPE is an index for measuring the prediction errors of a regression model, which reflects the accuracy of the model prediction by calculating the average of the relative errors between the predicted values and the actual values; RMSE is the square root of MSE, which can maintain the same unit as the original data; Prediction Time represents the test time and is an important index for measuring the computational efficiency of a regression model during the prediction process; The model has significant advantages in the balance between the inverse solution accuracy and the computational speed. The model not only ensures the basic inverse solution accuracy but also can complete an inverse solution operation within 7 ms. This performance is significantly better than the traditional inverse kinematics solution algorithms for robotic arms, which usually require hundreds of milliseconds of computational time. In those practical application scenarios with extremely high real-time requirements, such as embodied intelligence and human-computer interaction, the fast response and high-precision characteristics of the model demonstrate great potential and can meet the requirements for fast and precise operation of robotic arms in these fields.

[0247] Embodiment 3

[0248] A computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the inverse kinematics solution method for a robotic arm based on the grey wolf optimization algorithm and the attention time-domain convolutional network described in Embodiment 1 or 2.

[0249] Embodiment 4

[0250] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps of the inverse kinematics solution method for a robotic arm based on the grey wolf optimization algorithm and the attention time-domain convolutional network described in Embodiment 1 or 2.

[0251] Embodiment 5

[0252] An inverse kinematics solution system for a robotic arm based on the grey wolf optimization algorithm and the attention time-domain convolutional network includes:

[0253] A model training module, configured to: construct an attention time-domain convolutional network model, and input the collected robotic arm data into the attention time-domain convolutional network model for training;

[0254] During the training process, perform intelligent tuning on the hyperparameters of the attention time-domain convolutional network model to obtain the best combination of hyperparameters, and obtain the trained attention time-domain convolutional network model;

[0255] The attention time-domain convolutional network model includes a time-domain convolutional network, a self-attention mechanism, and a linear layer linear;

[0256] The time-domain convolutional network includes residual blocks to extract local features; a self-attention mechanism to extract global features; combines the time-domain convolutional network and the self-attention mechanism to obtain an attention time-domain convolutional network model; and a linear layer "linear" for feature output.

[0257] A model prediction module, configured to: use the trained attention time-domain convolutional network model to predict the robotic arm joint angle value, including:

[0258] The robotic arm data is input into the stacked residual blocks in the time-domain convolutional network, feature extraction is performed through a dilated causal convolutional layer, and the global features are extracted using the self-attention mechanism. The local features extracted by the time-domain convolutional network are combined with the global features of the self-attention mechanism; finally, through the linear layer "Linear", the output, that is, the joint angle value, is obtained.

Claims

1. A method for solving inverse kinematics of a robotic arm based on the gray wolf optimization algorithm and the attention time domain convolutional network, characterized in that: include: Step 1: Build an attention time domain convolutional network model and input the collected robotic arm data into the attention time domain convolutional network model for training; During the training process, the hyperparameters of the attention time domain convolutional network model are intelligently tuned to obtain the best hyperparameter combination and obtain the trained attention time domain convolutional network model; The attention temporal convolutional network model includes a temporal convolutional network, a self-attention mechanism, and a linear layer; The temporal convolutional network includes residual blocks to extract local features; The self-attention mechanism extracts global features; the time domain convolutional network and the self-attention mechanism are combined to obtain the attention time domain convolutional network model; the linear layer outputs features; Step 2: Use the trained attention time-domain convolutional network model to predict the joint angle value of the robot arm, including inputting the robot arm data into the stacked residual blocks in the time-domain convolutional network, extracting features through the dilated causal convolutional layer, and using the self-attention mechanism to extract global features, combining the local features extracted by the time-domain convolutional network with the global features of the self-attention mechanism; finally, through the linear layer Linear, the output, i.e. the joint angle value, is obtained.

2. According to claim 1, a method for solving inverse kinematics of a robotic arm based on the gray wolf optimization algorithm and the attention time domain convolutional network is characterized in that: Construct an attention temporal convolutional network model; including: In the attention temporal convolutional network model, the temporal convolutional network includes residual blocks. A self-attention mechanism is introduced between every two residual blocks. Each residual block includes multiple layers of dilated causal convolutional layers, and nonlinear activation functions ReLU, WeightNorm and Dropout mechanisms are introduced in each layer to regularize the network. The dilated causal convolution layer includes causal convolution and dilated convolution to perform local feature extraction.

3. According to claim 1, a method for solving inverse kinematics of a robotic arm based on the gray wolf optimization algorithm and the attention time domain convolutional network is characterized in that: Input the collected robotic arm data into the attention time domain convolutional network model for training; including: Collect the posture data and joint angle value data of the robot arm, and divide the data into training set, verification set and test set; The posture data of the robotic arm is first normalized and converted into the form of (batch_size, timesteps, input_dim), and then input into the attention time domain convolutional network model for training; where batch_size represents the number of training samples processed by the attention time domain convolutional network model in one iteration, timesteps represents the time step, and input_dim represents the feature dimension of each time step.

4. According to claim 2, a method for solving inverse kinematics of a robotic arm based on the gray wolf optimization algorithm and the attention time domain convolutional network is characterized in that: The residual block in the time domain convolutional network performs feature extraction through the dilated causal convolution layer; including: The dilated causal convolution layer includes causal convolution and dilated convolution; In causal convolution, the input sequence at time t is X = (x1, x2, ..., x t ) is the robot arm posture data, the filter F is of fixed size and is defined as F = (f1, f2, ..., f k ), then the causal convolution operation at time step t is: Among them, K represents the size of the filter F, k represents the index within the filter, which is used to traverse each element in the convolution kernel, and f k represents the kth weight parameter of the filter F, that is, the parameter value at each position in the convolution kernel, x t Represents the value of the input sequence at time step t, that is, the input data at the current moment; (F*X) (t) Represents the causal convolution output value at time step t; The last two nodes of the input sequence are x t-1 and x t , the last node of the first hidden layer, i.e. the first causal convolution calculation, is y t , then the filter F1 = (f1, f2) will be applied to the input sequence, and the calculation is: and t =f1x t-1 +f2x t ; Among them, f1 represents the convolution kernel of the previous time step data x t-1 The influence weight of f2 represents the influence of the convolution kernel on the current time step data x t The weight of influence; The dilation convolution introduces the dilation rate. For the filter F = (f1, f2, ..., f k ), input sequence X = (x1, x2, …, x t ), in x t The dilated convolution with a dilation rate of d at is: Where d represents the expansion rate, which is used to control the interval between input data points. represents the output value of the dilated convolution at time step t; In the residual block, the robot arm posture data is calculated through dilated convolution and causal convolution, and then passes through the WeightNorm layer, the nonlinear activation function ReLU layer and the Dropout layer to obtain local features.

5. According to claim 2, a method for solving inverse kinematics of a robotic arm based on the gray wolf optimization algorithm and the attention time domain convolutional network is characterized in that: A self-attention mechanism is introduced between every two residual blocks to extract global features; including: The input sequence is X=(x1,x2,…,x t ), where x i is the representation vector of the i-th element in the input sequence, with a length of n; First, we compute the query, key, and value vectors, for each element of the input x i , the query vector q is obtained through different linear transformations i , key vector k i Sum value vector v i , the formula is as follows: q i =W Q x i ; k i =W K x i ; v i =W V x i ; Among them, W Q , W K , W V They are the weight matrices of query, key, and value obtained through learning; Then, the attention weight is calculated for the query vector q i and key vector k j , by calculating q i and k j The dot product of gets the correlation score and scales it. The formula is as follows: Among them, q k is the dimension of the key vector, which plays a scaling role; then for each query vector q i , normalize the attention scores of all keys through the softmax function to get the attention weight of each position: Among them, a ij is the input element x i For element x j The attention weight of Finally, use the obtained attention weight a ij The value vector v j Perform weighted summation to obtain the output representation of each position: Among them, z i It is the final representation of the i-th position in the input sequence, that is, the context information representation calculated based on the current query position i.

6. According to claim 1, a method for solving inverse kinematics of a robotic arm based on the gray wolf optimization algorithm and the attention time domain convolutional network is characterized in that: During the training process, the hyperparameters of the attention temporal convolutional network model are intelligently tuned to obtain the best hyperparameter combination; include: (1) Initialize the gray wolf population and a, A, and C; Initialize the number of wolves, that is, the number of hyperparameter combinations to search for each iteration; the maximum number of iterations, that is, the number of rounds of search iterations; the dimension, that is, the number of hyperparameters; the hunting range of the wolf pack, that is, the search range of the hyperparameters; α wolf initialization, that is, whether to provide an initial hyperparameter combination; the positions of α, β, and δ wolves; the fitness values ​​of α, β, and δ wolves; Among them, each wolf in the gray wolf population represents a set of hyperparameter combinations, namely the number of convolution operations, the number of convolution kernels, the number of residual blocks, the ratio of discarded layers, the learning rate, and the training batch in the attention time domain convolutional network model; a is the linear reduction coefficient that controls convergence. By gradually reducing the a value linearly, the fluctuation range of A also decreases linearly; C is a random value between [0, 2], which represents the random weight of the influence of the wolf's location on the prey, i.e., the optimal hyperparameter combination; A is a random coefficient, which is used to adjust the search direction and exploration ability of the wolf pack; (2) Calculate the fitness of individual gray wolves and save the top three wolves with the best fitness: α, β, and δ; The fitness of the individual gray wolf represents the training loss obtained by training each set of hyperparameters; α, β, and δ represent the first, second, and third best solutions, i.e., the hyperparameter combinations, which are determined by the loss on the validation set; (3) Update the current position of the gray wolf; The position of the gray wolf indicates the hyperparameter combination; The position update formula of α wolf is: The position update formula of β wolf is: Delta wolf position update formula: in, They represent the positions of α wolf, β wolf, and δ wolf respectively; Indicates the positions of α, β, and δ wolves in the previous generation; A1, A2, and A3 are random coefficients, namely random coefficient A, which is used to adjust the search direction and exploration ability of the wolf pack; D1, D2, and D3 are the distances between the prey and the wolf, calculated as follows: in, It is the best position in the current group. represents the position vector of the current individual i, that is, the current solution of the individual in the search space, C i is a coefficient used to balance the change of the search range; The wolf pack adjusts its position according to the positions of α, β, and δ wolves, as shown in the following formula: Da=∣C1·X α -X∣; D β =∣C2·X β -X∣; D δ =∣C3·X δ -X∣; X1=X α -A1·D α ; X2=X β -A2·D β ; X3=X δ -A3·D δ ; Among them, X represents the current position of the gray wolf, C1, C2, and C3 represent random values ​​between [0, 2], and X α , X β , X δ Respectively represent the positions of α, β, and δ wolves, Da, D β , D δ They represent the distances between the current gray wolf and α, β, and δ wolves respectively. X1, X2, and X3 represent the candidate positions of the current gray wolf after updating according to the positions of α, β, and δ wolves respectively. new Indicates the new position of the current gray wolf after update; (4) Update a, A and C. The formula is as follows: A = 2a·ra; C=2·r; Where r represents a random vector, C is a random value between [0, 2], and a is a linear reduction coefficient that controls convergence; (5) Calculate the fitness of all gray wolves, that is, the training loss obtained by training the hyperparameters; (6) Update the positions of wolves α, β, and δ; Compare the existing wolf packs and select the three with the lowest training losses, namely α, β, and δ wolves; (7) Determine whether the maximum number of iterations has been reached. If not, execute step (3). If reached, output the final position of the α wolf, i.e., the best hyperparameter combination; Repeat the above training and updating steps until the predetermined number of iterations is reached, and the output optimal hyperparameter combination is used to perform final training on the attention time domain convolutional network model to obtain a trained attention time domain convolutional network model.

7. According to claim 6, a method for solving inverse kinematics of a robotic arm based on the gray wolf optimization algorithm and the attention time domain convolutional network is characterized in that: The training loss obtained by training each set of hyperparameters includes: The search range of the wolf pack is determined by providing an initial hyperparameter combination. First, the initial hyperparameter combination is used for training, and the training results are compared with the results obtained by training with the randomly generated α wolf hyperparameter combination to select the initial hyperparameter combination. The mean square error MSE is used as the judgment criterion, that is, the loss of the validation set is calculated using the mean square error. The average value of the square of the error between the predicted value and the actual value is calculated. The formula is: Where: y i is the true value, y′ i is the predicted value, n is the number of data points; the smaller the MSE value, the higher the prediction accuracy of the model and the smaller the error; In each iteration of the gray wolf algorithm, each wolf in the group, that is, each hyperparameter combination, is trained, and the score of the current wolf, that is, the best hyperparameter combination determined by the loss on the validation set, is recorded; then, the positions of the α, β, and δ wolves are updated according to the scores, and the score of the α wolf in this generation is recorded. After completing this process, the next iteration begins.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the inverse kinematics solution method of a robotic arm based on the gray wolf optimization algorithm and the attention time domain convolutional network described in any one of claims 1-7 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the inverse kinematics solution method of a robotic arm based on the gray wolf optimization algorithm and the attention time domain convolutional network described in any one of claims 1-7 are implemented.

10. A robot arm inverse kinematics solution system based on the gray wolf optimization algorithm and the attention time domain convolutional network, characterized in that: include: The model training module is configured to: construct an attention time domain convolutional network model, and input the collected robotic arm data into the attention time domain convolutional network model for training; During the training process, the hyperparameters of the attention time domain convolutional network model are intelligently tuned to obtain the best hyperparameter combination and obtain the trained attention time domain convolutional network model; The attention temporal convolutional network model includes a temporal convolutional network, a self-attention mechanism, and a linear layer; The temporal convolutional network includes residual blocks to extract local features; The self-attention mechanism extracts global features; the time domain convolutional network and the self-attention mechanism are combined to obtain the attention time domain convolutional network model; the linear layer outputs features; The model prediction module is configured to use the trained attention temporal convolutional network model to predict the joint angle value of the robot arm, including: The robot arm data is input into the stacked residual blocks in the time domain convolutional network, and feature extraction is performed through the dilated causal convolutional layer. The self-attention mechanism is used to extract global features, and the local features extracted by the time domain convolutional network are combined with the global features of the self-attention mechanism. Finally, the output, i.e. the joint angle value, is obtained through the linear layer.