Adaptive adjustment method and system of parallel robots based on attention mechanism
By constructing an adaptive adjustment method based on attention mechanism in a hexapod parallel robot, using SeNet-Transformer action network and PPO reinforcement learning to dynamically adjust the PID parameters, solving the strong coupling dynamics and real-time bottlenecks in the motion control of the hexapod parallel robot, and achieving high-precision and fast response adaptive adjustment.
Patent Information
- Application Number
- CN202510947213.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-10
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2045-07-10
AI Technical Summary
The motion control of the hexapod parallel robot faces strong coupling dynamics and real-time bottlenecks, and traditional PID control is difficult to cope with sudden load changes, resulting in high pose errors and long disturbance recovery time.
Adaptive adjustment method based on attention mechanism is adopted, by establishing a virtual model in the Gazebo simulation environment, collecting robot information data in real time, building a SeNet-Transformer action network model, combining PPO reinforcement learning and multi-head self-attention mechanism, the PID parameters are dynamically adjusted to achieve adaptive adjustment.
Significantly reduce the tracking error, improve the response speed of PID parameter adjustment, achieve position accuracy of ±0.1mm and steady-state error convergence time of 0.2 seconds, and improve control accuracy and stability.
Smart Images

Figure CN120447346B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of robot motion control, and in particular to a parallel robot adaptive adjustment method and system based on an attention mechanism. Background Art
[0002] Currently, hexapod parallel robots are widely used in scenarios such as aviation device assembly and aircraft skin drilling due to their high stiffness and multi-degree-of-freedom collaboration.
[0003] However, the motion control of hexapod parallel robots faces the following challenges:
[0004] (1) Strong coupling dynamics: The parallel structure of the legs leads to nonlinear coupling between joints. Traditional PID control parameters are fixed and it is difficult to cope with sudden load changes.
[0005] (2) Real-time bottleneck: The computational complexity of the analytical algorithm based on Newton iteration is high, making it difficult to meet the millisecond-level control closed-loop requirements. Traditional PID control in hexapod robots requires manual parameter tuning, resulting in posture errors as high as 3.2 mm and disturbance recovery times > 2 seconds. Summary of the Invention
[0006] The present invention provides an attention mechanism-based parallel robot adaptive adjustment method and system to overcome the above technical problems.
[0007] In order to achieve the above object, the technical solution of the present invention is:
[0008] A parallel robot adaptive adjustment method based on an attention mechanism specifically includes the following steps:
[0009] S1: Build a virtual model of the parallel robot's physical entity in the Gazebo simulation environment;
[0010] The Gazebo physics engine is used to simulate the dynamics of the virtual model's real environment to collect and acquire the parallel robot's information data in real time. The parallel robot's information data includes at least motor torque, joint angles, end-user pose, and load data.
[0011] S2: Define the PID controller framework model based on the parallel robot information data;
[0012] The state input of the PID controller framework model is the real-time trajectory error of the parallel robot, and the state output is the joint space control torque; the real-time trajectory error is the position error and speed error between the expected motion trajectory of the virtual model obtained based on the parallel robot information data and the actual motion trajectory.
[0013] And obtain the trajectory time series sample dataset of the parallel robot based on the real-time trajectory error and joint space control torque;
[0014] S3: Build a SeNet-Transformer action network model based on PPO reinforcement learning;
[0015] The SeNet-Transformer action network model includes a cascaded input layer, a feature extraction SeNet module, a Transformer encoder, and an output layer;
[0016] The input layer is used to perform dynamic symmetric error compensation on the real-time trajectory error sequence, obtain the real-time error compensation trajectory error sequence and input it into the feature extraction SeNet module; the feature extraction SeNet module is used to extract the spatiotemporal features of the data in the real-time error compensation trajectory error sequence; the Transformer encoder is used to process the spatiotemporal features of the data based on the multi-head self-attention mechanism, and combine the real-time trajectory error sequence to obtain the temporal dependency probability distribution of the parallel robot PID parameter adjustment; the output layer is used to predict and output the joint space control torque based on the temporal dependency probability distribution;
[0017] S4: The SeNet-Transformer action network model is trained based on the trajectory time series sample dataset to obtain the optimal parallel robot PID adaptive adjustment model. The PID adjustment parameters of the parallel robot are obtained based on the optimal parallel robot PID adaptive adjustment model to achieve PID adaptive adjustment of the parallel robot.
[0018] Furthermore, the Transformer encoder in S3 includes a cascaded first encoding unit and a second encoding unit;
[0019] The first encoding unit includes a first embedding layer, a first position encoding layer, a first multi-head attention layer, a first residual connection and normalization layer, a first feedforward neural network layer, and a second residual connection and normalization layer;
[0020] The first embedding layer is used to embed the real-time trajectory error sequence to obtain a trajectory error sequence vector; the first position encoding layer is used to perform position encoding on the trajectory error sequence vector to obtain a position encoding vector; the first multi-head attention layer is used to perform a multi-head attention operation on the position encoding vector to obtain a multi-head attention vector; the first residual connection and normalization layer is used to perform a residual connection on the position encoding vector and the multi-head attention vector, and then perform layer normalization processing; the first feedforward neural network layer is used to perform a feedforward mapping processing on the output of the first residual connection and normalization layer; the second residual connection and normalization layer is used to perform a residual connection on the output of the first feedforward neural network layer and the output of the first residual connection and normalization layer, and then perform layer normalization processing to obtain an intermediate vector;
[0021] The second encoding unit includes a second embedding layer, a second position encoding layer, a masked multi-head attention layer, a third residual connection and normalization layer, a second multi-head attention layer, a fourth residual connection and normalization layer, a second feedforward neural network layer, a fifth residual connection and normalization layer, a linear layer, and a soft max activation function layer;
[0022] The second embedding layer is used to embed the spatiotemporal features of the data to obtain the spatiotemporal feature vector of the data; the second position encoding layer is used to perform position encoding on the spatiotemporal feature vector of the data to obtain the feature encoding vector; the masked multi-head attention layer is used to perform masking on the feature encoding vector to obtain the feature mask vector; the third residual connection and normalization layer is used to perform residual connection on the feature mask vector and the feature encoding vector, and then perform layer normalization processing; the second multi-head attention layer is used to perform multi-head attention operation on the output of the third residual connection and normalization layer and the intermediate vector; the fourth residual connection and normalization layer is used to perform residual connection on the output of the second multi-head attention layer and the output of the third residual connection and normalization layer, and then perform layer normalization processing; the second feedforward neural network layer is used to perform feedforward mapping processing on the output of the fourth residual connection and normalization layer; the fifth residual connection and normalization layer is used to perform residual connection on the output of the second feedforward neural network layer and the output of the fourth residual connection and normalization layer, and then perform layer normalization processing; the linear layer is used to perform linear operation on the output of the fifth residual connection and normalization layer; soft The max activation function layer is used to activate the output of the linear layer and obtain the probability distribution of the temporal dependency of the PID parameter adjustment of the parallel robot.
[0023] Furthermore, the method for obtaining the optimal parallel robot PID adaptive adjustment model in S4 specifically includes the following steps:
[0024] S41: The position error and velocity error of the real-time trajectory error are used as feature data, the joint space control torque is used as label data, and the trajectory time series sample dataset is randomly divided into a training set and a validation set;
[0025] S42: Input the training set into the SeNet-Transformer action network model for model training, and obtain the trained SeNet-Transformer action network model;
[0026] S43: Construct a reward function based on PPO reinforcement learning, and use the reward function as the model loss function of the SeNet-Transformer action network model;
[0027] The trained SeNet-Transformer action network model is validated using the validation set, and the convergence of the output of the trained SeNet-Transformer action network model is determined based on the model loss function.
[0028] If the output of the trained SeNet-Transformer action network model is confirmed to converge, then the trained SeNet-Transformer action network model is the optimal parallel robot PID adaptive adjustment model;
[0029] Otherwise, based on the generalized advantage estimation strategy GAE and the PID parameter adaptation rule, the weight parameters of the trained SeNet-Transformer action network model are updated with gradients, and step S42 is iteratively executed repeatedly.
[0030] Furthermore, the reward function based on PPO reinforcement learning constructed in S43 is expressed as
[0031] ,
[0032] Where: R represents the reward value of the reward function based on PPO reinforcement learning; w_1, w_2, w_3 represent weight coefficients; Indicates position error; Indicates speed error; represents the change in the PID adaptive adjustment parameters of the parallel robot and ; Indicates the PID adaptive adjustment ratio parameter of the parallel robot The amount of change; Indicates the PID adaptive adjustment integral parameter of the parallel robot The amount of change; Indicates the PID adaptive adjustment differential parameter of the parallel robot The amount of change;
[0033] Furthermore, the expression for extracting the spatiotemporal features of the data in the real-time trajectory error sequence through the feature extraction SeNet module in S3 is:
[0034] ,
[0035] Where: It represents the extraction of spatiotemporal features of data in real-time trajectory error series; Represents the real-time trajectory error sequence of the input; Represents the weight parameters of the fully connected layer; express Activation function; Indicates the pooling operation on the real-time trajectory error sequence; express Activation function.
[0036] Furthermore, the method for performing dynamic symmetric error compensation on the real-time trajectory error sequence in S3 specifically includes the following steps:
[0037] S31: Based on the symmetry of the parallel robot's terminal trajectory error, the motion cycle type of the parallel robot's terminal trajectory is divided into acceleration segment, uniform speed segment and deceleration segment;
[0038] S32: Determine the motion cycle type of the current parallel robot terminal trajectory;
[0039] If it is confirmed that the motion cycle type is an acceleration segment or a deceleration segment, step S33 is executed;
[0040] If the motion cycle type is confirmed to be a uniform speed segment, step S34 is executed;
[0041] S33: construct an error compensation strategy based on the velocity error to compensate for the error of the spatial control torque of the end joint of the parallel robot;
[0042] And the expression for constructing the error compensation strategy is
[0043] ,
[0044] Where: represents the spatial control torque of the end joint of the parallel robot after error compensation; represents the compensation coefficient that can be dynamically optimized through reinforcement learning;
[0045] S34: Using arc error compensation, that is, obtaining the correction value of the angle of the end joint of the parallel robot through the inverse solution of the Jacobian matrix to compensate for the position error of the end joint of the parallel robot.
[0046] Furthermore, the PID parameter self-adaptation rule in S43 specifically includes:
[0047] S431: Confirm whether the current position error in the training set meets the preset position error threshold;
[0048] If it is confirmed that the current position error meets the preset position error threshold, the parallel robot PID adaptive adjustment ratio parameter is increased according to the preset expected increment. The amount of change;
[0049] Otherwise, the PID proportional parameters of the parallel robot are adjusted adaptively. The change in is not processed;
[0050] S432: Confirm the fluctuation of current speed error Whether the preset speed error threshold is met;
[0051] If it is confirmed that the fluctuation of the current speed error meets the preset speed error threshold, the PID adaptive adjustment differential parameters of the parallel robot are updated and obtained based on the parameter update rule. ;
[0052] And the expression of the parameter update rule is
[0053] ,
[0054] Otherwise, the differential parameters of the parallel robot PID are adjusted adaptively The change in is not processed.
[0055] A parallel robot PID adaptive control system based on SeNet-Transformer action network, characterized by comprising a physical layer module, a data layer module, an algorithm layer module, a compensation layer module and an interaction layer module;
[0056] The physical layer module is used to build a virtual model of the parallel robot's physical entity in the Gazebo simulation environment. The physical layer module and the data layer module publish the virtual model's status information in real time through ROS and use the UDP protocol for data transmission.
[0057] The data layer module is used to call Gazebo's physics engine to simulate the dynamics program of the real environment in which the virtual model is located. It collects and obtains the information data of the parallel robot in real time based on the state information of the virtual model, and defines the PID controller framework model based on the parallel robot information data.
[0058] The state input of the PID controller framework model is the real-time trajectory error of the parallel robot, and the state output is the joint space control torque; according to the real-time trajectory error and the joint space control torque, a trajectory time series sample data set of the parallel robot is obtained;
[0059] The algorithm layer module is used to build a SeNet-Transformer action network model based on PPO reinforcement learning, and the compensation layer module is used to implement dynamic symmetric error compensation and PID parameter adaptive rules for the real-time trajectory error sequence during the training process of the SeNet-Transformer action network model;
[0060] The interaction layer module is used to train the SeNet-Transformer action network model based on the trajectory time series sample dataset, obtain the optimal parallel robot PID adaptive adjustment model, and obtain the PID adjustment parameters of the parallel robot based on the optimal parallel robot PID adaptive adjustment model to realize the parallel robot PID adaptive adjustment.
[0061] The present invention provides a parallel robot adaptive adjustment method and system based on the attention mechanism, which has the following beneficial effects:
[0062] (1) Through the SeNet-Transformer action network model based on PPO reinforcement learning, the spatiotemporal features of the data are integrated and processed based on the multi-head self-attention mechanism. The temporal dependency probability distribution of the parallel robot PID parameter adjustment is obtained by combining the real-time trajectory error sequence, which greatly reduces the trajectory tracking error and improves the response speed of PID parameter adjustment.
[0063] (2) The symmetric compensation strategy combined with the PPO algorithm achieves a position accuracy of ±0.1mm in the Gazebo simulation environment, which is three times higher than traditional PID control.
[0064] (3) The PID adjustment parameters of the parallel robot are obtained according to the optimal parallel robot PID adaptive adjustment model. That is, the oscillation caused by the sudden change of load is effectively suppressed through the dynamic parameter adjustment mechanism (PID parameter adaptive rule), and the steady-state error convergence time is shortened to 0.2 seconds. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0066] Figure 1 This is a flow chart of the adaptive adjustment method of a parallel robot based on the attention mechanism of the present invention;
[0067] Figure 2 Schematic diagram of the network structure of the SeNet-Transformer action network model in this embodiment;
[0068] Figure 3 This is a segmented comparison curve diagram of the action network error compensation strategy constructed based on different models in this embodiment;
[0069] Figure 4 This is the PID control parameter adjustment result diagram in this embodiment;
[0070] Figure 5 is a comparison diagram of the posture error of the end effector in this embodiment;
[0071] Figure 6 This is a comparison diagram of the PID control attitude angle fluctuation in this embodiment;
[0072] Figure 7 This is a comparison chart of PID parameters adjusted in the proportional link based on the reinforcement learning algorithm in this embodiment;
[0073] Figure 8 This is a comparison chart of PID parameters adjusted in the integral link based on the reinforcement learning algorithm in this embodiment. DETAILED DESCRIPTION
[0074] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0075] This embodiment provides a parallel robot adaptive adjustment method based on the attention mechanism, such as Figure 1 As shown, the specific steps include:
[0076] S1: Build a virtual model of the parallel robot's physical entity in the Gazebo simulation environment;
[0077] The Gazebo physics engine is used to simulate the dynamics of the virtual model's real environment to collect and acquire the parallel robot's information data in real time. The parallel robot's information data includes at least motor torque, joint angles, end-user pose, and load data.
[0078] Specifically, a 6-DOF parallel robot URDF model was imported into the Gazebo simulation environment, and the link mass and inertia parameters were set to be consistent with the actual physical entity. A virtual force sensor (Wrench Sensor) was added to the actuator at the end of the parallel robot to collect contact force data, and encoders were deployed at the joints to obtain the angle and angular velocity of the parallel robot in real time, with a sampling frequency of 1kHz.
[0079] S2: Define the PID controller framework model based on the parallel robot information data;
[0080] The state input of the PID controller framework model is the real-time trajectory error of the parallel robot, and the state output is the joint space control torque; specifically, by defining the proportional parameter (K_p), integral parameter (K_i), and differential parameter (K_d) of the PID controller as PID adjustable variables, and by , speed error ) as state input, output joint space control torque, so as to establish a mathematical relationship function between the real-time trajectory error and the joint space control torque, and the method of establishing the mathematical relationship function is a well-known technical means, which will not be described in detail here;
[0081] The real-time trajectory error is the position error and velocity error between the expected motion trajectory of the virtual model obtained based on the information data of the parallel robot and the actual motion trajectory. The trajectory time series sample data set of the parallel robot is obtained based on the real-time trajectory error and the joint space control torque.
[0082] This embodiment also includes preprocessing the trajectory time series sample dataset:
[0083] Define the sample state vector s_t in the trajectory time series sample dataset, which contains:
[0084] End position error (3D), velocity error (3D) and joint space control torque (6 dimensions), a total of 12 dimensions;
[0085] Data standardization: and Perform Z-score normalization to control the torque in joint space Scale the maximum and minimum values to [-1,1];
[0086] S3: Build a SeNet-Transformer action network model based on PPO reinforcement learning;
[0087] like Figure 2 As shown in Figure 1, the SeNet-Transformer action network model consists of a cascaded input layer, a feature extraction SeNet module, a Transformer encoder, and an output layer.
[0088] The input layer is used to perform dynamic symmetric error compensation on the real-time trajectory error sequence, obtain the real-time error compensation trajectory error sequence and input it into the feature extraction SeNet module;
[0089] Specifically, the method for performing dynamic symmetric error compensation on a real-time trajectory error sequence comprises the following steps:
[0090] S31: Based on the symmetry of the parallel robot's terminal trajectory error, the motion cycle type of the parallel robot's terminal trajectory is divided into acceleration segment, uniform speed segment and deceleration segment;
[0091] S32: Determine the motion cycle type of the current parallel robot terminal trajectory;
[0092] If it is confirmed that the motion cycle type is an acceleration segment or a deceleration segment, step S33 is executed;
[0093] If the motion cycle type is confirmed to be a uniform speed segment, step S34 is executed;
[0094] S33: construct an error compensation strategy based on the velocity error to compensate for the error of the spatial control torque of the end joint of the parallel robot;
[0095] And the expression for constructing the error compensation strategy is
[0096] ,
[0097] Where: represents the spatial control torque of the end joint of the parallel robot after error compensation; represents the compensation coefficient that can be dynamically optimized through reinforcement learning;
[0098] S34: Using arc error compensation, that is, obtaining a correction value for the angle of the terminal joint of the parallel robot by inversely solving the Jacobian matrix, so as to compensate for the position error of the terminal joint of the parallel robot; wherein the method of using arc error compensation to compensate for the position error of the terminal joint of the parallel robot is a well-known technical means and will not be described in detail here;
[0099] The feature extraction SeNet module is used to perform channel attention weighting on the input data and extract key features to obtain the data spatiotemporal features in the error sequence of the real-time error compensation trajectory;
[0100] Specifically, the expression of the spatiotemporal features of the data in the real-time trajectory error sequence is extracted by the feature extraction SeNet module:
[0101] ,
[0102] Where: It represents the extraction of spatiotemporal features of data in real-time trajectory error series; Represents the real-time trajectory error sequence of the input; Represents the weight parameter of the fully connected layer FC; express Activation function; Indicates the pooling operation on the real-time trajectory error sequence; express Activation function; The input channel number C=12 and compression ratio r=4 of the SeNet module in this embodiment can generate 1x1xC features through global average pooling and pass through two layers of full connection (FC1: C→C / r, ; FC2: C / r→C, ) Generate channel weights and multiply them channel by channel with the original features;
[0103] The Transformer encoder is used to process the spatiotemporal features of the data based on the multi-head self-attention mechanism, and combines the real-time trajectory error sequence to obtain the temporal dependency probability distribution of the parallel robot PID parameter adjustment; the output layer, i.e., the fully connected layer, is used to predict and output the joint space control torque based on the temporal dependency probability distribution; in this embodiment, the input sequence length of the Transformer encoder is T = 10 (historical 10-step state), the embedding dimension is d = 64, and the position encoding uses a sine function; the number of multi-head self-attention heads is 4, the feedforward network dimension is 256, and the output context vector h_t; the fully connected layer maps h_t to the 3D action space and outputs the PID increment , the value range is [-0.1, 0.1] (through Activation function scaling);
[0104] Specifically, the Transformer encoder includes a cascaded first encoding unit and a second encoding unit;
[0105] The first encoding unit includes a first embedding layer, a first position encoding layer, a first multi-head attention layer, a first residual connection and normalization layer, a first feedforward neural network layer, and a second residual connection and normalization layer;
[0106] The first embedding layer is used to embed the real-time trajectory error sequence to obtain a trajectory error sequence vector; the first position encoding layer is used to perform position encoding on the trajectory error sequence vector to obtain a position encoding vector; the first multi-head attention layer is used to perform a multi-head attention operation on the position encoding vector to obtain a multi-head attention vector; the first residual connection and normalization layer is used to perform a residual connection on the position encoding vector and the multi-head attention vector, and then perform layer normalization processing; the first feedforward neural network layer is used to perform a feedforward mapping processing on the output of the first residual connection and normalization layer; the second residual connection and normalization layer is used to perform a residual connection on the output of the first feedforward neural network layer and the output of the first residual connection and normalization layer, and then perform layer normalization processing to obtain an intermediate vector;
[0107] The second encoding unit includes a second embedding layer, a second position encoding layer, a masked multi-head attention layer, a third residual connection and normalization layer, a second multi-head attention layer, a fourth residual connection and normalization layer, a second feedforward neural network layer, a fifth residual connection and normalization layer, a linear layer, and a soft max activation function layer;
[0108] The second embedding layer is used to embed the spatiotemporal features of the data to obtain the spatiotemporal feature vector of the data; the second position encoding layer is used to perform position encoding on the spatiotemporal feature vector of the data to obtain the feature encoding vector; the masked multi-head attention layer is used to perform masking on the feature encoding vector to obtain the feature mask vector; the third residual connection and normalization layer is used to perform residual connection on the feature mask vector and the feature encoding vector, and then perform layer normalization processing; the second multi-head attention layer is used to perform multi-head attention operation on the output of the third residual connection and normalization layer and the intermediate vector; the fourth residual connection and normalization layer is used to perform residual connection on the output of the second multi-head attention layer and the output of the third residual connection and normalization layer, and then perform layer normalization processing; the second feedforward neural network layer is used to perform feedforward mapping processing on the output of the fourth residual connection and normalization layer; the fifth residual connection and normalization layer is used to perform residual connection on the output of the second feedforward neural network layer and the output of the fourth residual connection and normalization layer, and then perform layer normalization processing; the linear layer is used to perform linear operation on the output of the fifth residual connection and normalization layer; soft The max activation function layer is used to activate the output of the linear layer and obtain the probability distribution of the temporal dependency of the PID parameter adjustment of the parallel robot.
[0109] S4: Train the SeNet-Transformer action network model based on the trajectory time series sample dataset to obtain the optimal parallel robot PID adaptive adjustment model. Then, obtain the PID adjustment parameters of the parallel robot based on the optimal parallel robot PID adaptive adjustment model to achieve PID adaptive adjustment of the parallel robot.
[0110] Specifically, the method for obtaining the optimal parallel robot PID adaptive adjustment model includes:
[0111] S41: The position error and velocity error of the real-time trajectory error are used as feature data, the joint space control torque is used as label data, and the trajectory time series sample dataset is randomly divided into a training set and a validation set;
[0112] S42: Input the training set into the SeNet-Transformer action network model for model training, and obtain the trained SeNet-Transformer action network model;
[0113] S43: Construct a reward function based on PPO reinforcement learning, and use the reward function as the model loss function of the SeNet-Transformer action network model;
[0114] The trained SeNet-Transformer action network model is validated using the validation set, and the convergence of the output of the trained SeNet-Transformer action network model is determined based on the model loss function.
[0115] Specifically, the reward function constructed based on PPO reinforcement learning is expressed as
[0116] ,
[0117] Where: R represents the reward value of the reward function based on PPO reinforcement learning; w_1, w_2, w_3 represent weight coefficients; Indicates position error; Indicates speed error; represents the change in the PID adaptive adjustment parameters of the parallel robot and ; Indicates the PID adaptive adjustment ratio parameter of the parallel robot The amount of change; Indicates the PID adaptive adjustment integral parameter of the parallel robot The amount of change; Indicates the PID adaptive adjustment differential parameter of the parallel robot The change in the amount of; In this embodiment, the PPO reinforcement learning algorithm hyperparameter is set to: discount factor =0.99, GAE parameter λ=0.95, learning rate α=3e-4, Clip range ε=0.2; batch size 256 and 4096 steps of data collected per iteration;
[0118] If the output of the trained SeNet-Transformer action network model is confirmed to have converged, then the trained SeNet-Transformer action network model is the optimal parallel robot PID adaptive adjustment model. This embodiment deploys a collaborative training environment in Gazebo: data synchronization between the simulation model and the physical entity is achieved through the ROS communication interface, and the PPO algorithm is used to iteratively optimize the action network parameters until the reward function converges.
[0119] Otherwise, based on the generalized advantage estimation strategy GAE and the PID parameter adaptation rule, the weight parameters of the trained SeNet-Transformer action network model are updated with gradients, and step S42 is iteratively executed repeatedly.
[0120] In a specific embodiment, the PID parameter adaptation rule is specifically:
[0121] S431: Confirm whether the current position error in the training set meets the preset position error threshold, i.e.
[0122] ;
[0123] If it is confirmed that the current position error meets the preset position error threshold, the parallel robot PID adaptive adjustment ratio parameter is increased according to the preset expected increment. The amount of change;
[0124] The amplitude of the PID adaptive differential parameter K_d is proportional to the error gradient:
[0125] ;
[0126] Otherwise, the change of the parallel robot PID adaptive adjustment proportional parameter K_p is not processed;
[0127] S432: Confirm the fluctuation of current speed error Whether it meets the preset speed error threshold, that is, ;
[0128] If it is confirmed that the fluctuation of the current speed error meets the preset speed error threshold, the parallel robot PID adaptive adjustment differential parameter K_d is updated and obtained based on the parameter update rule;
[0129] And the expression of the parameter update rule is
[0130] ,
[0131] Otherwise, the change of the differential parameter K_d of the parallel robot PID adaptive adjustment is not processed.
[0132] A parallel robot PID adaptive control system based on SeNet-Transformer action network, characterized by comprising a physical layer module, a data layer module, an algorithm layer module, a compensation layer module and an interaction layer module;
[0133] The physical layer module is used to build a virtual model of the parallel robot's physical entity in the Gazebo simulation environment. The physical layer module and the data layer module publish the virtual model's status information in real time via ROS and use the UDP protocol for synchronous data transmission, with a packet loss rate of less than 0.01%. This embodiment includes implementing data synchronization transmission through Gazebo's plug-in mechanism: that is, inserting a custom callback function into the Gazebo simulation loop to synchronize the physical entity (physical layer module) and the digital twin state (data layer module) at a frequency of 1kHz, with a latency of less than 0.5ms. In this embodiment, millisecond-level data synchronization can be achieved through the ROS interface.
[0134] The data layer module is used to call Gazebo's physics engine to simulate the dynamics program of the real environment in which the virtual model is located. It collects and obtains the information data of the parallel robot in real time based on the state information of the virtual model, and defines the PID controller framework model based on the parallel robot information data.
[0135] The state input of the PID controller framework model is the real-time trajectory error of the parallel robot, and the state output is the joint space control torque; according to the real-time trajectory error and the joint space control torque, a trajectory time series sample data set of the parallel robot is obtained;
[0136] The algorithm layer module is used to build a SeNet-Transformer action network model based on PPO reinforcement learning, and the compensation layer module is used to implement dynamic symmetric error compensation and PID parameter adaptive rules for the real-time trajectory error sequence during the training process of the SeNet-Transformer action network model;
[0137] The interaction layer module is used to train the SeNet-Transformer action network model based on the trajectory time series sample dataset, obtain the optimal parallel robot PID adaptive adjustment model, and obtain the PID adjustment parameters of the parallel robot based on the optimal parallel robot PID adaptive adjustment model to realize the parallel robot PID adaptive adjustment.
[0138] This embodiment also includes experimental comparison and analysis process:
[0139] A control method based on SeNet+Transformer and reinforcement learning, namely an adaptive adjustment method for parallel robots based on attention mechanism, was compared with a traditional control method based on mathematical models and analytical algorithms.
[0140] Under the same motion task and experimental conditions, the performance indicators of the two methods, such as control accuracy, response time, and stability, were recorded respectively.
[0141] 1) First, compare and analyze the reward value function of the algorithm. When using the RNN algorithm as the action network, such as Figure 3As shown in the figure, the reward value obtained when the end effector of the parallel robot reaches the desired posture is mostly below -1000, which shows that the PID value given by the action network cannot control the length and torque of the six legs of the parallel robot, and make the posture of the end motion platform reach the given position smoothly within the specified time limit. Therefore, the PID value generated by the action network is incorrect, and the PID value output generated by the network obtains a penalty value. When the training reaches more than 50 rounds, the PID value given by the Senet+Transformer network has reached the optimal value and maintained it for a long time, while the PID value given by the RNN network can only obtain a few sparse high-score rewards and Moreover, due to the lack of long-term memory effect of RNN, it was unable to give the most effective PID value after 50 rounds and 240 rounds of reinforcement training, resulting in the reward value being lower than -1000 for a long time. Compared with the case where Senet+Transformer was used as the action network, it was found that it could obtain higher reinforcement learning reward values more quickly than the PID setting value given by the RNN network, and maintained a good reward value during the long-term reinforcement learning training process. This shows that the Senet+Transformer network can extract feature values more quickly and accurately to generate the required PID control parameters.
[0142] 2) Compare and analyze the adaptive adjustment method of the parallel robot based on the attention mechanism and the reward value function of only the Transformer, such as Figure 4 As shown in the figure, both networks based on the attention mechanism can extract PID values so that the parallel robot end effector can reach the desired posture quickly and stably, solving the problem of PID control parameter adjustment of the strongly coupled hexapod parallel robot. However, in comparison, the Senet-Transformer network can avoid unnecessary interference because it first extracts the eigenvalues in a targeted manner through the attention-based Senet and then passes them to the Transformer network. After intensive training to achieve a better PID given value, it can obtain stable reward returns. In comparison, the PID value given by the simple Transformer network as the action network still has a higher control failure rate, and the reward value obtained is lower than that of the Senet-Transformer network, and the control fluctuation is more obvious. Therefore, using Senet-Transfomer as the action network can extract eigenvalues more quickly and provide more effective PID tuning values.
[0143] The experimental results and evaluation indicators in this embodiment are as follows:
[0144] 1) Control accuracy: It is measured by the error between the actual pose of the end effector and the target pose, as shown in the following example: Figure 6As shown in the figure, the PID values given by RNN as the action network control the movement of the six legs of the parallel robot. The posture error of the end effector is significantly higher than that of Senet-Transformer, so Senet-Transformer has higher control accuracy.
[0145] 2) Stability: Figure 5 The figure shows the posture curve of the parallel robot, which shows the jitter of the robot during movement and whether there are any singular points. It can be found that the PID control parameters given by Senet-Transformer have lower posture angle fluctuations, better stability and consistency.
[0146] 3)PID parameter tuning performance: Figures 7 and 8 As shown in the figure, the PID parameter value adjusted by the Senet-Transformer reinforcement learning algorithm tends to be stable in the proportional link in the later stage of reinforcement training, so it can achieve better response time and control accuracy. However, the proportional link under the RNN action network changes greatly, and repeated fluctuations occur, which affects the stability of the system. Similarly, in the integral link, the Senet-Transformer algorithm also tends to a stable parameter value in the later stage of training. However, due to the excessive change in the proportional link of the RNN network, the integral link has not been able to be effectively adjusted and is always in the maximum parameter tuning range, losing its regulatory effect.
[0147] Compared with the prior art, the method and system described in this embodiment have the following beneficial effects:
[0148] (1) Through the SeNet-Transformer action network model based on PPO reinforcement learning, the spatiotemporal features of the data are integrated and processed based on the multi-head self-attention mechanism. The temporal dependency probability distribution of the parallel robot PID parameter adjustment is obtained by combining the real-time trajectory error sequence. This greatly reduces the trajectory tracking error and improves the PID parameter adjustment response speed. The PID parameter adjustment response speed can be increased by 40% and the trajectory tracking error can be reduced by 60%.
[0149] (2) The symmetric compensation strategy combined with the PPO algorithm achieves a position accuracy of ±0.1mm in the Gazebo simulation environment, which is three times higher than traditional PID control.
[0150] (3) The PID adjustment parameters of the parallel robot are obtained according to the optimal parallel robot PID adaptive adjustment model. That is, the oscillation caused by the sudden change of load is effectively suppressed through the dynamic parameter adjustment mechanism (PID parameter adaptive rule), and the steady-state error convergence time is shortened to 0.2 seconds.
[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A parallel robot adaptive adjustment method based on attention mechanism, characterized in that: The specific steps include: S1: Build a virtual model of the parallel robot's physical entity in the Gazebo simulation environment; The Gazebo physics engine is used to simulate the dynamics of the virtual model's real environment to collect and acquire the parallel robot's information data in real time. The parallel robot's information data includes at least motor torque, joint angles, end-user pose, and load data. S2: Define the PID controller framework model based on the parallel robot information data; The state input of the PID controller framework model is the real-time trajectory error of the parallel robot, and the state output is the joint space control torque; the real-time trajectory error is the position error and speed error between the expected motion trajectory of the virtual model obtained based on the parallel robot information data and the actual motion trajectory. And obtain the trajectory time series sample dataset of the parallel robot based on the real-time trajectory error and joint space control torque; S3: Build a SeNet-Transformer action network model based on PPO reinforcement learning; The SeNet-Transformer action network model includes a cascaded input layer, a feature extraction SeNet module, a Transformer encoder, and an output layer; The input layer is used to perform dynamic symmetric error compensation on the real-time trajectory error sequence, obtain the real-time error compensation trajectory error sequence and input it into the feature extraction SeNet module; The feature extraction SeNet module is used to extract the spatiotemporal features of data in the error sequence of the real-time error compensation trajectory; The Transformer encoder is used to process the spatiotemporal features of the data based on a multi-head self-attention mechanism, and combines the real-time trajectory error sequence to obtain the temporal dependency probability distribution of the parallel robot PID parameter adjustment. The output layer is used to predict and output the joint space control torque based on the temporal dependency probability distribution. S4: The SeNet-Transformer action network model is trained based on the trajectory time series sample dataset to obtain the optimal parallel robot PID adaptive adjustment model. The PID adjustment parameters of the parallel robot are obtained based on the optimal parallel robot PID adaptive adjustment model to achieve PID adaptive adjustment of the parallel robot.
2. The method for adaptive adjustment of a parallel robot based on an attention mechanism according to claim 1, characterized in that: The Transformer encoder in S3 includes a cascaded first encoding unit and a second encoding unit; The first encoding unit includes a first embedding layer, a first position encoding layer, a first multi-head attention layer, a first residual connection and normalization layer, a first feedforward neural network layer, and a second residual connection and normalization layer; The first embedding layer is used to embed the real-time trajectory error sequence to obtain a trajectory error sequence vector; the first position encoding layer is used to perform position encoding on the trajectory error sequence vector to obtain a position encoding vector; the first multi-head attention layer is used to perform a multi-head attention operation on the position encoding vector to obtain a multi-head attention vector; the first residual connection and normalization layer is used to perform a residual connection on the position encoding vector and the multi-head attention vector, and then perform layer normalization processing; the first feedforward neural network layer is used to perform feedforward mapping processing on the output of the first residual connection and normalization layer; The second residual connection and normalization layer is used to perform a residual connection on the output of the first feedforward neural network layer and the output of the first residual connection and normalization layer, and then perform layer normalization processing to obtain an intermediate vector; The second encoding unit includes a second embedding layer, a second position encoding layer, a masked multi-head attention layer, a third residual connection and normalization layer, a second multi-head attention layer, a fourth residual connection and normalization layer, a second feedforward neural network layer, a fifth residual connection and normalization layer, a linear layer, and a soft max activation function layer; The second embedding layer is used to embed the spatiotemporal features of the data to obtain the spatiotemporal feature vector of the data; the second position encoding layer is used to perform position encoding on the spatiotemporal feature vector of the data to obtain the feature encoding vector; the masked multi-head attention layer is used to perform a mask operation on the feature encoding vector to obtain the feature mask vector; the third residual connection and normalization layer is used to perform a residual connection on the feature mask vector and the feature encoding vector, and then perform layer normalization; the second multi-head attention layer is used to perform a multi-head attention operation on the output and intermediate vector of the third residual connection and normalization layer; The fourth residual connection and normalization layer is used to perform residual connection on the output of the second multi-head attention layer and the output of the third residual connection and normalization layer, and then perform layer normalization. The second feedforward neural network layer is used to perform feedforward mapping processing on the output of the fourth residual connection and the normalization layer; The fifth residual connection and normalization layer is used to perform residual connection on the output of the second feedforward neural network layer and the output of the fourth residual connection and normalization layer, and then perform layer normalization processing; The linear layer is used to perform linear operations on the outputs of the fifth residual connection and the normalization layer. The soft max activation function layer is used to perform activation operations on the outputs of the linear layer to obtain the probability distribution of the temporal dependency relationship of the parallel robot PID parameter adjustment.
3. The method for adaptive adjustment of a parallel robot based on an attention mechanism according to claim 2, characterized in that: The method for obtaining the optimal parallel robot PID adaptive adjustment model in S4 specifically includes the following steps: S41: The position error and velocity error of the real-time trajectory error are used as feature data, the joint space control torque is used as label data, and the trajectory time series sample dataset is randomly divided into a training set and a validation set; S42: Input the training set into the SeNet-Transformer action network model for model training, and obtain the trained SeNet-Transformer action network model; S43: Construct a reward function based on PPO reinforcement learning, and use the reward function as the model loss function of the SeNet-Transformer action network model; The trained SeNet-Transformer action network model is validated using the validation set, and the convergence of the output of the trained SeNet-Transformer action network model is determined based on the model loss function. If the output of the trained SeNet-Transformer action network model is confirmed to converge, then the trained SeNet-Transformer action network model is the optimal parallel robot PID adaptive adjustment model; Otherwise, based on the generalized advantage estimation strategy GAE and the PID parameter adaptation rule, the weight parameters of the trained SeNet-Transformer action network model are updated with gradients, and step S42 is iteratively executed repeatedly.
4. The method for adaptive adjustment of a parallel robot based on an attention mechanism according to claim 3, characterized in that: The reward function based on PPO reinforcement learning constructed in S43 is expressed as , Where: R represents the reward value of the reward function based on PPO reinforcement learning; w_1, w_2, w_3 represent weight coefficients; Indicates position error; Indicates speed error; represents the change in the PID adaptive adjustment parameters of the parallel robot and ; Indicates the PID adaptive adjustment ratio parameter of the parallel robot The amount of change; Indicates the PID adaptive adjustment integral parameter of the parallel robot The amount of change; Indicates the PID adaptive adjustment differential parameter of the parallel robot The amount of change.
5. The method for adaptive adjustment of a parallel robot based on an attention mechanism according to claim 4, characterized in that: The expression for extracting the spatiotemporal features of data in the real-time trajectory error sequence through the feature extraction SeNet module in S3 is: , Where: It represents the extraction of spatiotemporal features of data in real-time trajectory error series; Represents the real-time trajectory error sequence of the input; Represents the weight parameters of the fully connected layer; express Activation function; Indicates the pooling operation on the real-time trajectory error sequence; express Activation function.
6. The method for adaptive adjustment of a parallel robot based on an attention mechanism according to claim 5, characterized in that: The method for performing dynamic symmetric error compensation on the real-time trajectory error sequence in S3 specifically includes the following steps: S31: Based on the symmetry of the parallel robot's terminal trajectory error, the motion cycle type of the parallel robot's terminal trajectory is divided into acceleration segment, uniform speed segment and deceleration segment; S32: Determine the motion cycle type of the current parallel robot terminal trajectory; If it is confirmed that the motion cycle type is an acceleration segment or a deceleration segment, step S33 is executed; If the motion cycle type is confirmed to be a uniform speed segment, step S34 is executed; S33: construct an error compensation strategy based on the velocity error to compensate for the error of the spatial control torque of the end joint of the parallel robot; And the expression for constructing the error compensation strategy is , Where: represents the spatial control torque of the end joint of the parallel robot after error compensation; represents the compensation coefficient that can be dynamically optimized through reinforcement learning; S34: Using arc error compensation, that is, obtaining the correction value of the angle of the end joint of the parallel robot through the inverse solution of the Jacobian matrix to compensate for the position error of the end joint of the parallel robot.
7. The method for adaptive adjustment of a parallel robot based on an attention mechanism according to claim 3, characterized in that: The PID parameter self-adaptation rule in S43 specifically includes: S431: Confirm whether the current position error in the training set meets the preset position error threshold; If it is confirmed that the current position error meets the preset position error threshold, the parallel robot PID adaptive adjustment ratio parameter is increased according to the preset expected increment. The amount of change; Otherwise, the PID proportional parameters of the parallel robot are adjusted adaptively. The change in is not processed; S432: Confirm the fluctuation of current speed error Whether the preset speed error threshold is met; If it is confirmed that the fluctuation of the current speed error meets the preset speed error threshold, the PID adaptive adjustment differential parameters of the parallel robot are updated and obtained based on the parameter update rule. ; And the expression of the parameter update rule is , Otherwise, the differential parameters of the parallel robot PID are adjusted adaptively The change in is not processed.
8. A system based on the parallel robot adaptive adjustment method based on the attention mechanism according to any one of claims 1 to 7, characterized in that: Including physical layer module, data layer module, algorithm layer module, compensation layer module and interaction layer module; The physical layer module is used to build a virtual model of the parallel robot's physical entity in the Gazebo simulation environment. The physical layer module and the data layer module publish the virtual model's status information in real time through ROS and use the UDP protocol for data transmission. The data layer module is used to call Gazebo's physics engine to simulate the dynamics program of the real environment in which the virtual model is located. It collects and obtains the information data of the parallel robot in real time based on the state information of the virtual model, and defines the PID controller framework model based on the parallel robot information data. The state input of the PID controller framework model is the real-time trajectory error of the parallel robot, and the state output is the joint space control torque; according to the real-time trajectory error and the joint space control torque, a trajectory time series sample data set of the parallel robot is obtained; The algorithm layer module is used to build a SeNet-Transformer action network model based on PPO reinforcement learning, and the compensation layer module is used to implement dynamic symmetric error compensation and PID parameter adaptive rules for the real-time trajectory error sequence during the training process of the SeNet-Transformer action network model; The interaction layer module is used to train the SeNet-Transformer action network model based on the trajectory time series sample dataset, obtain the optimal parallel robot PID adaptive adjustment model, and obtain the PID adjustment parameters of the parallel robot based on the optimal parallel robot PID adaptive adjustment model to realize the parallel robot PID adaptive adjustment.
Citation Information
Patent Citations
Self-adaptive SAC-PID method suitable for complex unknown environment
CN113359704A
Three-degree-of-freedom parallel robot trajectory tracking method and system
CN120002660A