2R type flexible joint robot control method and system

By setting up a disturbance observer and improving the PPO policy network on a 2R-type flexible joint robot, and combining it with an NMPC controller for coupled disturbance estimation and weight constraint optimization, the problems of unsuppressed coupled disturbances and easy weight output overshooting in the prior art are solved, achieving high-precision and robust control effects.

CN123169100APending Publication Date: 2026-11-27XIAN INST OF OPTICS & PRECISION MECHANICS CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611493365.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-23
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

The existing PPO+NMPC solution cannot effectively suppress the coupled disturbances of flexible joint robots. The weight output is prone to going out of bounds and becoming unstable. The control decision-making, learning optimization, and disturbance suppression are disconnected from each other, making it difficult to meet the stringent requirements of high-end operation scenarios for control accuracy and robustness.

Method used

A disturbance observer is set up on a 2R-type flexible joint robot. Coupled disturbance estimation is performed by improving the PPO policy network. Weight constraint penalty term and coupled disturbance intensity penalty term are introduced. Multi-objective cost function optimization is performed in combination with NMPC controller to achieve dynamic compensation and adaptive fusion.

Benefits of technology

Effectively constraining the weight range of the NMPC controller improves trajectory tracking accuracy, reduces overshoot and steady-state error, ensures the smoothness of control quantities and the safety of actuators, and enhances the robustness and control quality of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123169100A_ABST
    Figure CN123169100A_ABST
Patent Text Reader

Abstract

The present application relates to a robot control method and system, in particular to a 2R type flexible joint robot control method and system. The present application solves the problem that the coupling disturbance cannot be effectively suppressed and the weight output is easy to exceed the boundary and lose stability due to the direct splicing of the general algorithm in the existing PPO+NMPC scheme. Specifically, the present application comprises the following steps: step 1, obtaining the system state and the coupling disturbance estimation value of the 2R type flexible joint robot at the current time; step 2, inputting the system state and the coupling disturbance estimation value at the current time as the state observation value into the improved PPO policy network which has been pre-trained, and the improved PPO policy network outputs a multi-dimensional weight vector; step 3, inputting the multi-dimensional weight vector output by step 2 and the coupling disturbance estimation value obtained by step 1 into the NMPC controller of the 2R type flexible joint robot, and obtaining the optimal control torque based on the multi-objective cost function of the NMPC controller; and step 4, controlling the 2R flexible joint robot to run based on the optimal control torque by the NMPC controller.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to robot control methods and systems, specifically to a control method and system for a 2R type flexible joint robot. Background Technology

[0002] In high-end operational scenarios such as intelligent manufacturing and human-robot collaboration, the compliance and low-impact characteristics of robots are crucial. Flexible joint robots, due to the elastic elements embedded in their joints, possess natural mechanical cushioning capabilities, exhibiting irreplaceable advantages in these scenarios. Among them, the 2R-type flexible joint robot, with its simple dynamic analysis framework and low control deployment cost, has become an ideal experimental platform and engineering verification vehicle for flexible joint robot modeling and advanced control technology research.

[0003] However, the rigid-flexible coupling effect and nonlinear coupling disturbance introduced by joint flexibility cause the robot system to exhibit strong nonlinearity and high coupling characteristics. Traditional control methods struggle to achieve an effective balance between trajectory tracking accuracy and vibration suppression, and controller parameter optimization relies heavily on manual trial and error, resulting in low efficiency and poor robustness, which has become a key bottleneck restricting engineering applications.

[0004] Nonlinear Model Predictive Control (NMPC), with its rolling time-domain optimization and multivariable coordination capabilities, is naturally suited to the complex control requirements of flexible articulated robots and is currently one of the mainstream control schemes in this field. The control performance of NMPC is highly dependent on the accuracy of system dynamics modeling and the configuration of cost function weights. However, traditional NMPC often uses fixed weight coefficients, which cannot adapt to fluctuations in operating conditions such as load changes and speed switching, leading to conservative control or performance degradation. To address this, existing research attempts to combine the Proximal Policy Optimization (PPO) algorithm with NMPC, leveraging PPO's advantages in optimization stability and convergence to achieve online adaptive adjustment of cost function weights.

[0005] However, existing PPO+NMPC solutions are all direct splicing applications of general algorithms, which have three fatal flaws: First, the solutions lack observation and compensation mechanisms for coupling disturbances specific to flexible joints. The policy network of the native PPO cannot effectively identify elastic torque coupling disturbances and rigid-flexible energy interaction dynamics during the optimization process, causing the weight optimization to deviate from the actual needs of the system. Second, the PPO output weights lack an effective physical feasible domain constraint mechanism, and the optimization results are prone to producing out-of-bounds weights, causing the control commands output by NMPC to exceed the safety boundaries of actuator torque, speed, etc., inducing overload of joint elastic elements or even system instability. Third, existing solutions are only simple splicing of double closed loops, and the control decision, learning optimization, and disturbance suppression are disconnected from each other, causing the NMPC weight adjustment to lag behind the changes in system state, and the control quality cannot be consistently guaranteed.

[0006] In summary, most existing technologies cannot dynamically adjust NMPC weight parameters based on the robot's real-time operating status and coupled disturbances, which severely restricts the full realization of NMPC control performance and makes it difficult to meet the stringent requirements of high-end operation scenarios for control accuracy and robustness. Summary of the Invention

[0007] This invention aims to solve the technical problems of existing PPO+NMPC schemes, such as the inability to effectively suppress coupling disturbances, the easy out-of-bounds instability of weight outputs, and the disconnect between control decision-making, learning optimization, and disturbance suppression caused by the direct splicing of general algorithms. In response, this invention proposes a 2R-type flexible joint robot control method and system.

[0008] To achieve the above-mentioned objectives, the present invention adopts the following technical solution:

[0009] A control method for a 2R-type flexible joint robot, characterized by the following steps:

[0010] Step 1: Set up a disturbance observer on the 2R-type flexible joint robot, collect the sensor measurement signals of the 2R-type flexible joint robot at the current moment, and calculate the system state and the estimated value of the coupled disturbance at the current moment through the disturbance observer; the estimated value of the coupled disturbance is used to characterize the nonlinear disturbances caused by joint hysteresis, clearance and friction of the 2R-type flexible joint robot.

[0011] Step 2: Input the current system state and the estimated coupling perturbation value as state observations into the pre-trained improved PPO policy network. The improved PPO policy network outputs a multi-dimensional weight vector. The improved PPO policy network is the policy network in the improved PPO algorithm framework. The improved PPO algorithm framework introduces a weight constraint penalty term to constrain the output range of the multi-dimensional weight vector in the loss function of the existing PPO algorithm framework, and introduces a coupling perturbation strength penalty term to guide the anti-perturbation optimization in its reward function.

[0012] Step 3: Input the multidimensional weight vector output in Step 2 and the coupling disturbance estimate obtained in Step 1 into the NMPC controller of the 2R flexible joint robot, and obtain the optimal control torque based on the multi-objective cost function of the NMPC controller.

[0013] Step 4: The NMPC controller controls the operation of the 2R flexible joint robot based on the optimal control torque.

[0014] Furthermore, in step 1, the system state includes the joint position on the connecting rod side, the angular velocity on the connecting rod side, the joint position on the motor side, and the angular velocity on the motor side.

[0015] Furthermore, in step 2, the multidimensional weight vector includes the link-side joint position tracking weight coefficient λ1, the link-side angular velocity tracking weight coefficient λ2, the flexible deformation suppression weight coefficient λ3, the control energy consumption weight coefficient λ4, and the coupling disturbance compensation weight coefficient λ5 in the NMPC multi-objective cost function.

[0016] Furthermore, step 3 specifically involves:

[0017] The multidimensional weight vector output in step 2 and the estimated coupled disturbance obtained in step 1 are input into the NMPC controller of the 2R-type flexible joint robot. The NMPC controller uses a sequential quadratic programming algorithm to solve the multi-objective cost function under the constraint of a preset motor torque range, thereby obtaining the optimal control torque.

[0018] The 2R-type flexible joint robot control method according to claim 4 is characterized in that: in step 3, the multi-objective cost function for:

[0019] ;

[0020] in, For position tracking error, For the tracking error of the connecting rod side angular velocity, For flexible deformation error, N c For NMPC control time domain, u is control torque, d is estimated value of coupling disturbance, and k is discrete time step number in control time domain; the position tracking error is the deviation between the actual joint position and the expected joint position on the link side; the link side angular velocity tracking error is the deviation between the actual angular velocity and the expected angular velocity on the link side; the flexible deformation error is the deviation between the actual torsional deformation and the expected torsional deformation of the flexible joint.

[0021] Furthermore, in step 2, the weight constraint penalty term is used to increase the value of the loss function of the improved PPO algorithm framework when the multidimensional weight vector deviates from the corresponding preset constraint boundary, thereby driving the multidimensional weight vector output by the improved PPO policy network to converge to the preset constraint boundary range.

[0022] Furthermore, in step 2, the pre-training of the improved PPO policy network includes the following steps:

[0023] Step A: Initialize the policy network, evaluation network, and experience replay pool in the improved PPO algorithm framework;

[0024] Step B: In the simulation environment, within each control time step of the 2R-type flexible joint robot, the current system state and the estimated value of the coupling disturbance at the current time are input into the improved PPO policy network. The improved PPO policy network outputs the corresponding multi-dimensional weight vector. The multi-dimensional weight vector is input into the NMPC controller to solve for the optimal control torque. The optimal control torque is applied to the 2R-type flexible joint robot to obtain the system state and the estimated value of the coupling disturbance at the next time step.

[0025] Step C: Calculate the immediate reward at the current time step based on the reward function in the improved PPO algorithm framework, and construct a transition tuple to store in the experience replay pool; the transition tuple includes the current system state, the current coupled perturbation estimate, the multidimensional weight vector, the immediate reward, the next system state, and the next coupled perturbation estimate;

[0026] Step D: Sample data in batches from the experience replay pool, calculate the loss function including weight constraint penalty terms using the sampled data, update the policy network based on the calculation result of the loss function, and update the evaluation network synchronously.

[0027] Step E: Repeat steps B to D until the pre-training termination condition is met, and obtain the improved PPO policy network after pre-training is completed.

[0028] A 2R-type flexible joint robot control system, used to implement the above-mentioned 2R-type flexible joint robot control method, is characterized by including:

[0029] The acquisition module is used to acquire the system state and estimated coupling perturbation values ​​of the 2R flexible joint robot at the current moment.

[0030] The input module is used to input the current system state and the estimated coupling perturbation as state observations into the pre-trained improved PPO policy network. The improved PPO policy network outputs a multi-dimensional weight vector. The improved PPO policy network is the policy network in the improved PPO algorithm framework. The improved PPO algorithm framework introduces a weight constraint penalty term to constrain the output range of the multi-dimensional weight vector in the loss function of the existing PPO algorithm framework, and introduces a coupling perturbation strength penalty term to guide the anti-perturbation optimization in its reward function.

[0031] The solution module is used to input the multidimensional weight vector and the estimated value of the coupling disturbance into the NMPC controller of the 2R type flexible joint robot, and obtain the optimal control torque based on the multi-objective cost function of the NMPC controller;

[0032] The NMPC controller controls the operation of the target 2R flexible joint robot based on optimal control torque.

[0033] The beneficial effects of this invention are:

[0034] 1. A constraint feasibility guarantee mechanism is implemented by innovatively introducing a weight constraint penalty term into the loss function of the PPO algorithm framework. This transforms the unconstrained action search space of traditional reinforcement learning into a compact feasible region that satisfies the physical control boundary. This mechanism effectively constrains the eigenvalue range of the weighting matrix in the NMPC controller, fundamentally eliminating the numerical ill-conditioning and control oscillation problems caused by excessively large or small output weights in the original PPO algorithm. This ensures that the rolling optimization process has numerical stability and solution uniqueness at any learning step size.

[0035] 2. Active Disturbance Resistant Cooperative Optimization: By introducing a coupling disturbance strength penalty term into the reward function, the policy network not only pursues the minimization of tracking error but also considers disturbance suppression capability as an important component of long-term rewards. This design gives the weight configuration a clear physical meaning—that is, the weight adjustment process forms a mapping relationship with the real-time estimated coupling disturbance state, guiding the policy network to spontaneously tend towards the parameter region that is insensitive to time-varying external disturbances during exploration, realizing a paradigm shift from passive robustness to active disturbance resistance.

[0036] 3. Dynamic Compensation and Adaptive Fusion: By using the coupled disturbance estimate as the real-time input feature of the improved PPO strategy network, the NMPC controller simultaneously completes two tasks in each rolling time domain: disturbance feedforward compensation and online weight adaptation. These two tasks form a positive feedback synergy: the more accurate the disturbance estimate, the more reasonable the weight adjustment; the more reasonable the weight, the more significant the disturbance compensation effect. Ultimately, under extreme conditions of joint flexibility deformation and sudden load changes, the trajectory tracking accuracy is significantly improved compared to traditional NMPC, overshoot and steady-state error are greatly reduced, and the smoothness of the control quantity and the satisfaction of actuator saturation constraints are maintained throughout the entire task cycle, demonstrating strong engineering practical value. Attached Figure Description

[0037] Figure 1 This is a flowchart of an embodiment of a 2R-type flexible joint robot control method according to the present invention;

[0038] Figure 2 This is a structural schematic diagram of a 2R-type flexible joint robot;

[0039] Figure 3 This is a closed-loop flowchart of the improved PPO-NMPC offline collaborative training architecture with three-ring collaboration in this embodiment of the invention;

[0040] Figure 4 This is a flowchart of the improved PPO-NMPC online real-time control architecture in an embodiment of the present invention.

[0041] Numbering on the map:

[0042] 11. First joint; 12. First link; 21. Second joint; 22. Second link; 3. Second joint motor. Detailed Implementation

[0043] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings and embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0044] In this embodiment of the invention, the 2R-type flexible joint robot adopts a dual-link serial configuration. Each rotary joint is equipped with a harmonic reducer and a torque sensor. Incremental encoders and absolute encoders are installed on the motor side to collect motor position and speed in real time. A high-precision inertial measurement unit (IMU) is installed on the link side to acquire link pose information. The system main control unit adopts a high-performance embedded industrial computer, equipped with an NVIDIA Jetson AGX Xavier computing module, for deploying an improved PPO policy network and an NMPC controller. The underlying servo drive uses EtherCAT bus communication, with a control cycle set to 1ms. Both the NMPC prediction time domain and the NMPC control time domain are set to 20 sampling steps. The optimization solver uses the open-source nonlinear optimization library CasADi in conjunction with the IPOPT solver to solve sequential quadratic programming (SQP).

[0045] The native 8-dimensional system state of the 2R type flexible joint robot is It includes link / motor position and link / motor speed, representing the robot's basic motion conditions. This refers to the joint angle of the first link 12. This refers to the joint angle of the second link 22. The angular velocity of the first link 12 is the lateral velocity of the link. The lateral angular velocity of the second link 22. The output shaft rotation angle of the first joint motor. The output shaft rotation angle of the second joint motor 3, Let be the angular velocity of the motor at the first joint. The angular velocity of the second joint motor 3. Estimated value of the coupled disturbance. The real-time output of the disturbance observation logic within the 2R-type flexible joint robot (including coupled disturbance terms) module characterizes the nonlinear disturbances caused by hysteresis, clearance, and friction of the flexible joint. This coupled disturbance estimate is then concatenated with the 8-dimensional native system state to form an appended... Figure 3 Observation signals marked in the middle (Composed of 8-dimensional system state and coupled perturbation estimates), serving as the perturbation-aware input to the improved PPO weight optimizer.

[0046] The system state acquisition frequency is 1000Hz, and the cutoff frequency of the disturbance observer is designed to be 50Hz to effectively filter out high-frequency measurement noise while retaining the mid-to-low frequency characteristic components of the coupled disturbance. The input state dimension of the improved PPO policy network is 8-dimensional (link-side joint position, link-side angular velocity, motor-side joint position, and motor-side angular velocity), and the output action dimension is 5-dimensional (i.e., five weight coefficients).

[0047] This invention provides a control method for a 2R-type flexible joint robot, such as... Figure 1 As shown, the method includes the following steps:

[0048] Step 1: Set up a disturbance observer on the 2R-type flexible joint robot, collect the sensor measurement signals of the 2R-type flexible joint robot at the current moment, and obtain the system state and coupled disturbance estimate at the current moment through the disturbance observer. The coupled disturbance estimate is used to characterize the nonlinear disturbances caused by joint hysteresis, clearance and friction of the 2R-type flexible joint robot.

[0049] In step 1, a perturbation observer is set up on the 2R-type flexible joint robot. Specifically, a nonlinear perturbation observer based on generalized momentum is adopted, and its design process is as follows:

[0050] First, the dynamic model of the 2R-type flexible joint robot is established as follows:

[0051] ;

[0052] Where M(q) is the inertia matrix, Here is the matrix of Coriolis force and centrifugal force, and G(q) is the gravity term. This is the nonlinear friction term of the joint. This refers to the elastic force / moment term caused by flexible deformation. This is the input torque for the motor. This is an external time-varying disturbance.

[0053] Define generalized momentum The disturbance observer is then designed as follows:

[0054] ;

[0055] ;

[0056] in, This is the estimated value of the coupled perturbation. Let z be the observer gain matrix (a positive definite diagonal matrix), and z be the auxiliary state vector. This is the derivative of the inertia matrix with respect to time. In this embodiment, The diagonal elements are set to [85, 85]. Through experimental parameter tuning, a balance can be achieved between convergence speed and noise suppression.

[0057] Coupled perturbation estimate Comprehensive characterization of nonlinear disturbances caused by gaps and friction.

[0058] In this embodiment, a disturbance observer update is performed once within each control cycle, updating the real-time estimated coupled disturbance values. With system state variables Together they form the state observation vector, which serves as the input to the subsequent improved PPO policy network.

[0059] The aforementioned system states include the link position, link lateral angular velocity, motor position, and motor speed.

[0060] Step 2: Input the current system state and coupled perturbation estimate as state observations into the pre-trained improved PPO policy network. The improved PPO policy network outputs a multi-dimensional weight vector.

[0061] The improved PPO policy network described above is the policy network within the improved PPO algorithm framework. The policy network consists of an input layer (8-dimensional), three hidden layers (256 neurons per layer, with Tanh activation function), and an output layer (5-dimensional, with Sigmoid activation function linearly scaled to fit within a preset constraint boundary). The evaluation network structure is symmetric to the policy network, and the output layer is 1-dimensional (state-value function V(s)). The network weights are initialized using the Xavier initialization method, and the bias terms are initialized to zero.

[0062] The improved PPO algorithm framework described above introduces a weight constraint penalty term to the loss function of the existing PPO algorithm framework to constrain the output range of the multidimensional weight vector, and introduces a coupling perturbation strength penalty term to its reward function to guide perturbation-resistant optimization. The loss function is:

[0063]

[0064] in, Let $\frac{ ... ; To obtain the expected value of the batch data; This is the probability ratio between the old and new strategies, that is, the ratio of the probability of the action under the current strategy to that under the old strategy; The advantage function measures the advantage of the current action relative to the baseline, guiding the direction of policy updates. The shearing function for PPO restricts the probability ratio to... Within a certain range, to prevent excessively large policy update amplitudes and ensure training stability, among which... The preset shear coefficient is 0.2 in this embodiment. The NMPC weight vector output by PPO, corresponding to the appendix Figure 3 middle Signal; The constraint boundary of the weight vector is defined by the upper and lower limits of the weights. and The structure is used to define the valid range of values ​​for the weights; The penalty coefficient for the weight constraint penalty term is a preset positive real number used to control the penalty intensity. As a weight constraint penalty term (the core improvement of this invention), when the weight When the deviation from the constraint boundary occurs, this term will increase the loss function value of the improved PPO algorithm framework, guiding the weights output by the policy network to converge within the constraint range, and avoiding NMPC control instability caused by weights going out of bounds.

[0065] The aforementioned multidimensional weight vector includes the link-side joint position tracking weight coefficient λ1, link-side angular velocity tracking weight coefficient λ2, flexible deformation suppression weight coefficient λ3, control energy consumption weight coefficient λ4, and coupling disturbance compensation weight coefficient λ5 in the NMPC multi-objective cost function.

[0066] The aforementioned weight constraint penalty term L penalty The specific form is as follows:

[0067]

[0068] in, For the i-th weight coefficient output by the policy network, This refers to the preset physical constraint boundaries for this weight. In this embodiment, the constraint boundaries for the five weight coefficients are set as follows: position tracking weight coefficient... Speed ​​tracking weight coefficient Flexible deformation suppression weighting coefficient Control energy consumption weighting coefficient Coupling disturbance compensation weight coefficient These boundary values ​​are determined based on the physical range of the error magnitudes in the NMPC controller, ensuring that all components in the cost function are of the same order of magnitude and avoiding numerical ill-conditioning.

[0069] When the multidimensional weight vector deviates from the corresponding preset constraint boundary, the weight constraint penalty term exhibits a quadratic increase, driving an increase in the loss function value. This forces the multidimensional weight vector output by the improved PPO policy network to converge to the preset constraint boundary range during gradient updates. This mechanism ensures that the control weights remain within a reasonable range at the training level, avoiding the unsolvable NMPC optimization problem or control torque saturation and instability caused by the unconstrained action output of the original PPO.

[0070] The specific design of the aforementioned coupling perturbation strength penalty term is as follows:

[0071] ;

[0072] The first item is the cost of conventional control (tracking error and control energy consumption), and the second item is... This is the coupling perturbation strength penalty term. The disturbance penalty gain is 0.05 in this embodiment. The third term is the L2 norm squared of the perturbation estimate, used to quantify the severity of the coupled perturbation at the current moment; The additional weight sensitivity penalty term (η is 0.01) prompts the policy network to converge to a flat region that is insensitive to changes in perturbation.

[0073] This reward function design enables the policy network to not only minimize tracking error during training, but also implicitly learn that if inappropriate weights are output under strong perturbation, low reward will be obtained immediately. This guides the policy network to optimize weight configuration in the direction of anti-perturbation, realizing closed-loop optimization of "perturbation intensity perception - adaptive weight adjustment".

[0074] The pre-training of the improved PPO policy network described above includes the following steps:

[0075] Step A: Initialize the policy network, evaluation network, and experience replay pool in the improved PPO algorithm framework; specifically: initialize the policy network parameters θ and the evaluation network parameters φ, and clear the experience replay pool (set its capacity to 100,000 transition tuples). Set the PPO training hyperparameters: learning rate. (Using the Adam optimizer, adaptively adjusted), discount factor γ discount =0.99, GAE parameter λ gae =0.95, number of training steps per round T step =2048, PPO update round K epoch =10, MiniBatch_Size=64.

[0076] Step B: In the simulation environment, within each control time step of the 2R-type flexible joint robot, the current system state and the estimated coupling disturbance at the current time are input into the improved PPO policy network. The improved PPO policy network outputs a corresponding multi-dimensional weight vector, which is then input into the NMPC controller to solve for the optimal control torque. The optimal control torque is then applied to the 2R-type flexible joint robot to obtain the system state and the estimated coupling disturbance at the next time step. Specifically:

[0077] Within each control time step k, the current system state is recorded. Coupled perturbation estimate at the current time Commonly composed of state observations Input the improved PPO strategy network π θ The policy network outputs action a. k (i.e., multidimensional weight vector w) k The mean μ(s) and standard deviation σ(s) of the weight vector are obtained through Gaussian sampling to acquire specific action values, and then mapped to a preset constraint boundary through Tanh transformation and linear scaling. Input the NMPC controller and solve for the optimal control torque τ. m '. The optimal control torque τ m 'Applied to a physical or high-fidelity simulation environment of a 2R-type flexible joint robot, the system state at the next moment is obtained through sensor feedback.' And updated through the perturbation observer .

[0078] In this embodiment, the pre-training process adopts a two-stage strategy of "simulation pre-training + physical fine-tuning": First, 2 million steps of simulation pre-training are performed in a high-fidelity physical simulation environment built on PyBullet. Randomly varying load mass (±50% fluctuation), random external impact force, and joint friction parameter perturbations are introduced into the simulation environment to enhance the generalization ability of the strategy. Then, the pre-trained network is migrated to a physical platform for 100,000 steps of online fine-tuning. During the fine-tuning process, the learning rate is reduced to 1 / 10 of the original value to ensure stable convergence.

[0079] Step C: Calculate the immediate reward at the current time step based on the reward function in the improved PPO algorithm framework, and construct a transition tuple to store in the experience replay pool; the transition tuple includes: the current system state, the current estimated coupled perturbation value, the multidimensional weight vector, the immediate reward, the next system state, and the next estimated coupled perturbation value; specifically:

[0080] The instantaneous reward at the current time step is calculated based on the reward function in the improved PPO algorithm framework. Construct transition tuples The data is stored in the experience replay pool. If the experience replay pool is full, the earliest data is overwritten using a first-in, first-out (FIFO) strategy.

[0081] Step D: Sample data in batches from the experience replay pool, calculate a loss function including weight constraint penalty terms using the sampled data, update the policy network based on the calculation result of the loss function, and simultaneously update the evaluation network; specifically:

[0082] Whenever the amount of data in the experience replay pool reaches the batch sampling threshold (in this embodiment, an update is performed every 2048 steps), 64 samples (MiniBatch_Size=64) are randomly sampled from the experience replay pool, and the generalized advantage estimate is calculated. The total loss function, including weight constraint penalties, is calculated using the sampled data. The Adam optimizer is used to perform gradient descent to update the policy network parameters θ, while the mean squared error loss is used to update the evaluation network parameters φ. During the update process, the ratio of the old to new probabilities of the policy network is pruned to the range [0.8, 1.2] to prevent policy collapse due to excessively large update steps.

[0083] Step E: Repeat steps B to D until the pre-training termination condition is met, and obtain the improved PPO policy network after pre-training is completed.

[0084] The termination condition is one of the following three:

[0085] (1) Reach the maximum number of training steps (2 million steps in the simulation stage);

[0086] (2) The average reward value over 100 consecutive rounds converges to above the preset threshold (i.e., the reward fluctuation is less than ±2%).

[0087] (3) The root mean square error of trajectory tracking no longer decreases for 50 consecutive rounds on the validation set. Training is stopped when any condition is met, and the current policy network parameters are saved as a pre-trained improved PPO policy network for direct deployment in the actual control phase.

[0088] Step 3: Combine the multidimensional weight vector w output in Step 2 with the coupling perturbation estimate obtained in Step 1. The input is fed into the NMPC controller of the 2R-type flexible joint robot. The NMPC controller uses a sequential quadratic programming algorithm to solve the multi-objective cost function under the constraint of a preset motor torque range, thereby obtaining the optimal control torque.

[0089] The above objective cost function for:

[0090] ;

[0091] in, For position tracking error, For the tracking error of the connecting rod side angular velocity, For flexible deformation error, N c For NMPC control time domain, u is control torque, d is estimated value of coupling disturbance, and k is discrete time step number in control time domain; position tracking error is the deviation between actual joint position and expected joint position on the link side; link side angular velocity tracking error is the deviation between actual angular velocity and expected angular velocity on the link side; flexible deformation error is the deviation between actual torsional deformation and expected torsional deformation of flexible joint.

[0092] Weighting coefficient The dynamic output of the improved PPO policy network at each step, where These are the coupling disturbance compensation weighting coefficients, which directly affect the disturbance estimate. The penalty term, when the perturbation strength increases, the policy network tends to output a larger value. To enhance the NMPC's ability to compensate for disturbances.

[0093] In this embodiment, the peak torque of the motor is limited to ±15 N·m, and the rate of change of the motor torque is limited to ±50 N·m / s to ensure the physical constraints of the actuator and the safety of the system. The constraints can be expressed as:

[0094] τ min ≤τ m ≤τ max ;

[0095] Where, τ min τ is the minimum allowable output torque limit of the motor. max To determine the maximum allowable torque limit for the motor output, a sequential quadratic programming algorithm (SQP) is used to solve for the optimal torque, ensuring that the control output is safe and feasible.

[0096] In addition, to ensure that the joint's flexible deformation does not exceed the material's elastic limit, the amount of flexible deformation |θ is also constrained. f |≤0.05rad.

[0097] Under the above constraints, the Sequential Quadratic Programming (SQP) algorithm is used to solve the multi-objective cost function in the rolling time domain. The specific implementation steps are as follows: at the current time k, using the current system state as the initial condition, in the prediction time domain N... p =Predict the future output of the system within 20 seconds, solve the optimal control sequence through SQP iteration, and take the first element in the sequence as the optimal control torque output at the current moment to realize the closed-loop control strategy of "rolling optimization and real-time feedback".

[0098] The maximum number of iterations for the SQP algorithm is set to 50, and the convergence tolerance is set to... It can stably complete the solution within a 1ms control cycle, meeting the real-time requirements.

[0099] Step 4: The NMPC controller controls the operation of the target 2R flexible joint robot based on the optimal control torque.

[0100] The NMPC controller will use the optimal control torque τ obtained in step 3. m The torque command is sent to each joint servo driver via the EtherCAT bus. The driver then drives the motor according to the torque command, which in turn moves the flexible joint and linkage to track the desired trajectory. Simultaneously, at the end of each control cycle, the sensors collect new system states in real time and input them into the disturbance observer to update the coupled disturbance estimate. This provides the latest state and disturbance information for the NMPC rolling optimization in the next control cycle, forming a complete real-time control loop of "state acquisition - disturbance estimation - PPO weight generation - NMPC optimization - torque output".

[0101] In a preferred embodiment of the present invention, some key parameters can be adjusted within a reasonable range to adapt to different working conditions:

[0102] Perturbation observer gain K obs The value can be adjusted within the range of [50, 150] according to the measured noise level. The larger the value, the faster the tracking of disturbances, but the sensitivity to noise also increases accordingly.

[0103] The weight constraint penalty coefficient β can be selected between [0.1, 2.0]. The larger the value of β, the more rigid the weight constraint, which improves training stability but may lose some exploratory potential.

[0104] Perturbation penalty gain It can be adjusted between [0.01, 0.2]. The larger the value, the stronger the bias of the strategy network against disturbances, making it suitable for strong disturbance conditions;

[0105] NMPC Prediction Time Domain N p With control time domain N c The range [10,50] can be selected based on the trade-off between system response speed and computing resources. The longer the time domain, the better the global optimization performance, but the computational load increases.

[0106] The values ​​listed in this embodiment are all preferred parameters verified by a large number of experiments, but they do not constitute a limitation on the scope of protection of this invention. Those skilled in the art can make equivalent adjustments without departing from the concept of this invention.

[0107] To verify the practical effectiveness of this invention, a comparative experiment was conducted on a physical platform. The same "∞"-shaped high-speed trajectory tracking task was performed using three different control strategies:

[0108] (1) Traditional fixed-weight NMPC.

[0109] (2) Native PPO-NMPC (unconstrained penalty and disturbance penalty).

[0110] (3) The present invention improves PPO-NMPC.

[0111] Experimental results show that:

[0112] 1. Under the condition of no external interference, all three methods can achieve basic tracking, but the maximum tracking error of the method of this invention is 0.012 rad, which is about 65.7% lower than fixed weight NMPC (0.035 rad) and about 57.1% lower than native PPO-NMPC (0.028 rad).

[0113] 2. When a sinusoidal external torque disturbance with an amplitude of 5 N·m and a frequency of 2 Hz is applied, the maximum tracking error of the method of the present invention is only 0.018 rad, while the error of fixed-weight NMPC rises to 0.089 rad and the error of native PPO-NMPC rises to 0.065 rad. The robustness advantage of the method of the present invention is particularly significant.

[0114] 3. Regarding the smoothness of the control torque, the control torque fluctuation variance of the method of the present invention is 0.42 (N·m)², which is much smaller than 1.35 (N·m)² of fixed weight NMPC and 0.98 (N·m)² of native PPO-NMPC, effectively reducing the impact wear of flexible joints.

[0115] 4. During the period when the weight constraint penalty term is applied, the weight vector output by the policy network is always within the preset constraint boundary and there is no out-of-bounds situation. In contrast, the out-of-bounds rate of the native PPO is 37% under the same number of training steps, which verifies the effectiveness of the constraint mechanism of the present invention.

[0116] The experimental data above fully demonstrate the significant beneficial effects of the proposed method in improving tracking accuracy, enhancing disturbance resistance, and ensuring control stability.

[0117] This invention also provides a 2R-type flexible joint robot control system. In this embodiment, the system is deployed as software modules within the real-time operating system (RT-Linux) of an industrial control computer, and the modules are divided as follows:

[0118] The acquisition module is used to acquire the system state and coupling perturbation estimate of the target 2R flexible joint robot at the current moment.

[0119] The input module takes the current system state and the estimated coupling perturbation as state observations and inputs them into the pre-trained improved PPO policy network. The improved PPO policy network outputs a multi-dimensional weight vector. The improved PPO policy network is the policy network in the improved PPO algorithm framework. The improved PPO algorithm framework introduces a weight constraint penalty term to constrain the output range of the multi-dimensional weight vector in the loss function of the existing PPO algorithm framework, and introduces a coupling perturbation strength penalty term to guide the anti-perturbation optimization in its reward function.

[0120] The solution module is used to input the multidimensional weight vector output in step 2 and the coupled disturbance estimate obtained in step 1 into the NMPC controller of the 2R-type flexible joint robot, and obtain the optimal control torque based on the multi-objective cost function of the NMPC controller.

[0121] The NMPC controller controls the operation of the target 2R flexible joint robot based on optimal control torque.

[0122] The modules communicate using shared memory, with a fixed control cycle of 1ms and an overall closed-loop delay of less than 200μs, meeting real-time control requirements. The system supports manual / automatic mode switching and has a built-in safety monitoring thread that automatically switches to a safe shutdown state when abnormal conditions such as torque over-limit or communication timeout are detected.

[0123] Existing PPO+NMPC solutions all involve directly concatenating general algorithms, which has three fatal flaws:

[0124] (1) Without a coupled disturbance observation and compensation mechanism, it cannot handle disturbances unique to flexible joints.

[0125] (2) The native PPO output weights are unconstrained and are prone to exceeding the limits, leading to control instability.

[0126] (3) It is only a simple splicing of two closed loops, without forming a three-loop synergy of control-learning-disturbance compensation, and control and optimization are disconnected.

[0127] The core innovation of this invention lies in the fact that it does not simply apply PPO to NMPC weight tuning, but proposes an original control scheme of three-ring collaborative architecture + improved PPO for flexible joints + real-time compensation for coupled disturbances, so as to achieve multi-objective dynamic balance and high-precision anti-disturbance control.

[0128] The 2R flexible joint robot control method of this invention is a three-ring cooperative NMPC control method for 2R flexible joint robots based on an improved PPO algorithm. Its core is a three-ring fusion architecture of control-learning-disturbance compensation and an improved PPO algorithm for flexible joints. The offline cooperative pre-training process is attached. Figure 3 As shown, the details are as follows:

[0129] S1: Rigid-flexible coupling dynamics modeling with coupled perturbations.

[0130] Reference Figure 2 An elastic joint model is used to characterize joint flexibility, and a link rotation vector is introduced. Motor rotation angle vector As a generalized coordinate system, a rigid-flexible coupled dynamic model of a 2R flexible joint robot containing coupled perturbation terms is constructed based on the Lagrange equation, and its expression is:

[0131] ;

[0132] in, Here is the system inertia matrix. For Coriolis force and centrifugal force terms, The vector of the gravity term. Here is the joint stiffness matrix. Here is the rotor inertia matrix of the motor. For the motor damping matrix, For motor control input torque, This is a coupled perturbation term used to characterize nonlinear perturbations induced by joint hysteresis, clearance, and friction. The angular velocity vector of the connecting rod. Let be the angular acceleration vector of the link. The angular velocity vector of the motor. This is the angular acceleration vector of the motor.

[0133] S2: Design of NMPC controller with flexible deformation constraints and disturbance compensation.

[0134] The continuous dynamics model is discretized using the fourth-order Runge-Kutta method, and the state transition equations of the system with coupled perturbations are constructed as follows:

[0135] ;

[0136] in, Let k be the system state at time k. To control the input, This is the estimated value of the coupling disturbance.

[0137] S3: An improved PPO weight optimizer for flexible joints.

[0138] The NMPC cost function weight optimization is transformed into a Markov decision process (MDP). The PPO algorithm is improved to suit the characteristics of flexible joint robots by adding weight constraints and disturbance perception mechanisms.

[0139] State observation This includes estimates of the native 8-dimensional system state and coupled perturbations of the 2R robot.

[0140] This invention integrates a coupled disturbance observer within the framework of a dynamic system, aggregating nonlinear effects such as joint hysteresis, clearance, and friction into a total coupled disturbance. A generalized momentum disturbance observation method is used for real-time estimation: using measurable position and velocity signals from the motor side and control input torque as inputs, the estimated coupled disturbance value is calculated through state expansion and feedback correction, and then concatenated with the system's 8-dimensional basic motion state to form the output state observation signal. This observer is built into the dynamic system module, and its output disturbance information is included within... Internally, there is no need to set up a separate external module.

[0141] action corresponding The signal is the 5-dimensional weight vector of the NMPC cost function. Output with upper and lower limit constraints This is to prevent the weights from going out of bounds and causing control instability.

[0142] The reward function r corresponds to the appendix Figure 3 The r in the middle t The immediate reward is a multi-objective penalty-type reward, constructed by comprehensively considering trajectory tracking error, flexible deformation error, control torque amplitude, and coupled disturbance strength. It guides the PPO towards optimization towards "high-precision tracking, low flexible vibration, low control energy consumption, and strong disturbance suppression," expressed as:

[0143] ;

[0144] in, This is an immediate reward value; the higher the value, the better the current control effect. This represents the position tracking error, corresponding to the position error term in the NMPC cost function. The norm of the error is used to quantify the trajectory tracking deviation. This represents the flexible deformation error, corresponding to the flexible deformation term in the NMPC cost function. The norm of the error is used to quantify the joint's flexible vibration intensity. The control torque output by NMPC The norm of torque is used to quantify and control energy consumption. The coupled perturbation estimate comes from... Figure 2 The output of the 2R flexible joint dynamics system (including coupled perturbation terms) module in the middle Signal, The norm of the perturbation intensity is a key improvement of the reward function in this invention; , , and represents the weighting coefficient of each penalty term, and is a preset positive real number used to balance the priority of different optimization objectives.

[0145] This reward function incorporates the coupling perturbation strength into the reward metric, achieving "perturbation-aware" optimization. Compared with traditional reward functions based solely on tracking error, it can guide the PPO agent to actively optimize towards a perturbation-resistant weight configuration, improving the system's robustness under perturbation conditions and enabling linkage with the perturbation compensation loop in the three-ring collaborative architecture.

[0146] The state transition follows the discrete dynamics equations of a 2R flexible joint robot. The system state at the next moment is determined by the current system state, control input, and disturbance estimate; after processing by the disturbance observer, the system state yields the state observation vector, which is the attached... Figure 3 middle Signal, corresponding to the attached Figure 3 middle Signal generation logic.

[0147] The termination condition is reaching the maximum number of steps in a single round, the trajectory tracking error exceeding the preset safety threshold, or the joint flexibility deformation exceeding the limit, triggering the protection mechanism.

[0148] To address the issues of unconstrained weight output and easy boundary violations leading to control instability in the native PPO algorithm, this invention improves the PPO shearing objective function by adding a weight constraint penalty term, thus achieving constrained optimization of NMPC weights. The expression is as follows:

[0149] ;

[0150] in, Let $\frac{ ... ; To obtain the expected value of the batch data; This is the probability ratio between the old and new strategies, that is, the ratio of the probability of the action under the current strategy to that under the old strategy; The advantage function measures the advantage of the current action relative to the baseline, guiding the direction of policy updates. The shearing function for PPO restricts the probability ratio to... Within a certain range, to prevent excessively large policy update amplitudes and ensure training stability, among which... The preset shear coefficient; The NMPC weight vector output by PPO, corresponding to the appendix Figure 3 middle Signal; The constraint boundary of the weight vector is defined by the upper and lower limits of the weights. and The structure is used to define the valid range of values ​​for the weights; The penalty coefficient for the weight constraint penalty term is a preset positive real number used to control the penalty intensity. As a weight constraint penalty term (the core improvement of this invention), when the weight When the weights deviate from the constraint boundary, this term will increase the value of the loss function, guiding the weights output by the policy network to converge within the constraint range, thus preventing the weights from going out of bounds and causing NMPC control instability.

[0151] This improved PPO, based on the original PPO, adds a weight constraint penalty term to the loss function, achieving an improvement from "unconstrained policy output" to "constrained weight optimization." This solves the weight out-of-bounds and control instability problems that easily occur when traditional PPO optimizes NMPC weights. Figure 3 The functional characteristics of the improved PPO weight optimizer module are completely consistent.

[0152] S4: Improved PPO-NMPC three-ring collaborative training process.

[0153] Inputs: Dynamic parameters of the 2R flexible joint robot, initial parameters θ of the policy network, and initial parameters of the evaluation network. Perturbation observer parameters, PPO training hyperparameters (learning rate, batch size, maximum number of training epochs, shearing coefficient) Weight constraint penalty coefficient), NMPC control parameters, and upper and lower weight limits.

[0154] Output: NMPC optimal constraint weight strategy model adapted to 2R flexible joint robots.

[0155] S41: Initialization.

[0156] S411: Initialize policy network parameters Evaluate network parameters Clear the experience replay pool .

[0157] S412: Initialize the disturbance observer and complete the disturbance observation channel calibration.

[0158] S413: Set the PPO algorithm shearing factor Weight constraint penalty coefficient, maximum time step per round T, maximum number of training rounds E.

[0159] S414: Set the range of NMPC weight constraints.

[0160] S42: for training round i = 1: E do.

[0161] S421: Reset the robot control environment and obtain the initial system state. .

[0162] S422: Start the disturbance observer, solve for and output the initial coupled disturbance estimate. .

[0163] S423: for time step t = 1: T do.

[0164] S4231: Change the current system state Coupled perturbation estimates Input policy network.

[0165] S4232: The policy network samples and outputs the original NMPC weight vector.

[0166] S4233: Perform constraint trimming on the weights according to preset upper and lower limits to obtain compliant constraint weights.

[0167] S4234: Set constraint weights Disturbance estimates Input to the NMPC controller.

[0168] S4235: NMPC is based on multi-objective cost functions and torque constraints, and uses SQP to solve for the optimal control torque. .

[0169] S4236: Optimal torque Input the robot's dynamics model to drive the robot's operation.

[0170] S4237: New Status of the Data Acquisition Robot The disturbance observer outputs a new disturbance estimate. .

[0171] S4238: Calculates instantaneous reward by integrating trajectory tracking error, flexible deformation error, control energy consumption, and coupling disturbance strength. .

[0172] S4239: Transfer tuple Store in experience pool .

[0173] S4240: Determine the termination condition: if the trajectory tracking error exceeds the limit / flexible deformation exceeds the limit / maximum time step is reached, exit the current time step loop if the condition is met.

[0174] S424: end for.

[0175] S425: From the experience pool Randomly select a batch of data and calculate the dominance function.

[0176] S426: Update the policy network: Combine the PPO cutoff objective function with the weight constraint penalty term to minimize the policy loss.

[0177] S427: Update the evaluation network: minimize the prediction error of the value function and correct the state value estimate.

[0178] S428: Save the current weight strategy model at fixed intervals.

[0179] S43: end for.

[0180] S44: After training convergence, output the final optimal constraint weight strategy model for three-loop collaborative real-time control.

[0181] like Figure 4 As shown, the online real-time control process is as follows:

[0182] The optimal constraint weight strategy model obtained from offline training is deployed to the controller of the 2R-type flexible joint robot.

[0183] Step 1: Mount a disturbance observer on the 2R-type flexible joint robot to collect the sensor measurement signals of the 2R-type flexible joint robot at the current moment. The disturbance observer calculates the 8-dimensional system state and the estimated value of the coupled disturbance at the current moment. The estimated value of the coupled disturbance is used to characterize the nonlinear disturbances caused by joint hysteresis, gap and friction of the 2R-type flexible joint robot.

[0184] Step 2: Input the current 8-dimensional system state and coupling perturbation estimate as state observations into the pre-trained improved PPO policy network. The improved PPO policy network then infers and outputs the multi-dimensional weight vector corresponding to the 5-dimensional NMPC multi-objective cost function. The improved PPO policy network is the policy network in the improved PPO algorithm framework. The improved PPO algorithm framework introduces a weight constraint penalty term to constrain the output range of the multi-dimensional weight vector in the loss function of the existing PPO algorithm framework, and introduces a coupling perturbation strength penalty term to guide the anti-perturbation optimization in its reward function.

[0185] Step 3: Input the multidimensional weight vector output in Step 2 and the coupling disturbance estimate obtained in Step 1 into the NMPC controller of the 2R type flexible joint robot, and obtain the optimal control torque by solving the multi-objective cost function based on the NMPC controller.

[0186] Step 4: The NMPC controller controls the operation of the 2R flexible joint robot based on the optimal control torque; Steps 1 to 4 are executed cyclically to achieve real-time trajectory tracking and flexible vibration suppression of the robot.

[0187] During the online phase, the improved PPO policy network only performs forward inference, and the parameters of the policy network and evaluation network are fixed. Network parameter updates and experience replay sampling operations are no longer performed.

[0188] This invention constructs a three-loop closed-loop architecture consisting of a control loop, a learning loop, and a disturbance compensation loop, and operates in two stages: pre-training with separation line collaboration and online real-time control.

[0189] Offline collaborative pre-training phase (Figure 3): The three-ring collaboration completes the learning and optimization of the policy model.

[0190] Control loop: corresponding attachment Figure 3 NMPC controller (with flexible deformation constraints).

[0191] The control loop is the core execution unit of the system, corresponding to the attached... Figure 3 The NMPC controller is labeled on the right:

[0192] Receive attachment Figure 3 The output of the improved PPO weight optimizer Signal (5-dimensional weight vector);

[0193] Combined with appendix Figure 3 The output of the 2R flexible joint dynamics system (with built-in coupled perturbation observation module) Estimated coupling perturbations in the signal, and a multi-objective cost function with perturbation compensation is constructed;

[0194] The optimal torque is obtained by solving the problem. and output to the attached Figure 3 The 2R flexible joint dynamic system on the left side drives the robot's movement, achieving trajectory tracking and flexible vibration suppression.

[0195] Learning cycle: corresponding appendix Figure 3 An improved PPO weight optimizer with a multi-objective reward calculation module.

[0196] The learning loop is the adaptive optimization unit of the system, corresponding to the attached... Figure 3 The improved PPO weight optimizer in the middle and the multi-objective reward calculation module below (perturbation-aware):

[0197] Receive attachment Figure 3 The output of the 2R flexible joint dynamic system The signal (8-dimensional basic state + coupled perturbation estimate) serves as a perturbation-aware state observation.

[0198] Simultaneously receive attachments Figure 3 The output of the multi-objective reward calculation module Signals (instant rewards) are used to update the policy network;

[0199] Output constrained weighted signals Send to attached Figure 3 The NMPC controller on the right side enables online adaptive optimization of the NMPC cost function weights.

[0200] Disturbance compensation loop: corresponding appendix Figure 3 The coupled disturbance observation module is built into the 2R flexible joint dynamics system.

[0201] The disturbance compensation loop is the system's disturbance rejection support unit, corresponding to the attached... Figure 3 The 2R flexible joint dynamic system on the left side of the middle section:

[0202] The nonlinear coupling perturbation estimate of the flexible joint is calculated in real time and spliced ​​with the basic state of the 8-dimensional system to generate an additional value. Figure 3 The middle label is The signal.

[0203] Will Signal output to the attached Figure 3 The improved PPO weight optimizer module in the middle provides perturbation-aware input to the learning loop.

[0204] At the same time, it is attached Figure 3 The NMPC controller (with flexible deformation constraints) module on the right side provides disturbance information support, realizes disturbance compensation for NMPC control, and forms a closed-loop linkage of "disturbance perception-optimization-control".

[0205] As attached Figure 3 As shown, the system implements real-time iteration of the three loops according to the following signal flow:

[0206] Appendix Figure 3 NMPC controller output The signal is sent to the 2R flexible joint dynamics system to drive the robot's operation.

[0207] The 2R flexible joint dynamics system generates a new state and outputs... The signal is sent to the improved PPO weight optimizer, and the output is simultaneously... Signal to multi-target reward calculation module.

[0208] The multi-objective reward calculation module is based on generate The signal is fed back to the improved PPO weight optimizer.

[0209] Improved PPO weight optimizer output The signal is sent to the NMPC controller, completing one closed-loop iteration;

[0210] Through the above signal flow loop, the control loop, learning loop, and disturbance compensation loop are deeply coordinated to achieve high-precision trajectory tracking and flexible vibration suppression of the 2R flexible joint robot.

[0211] Online real-time control stage (attached) Figure 4The three-loop architecture continues to operate, but the learning loop only performs forward inference, the policy network parameters are fixed and no longer updated, and there is no reward calculation or network parameter update operation. The control loop and disturbance compensation loop maintain closed-loop operation; the learning loop receives the system state and coupled disturbance estimates, directly outputs the NMPC cost function weight vector and sends it to the NMPC controller to complete real-time trajectory tracking and vibration suppression.

[0212] Enhanced architectural synergy: A three-loop fusion architecture of control-learning-disturbance compensation is proposed to achieve closed-loop linkage of NMPC control, PPO weight optimization and coupled disturbance compensation, solving the problems of disconnection between traditional control and learning links and the inability to provide synchronous disturbance feedback, thereby improving the overall control coordination and response speed of the system.

[0213] Smarter Adaptive Weight Tuning: Through PPO reinforcement learning, the weights of the NMPC cost function are output online adaptively, eliminating the need for manual parameter adjustments. The weight configuration can be autonomously optimized based on the robot's real-time operating status and working conditions, significantly improving control adaptability.

[0214] More outstanding anti-disturbance and vibration suppression effects: Combined with the coupled disturbance observation and compensation mechanism, it can effectively suppress elastic vibration caused by the nonlinear characteristics of flexible joints. It can still maintain high trajectory tracking accuracy under conditions such as external torque disturbance and model parameter mismatch, and has stronger robustness.

[0215] More stable and reliable control operation: The PPO weight output adopts constraint limitation to avoid the control instability caused by the weight going out of bounds; combined with the PPO algorithm to cut the objective function, it effectively avoids the problem of traditional optimization algorithms getting trapped in local optima, and the control process is more stable.

[0216] More balanced multi-objective control: It takes into account multiple objectives such as trajectory tracking accuracy, flexible vibration suppression, control energy consumption and disturbance suppression, and can dynamically balance various control indicators according to actual working conditions to adapt to high-precision operation requirements.

[0217] Easier to implement in engineering: Based on the conventional rigid-flexible coupling dynamic model, there is no need to make complex improvements to the modeling process. The algorithm is clear and easy to reproduce, and can be directly deployed on 2R flexible joint robots, which has good engineering application value.

[0218] Improved PPO-NMPC trajectory tracking control for 2R robots through three-ring collaborative design.

[0219] This embodiment uses a two-degree-of-freedom flexible articulated robot as the controlled object to perform a preset planar trajectory tracking task. It employs a three-loop coordinated operation of a control loop, a learning loop, and a disturbance compensation loop, relying on an improved PPO to achieve online NMPC weight optimization, simultaneously completing coupled disturbance compensation and flexible vibration suppression. The specific implementation steps are as follows:

[0220] Step 1: Build a dynamic model of a 2R robot with coupled perturbations.

[0221] A rigid-flexible coupled dynamic model of a 2R flexible joint robot is constructed based on the Lagrange equation. Coupled disturbance terms are introduced to characterize the joint hysteresis, clearance, and friction nonlinearity. Key parameters of the model are obtained through parameter identification, a disturbance observer is built, and the coupled disturbance estimates are calculated and output in real time, providing basic data for three-ring coordinated control.

[0222] Step 2: Build an NMPC controller with disturbance compensation.

[0223] The dynamic model was discretized using the fourth-order Runge-Kutta method, and the system state transition equations were constructed. A multi-objective cost function was designed, which includes trajectory tracking, flexible deformation suppression, control energy consumption and disturbance compensation, and motor torque safety constraints were set. The optimal control torque was solved using a sequential quadratic programming algorithm, which serves as the core execution unit of the control loop.

[0224] Step 3: Train the improved PPO weight optimizer.

[0225] The NMPC weight optimization is transformed into a perturbation-aware Markov decision process, with the robot system state and coupled perturbation estimates as inputs and constrained NMPC four-dimensional weights as outputs. A perturbation-aware multi-objective reward function is constructed, an Actor-Critic dual-network architecture is built, and an improved PPO algorithm is used to complete policy iterative training to obtain the optimal weight decision model, which serves as the core optimization unit of the learning loop.

[0226] Step 4: Execute three-ring coordinated trajectory tracking control.

[0227] Initiating coordinated control of the three loops: control loop, learning loop, and disturbance compensation loop.

[0228] Disturbance compensation loop: Real-time output of coupled disturbance estimates, synchronously fed back to the NMPC controller and the improved PPO optimizer.

[0229] Learning loop: The improved PPO outputs constrained optimal weights online based on system state and disturbance information.

[0230] Control loop: NMPC outputs optimal torque to drive the robot's operation based on optimized weights and disturbance compensation.

[0231] The system achieves high-precision trajectory tracking of the 2R flexible joint robot through three-loop real-time closed-loop iteration, while realizing active suppression of flexible vibration and real-time compensation of coupled disturbances, maintaining stable control performance under disturbed conditions.

[0232] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present invention should be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A control method for a 2R-type flexible joint robot, characterized in that, Includes the following steps: Step 1: Set up a disturbance observer on the 2R-type flexible joint robot, collect the sensor measurement signals of the 2R-type flexible joint robot at the current moment, and calculate the system state and the estimated value of the coupled disturbance at the current moment through the disturbance observer; The coupled perturbation estimate is used to characterize the joint hysteresis, clearance, and nonlinear perturbation caused by friction in the 2R-type flexible articulated robot. Step 2: Input the current system state and the estimated coupling perturbation value as state observations into the pre-trained improved PPO policy network. The improved PPO policy network outputs a multi-dimensional weight vector. The improved PPO policy network is the policy network in the improved PPO algorithm framework. The improved PPO algorithm framework introduces a weight constraint penalty term to constrain the output range of the multi-dimensional weight vector in the loss function of the existing PPO algorithm framework, and introduces a coupling perturbation strength penalty term to guide the anti-perturbation optimization in its reward function. Step 3: Input the multidimensional weight vector output in Step 2 and the coupling disturbance estimate obtained in Step 1 into the NMPC controller of the 2R flexible joint robot, and obtain the optimal control torque based on the multi-objective cost function of the NMPC controller. Step 4: The NMPC controller controls the operation of the 2R flexible joint robot based on the optimal control torque.

2. The control method for the 2R-type flexible joint robot according to claim 1, characterized in that: In step 1, the system state includes the joint position of the connecting rod side, the angular velocity of the connecting rod side, the joint position of the motor side, and the angular velocity of the motor side.

3. The control method for the 2R-type flexible joint robot according to claim 2, characterized in that: In step 2, the multidimensional weight vector includes the link-side joint position tracking weight coefficient λ1, the link-side angular velocity tracking weight coefficient λ2, the flexible deformation suppression weight coefficient λ3, the control energy consumption weight coefficient λ4, and the coupling disturbance compensation weight coefficient λ5 in the NMPC multi-objective cost function.

4. The control method for a 2R-type flexible joint robot according to claim 1, characterized in that, Step 3 specifically involves: The multidimensional weight vector output in step 2 and the estimated coupled disturbance obtained in step 1 are input into the NMPC controller of the 2R-type flexible joint robot. The NMPC controller uses a sequential quadratic programming algorithm to solve the multi-objective cost function under the constraint of a preset motor torque range, thereby obtaining the optimal control torque.

5. The control method for a 2R-type flexible joint robot according to claim 4, characterized in that: In step 3, the multi-objective cost function for: ; in, For position tracking error, For the tracking error of the connecting rod side angular velocity, For flexible deformation error, N c For NMPC control time domain, u is control torque, d is estimated value of coupling disturbance, and k is discrete time step number in control time domain; the position tracking error is the deviation between the actual joint position and the expected joint position on the link side; the link side angular velocity tracking error is the deviation between the actual angular velocity and the expected angular velocity on the link side; the flexible deformation error is the deviation between the actual torsional deformation and the expected torsional deformation of the flexible joint.

6. The control method for a 2R-type flexible joint robot according to claim 1, characterized in that: In step 2, the weight constraint penalty term is used to increase the value of the loss function of the improved PPO algorithm framework when the multidimensional weight vector deviates from the corresponding preset constraint boundary, thereby driving the multidimensional weight vector output by the improved PPO policy network to converge to the preset constraint boundary range.

7. The control method for a 2R-type flexible joint robot according to claim 6, characterized in that, Step 2, the pre-training of the improved PPO policy network includes the following steps: Step A: Initialize the policy network, evaluation network, and experience replay pool in the improved PPO algorithm framework; Step B: In the simulation environment, within each control time step of the 2R-type flexible joint robot, the current system state and the estimated value of the coupling disturbance at the current time are input into the improved PPO policy network. The improved PPO policy network outputs the corresponding multi-dimensional weight vector. The multi-dimensional weight vector is input into the NMPC controller to solve for the optimal control torque. The optimal control torque is applied to the 2R-type flexible joint robot to obtain the system state and the estimated value of the coupling disturbance at the next time step. Step C: Calculate the immediate reward at the current time step based on the reward function in the improved PPO algorithm framework, and construct a transition tuple to store in the experience replay pool; the transition tuple includes the current system state, the current coupled perturbation estimate, the multidimensional weight vector, the immediate reward, the next system state, and the next coupled perturbation estimate; Step D: Sample data in batches from the experience replay pool, calculate the loss function including weight constraint penalty terms using the sampled data, update the policy network based on the calculation result of the loss function, and update the evaluation network synchronously. Step E: Repeat steps B to D until the pre-training termination condition is met, and obtain the improved PPO policy network after pre-training is completed.

8. A 2R-type flexible joint robot control system, used to implement the 2R-type flexible joint robot control method according to any one of claims 1-7, characterized in that, include: The acquisition module is used to acquire the system state and estimated coupling perturbation values ​​of the 2R flexible joint robot at the current moment. The input module is used to input the current system state and the estimated coupled perturbation as state observations into the pre-trained improved PPO policy network. The improved PPO policy network outputs a multi-dimensional weight vector. The improved PPO policy network is the policy network in the improved PPO algorithm framework; the improved PPO algorithm framework introduces a weight constraint penalty term to constrain the output range of the multidimensional weight vector in the loss function of the existing PPO algorithm framework, and introduces a coupling perturbation strength penalty term to guide the anti-perturbation optimization in its reward function. The solution module is used to input the multidimensional weight vector and the estimated value of the coupling disturbance into the NMPC controller of the 2R type flexible joint robot, and obtain the optimal control torque based on the multi-objective cost function of the NMPC controller; The NMPC controller controls the operation of the target 2R flexible joint robot based on optimal control torque.