Mechanical arm path planning method and device based on improved DDPG algorithm and medium

By combining the improved DDPG algorithm with HER technology, the problems of low learning efficiency and slow convergence speed of robotic arms in sparse reward environments are solved, realizing efficient and flexible path planning and control, and adapting to complex and ever-changing dynamic environments.

CN119036449APending Publication Date: 2024-11-29SHANGHAI UNIVERSITY OF ELECTRIC POWER

Patent Information

Application Number
CN202411190548.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2024-11-29

Smart Images

  • Figure CN119036449A_ABST
    Figure CN119036449A_ABST
Patent Text Reader

Abstract

The invention relates to a mechanical arm path planning method and device based on an improved DDPG algorithm and a medium, and the method comprises the following steps: obtaining initial information and target point information of a mechanical arm, inputting a trained mechanical arm path planning model, and obtaining a mechanical arm path planning result; wherein the mechanical arm path planning model comprises a mechanical arm state space, a mechanical arm action space and a reward function, and the mechanical arm state space comprises a three-dimensional coordinate of the tail end of the mechanical arm, a three-dimensional coordinate of a target point and an attitude angle of an actuator at the tail end of the mechanical arm; the mechanical arm action space comprises a displacement vector of the tail end of the mechanical arm, a rotating attitude angle of an actuator at the tail end of the mechanical arm and an opening and closing state of a clamping jaw at the tail end of the mechanical arm; the mechanical arm path planning model is trained by introducing an improved DDPG algorithm of an HER technology, the state of a mechanical arm reaching or not reaching a target point is calibrated as a potential target state, and a reward value is calculated according to the potential target state. Compared with the prior art, efficient mechanical arm path planning can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of robot arm control, and in particular relates to a robot arm path planning method, device and medium based on an improved DDPG algorithm. Background Art

[0002] In the field of industrial automation and intelligent manufacturing, the widespread use of robotic arms requires them to have efficient and accurate path planning capabilities in order to complete tasks in complex and changing working environments. Existing robotic arm path planning methods mostly rely on predefined paths or complex sensor systems. These methods show limitations when dealing with dynamic and uncertain environments and are difficult to adapt to the needs of complex tasks. Especially in unstructured environments, robotic arm path planning faces many challenges, such as uncertainty in workpiece position, limitations in workspace, and dynamic changes in the environment.

[0003] Although the existing sensor-based path planning methods can provide real-time environmental information, the high dimensionality and noise problems of sensor data bring additional challenges to path planning. In addition, traditional path planning algorithms have problems such as slow convergence speed and poor stability when dealing with continuous action space, which affects the operating efficiency and reliability of the robot in practical applications. In order to solve these problems, researchers have proposed some robot path planning methods based on reinforcement learning. Chinese patent application 202310657299.7 discloses a robot control method based on deep reinforcement learning, designs an adaptive servo gain algorithm based on deep deterministic policy gradient (DDPG), and adaptively adjusts the servo gain of the controller (SMCC-IBVS) through deep reinforcement learning to reduce servo error and improve stability. The DDPG algorithm improves the path planning ability of the robot in a dynamic environment to a certain extent by combining the advantages of deep learning and deterministic policy gradient. However, the DDPG algorithm still has certain limitations, especially in the case of sparse rewards, the learning efficiency and convergence speed of the algorithm are greatly affected. Therefore, it is necessary to redesign a robot path planning method to achieve efficient robot control. Summary of the invention

[0004] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a robot arm path planning method, device and medium based on the improved DDPG algorithm to solve the sparse reward problem and realize efficient robot arm path planning.

[0005] The purpose of the present invention can be achieved by the following technical solutions:

[0006] The present invention provides a robot arm path planning method based on an improved DDPG algorithm, comprising the following steps:

[0007] Obtain the initial information and target point information of the robot arm, input the trained robot arm path planning model, and obtain the robot arm path planning result;

[0008] The robot path planning model includes a robot state space, a robot action space and a reward function. The robot state space includes the three-dimensional coordinates of the end of the robot, the three-dimensional coordinates of the target point and the attitude angle of the end effector of the robot. The robot action space includes the displacement vector of the end of the robot, the rotation attitude angle of the end effector of the robot and the opening and closing state of the gripper at the end of the robot.

[0009] The robot path planning model is trained by an improved DDPG algorithm that introduces HER technology. The improved DDPG algorithm that introduces HER technology calibrates the state of the robot that reaches or fails to reach the target point as a potential target state, and calculates the reward value based on the reward function and the potential target state.

[0010] Furthermore, the robot arm path planning model is constructed based on a dynamic model of the robot arm, and the dynamic model of the robot arm is constructed based on a kinematic model of the robot arm.

[0011] Furthermore, the improved DH method is used to establish the kinematic model of the robot arm. The specific process is as follows:

[0012] A coordinate system is established at the head end of each link of the robotic arm, and the relationship between each joint and link of the robotic arm is described by DH parameters to establish a kinematic model of the robotic arm. The DH parameters include link length, torsion angle, link offset and joint angle.

[0013] Furthermore, the reverse engineering method is used to construct the dynamic model of the robotic arm. The specific process is as follows:

[0014] Based on the kinematic model of the robotic arm, the dynamic data of the robotic arm, including the inertia matrix and gravity vector of the robotic arm, is calculated, a symbolic regression matrix is ​​constructed, the dynamic coefficients are obtained by the least squares method, the forward kinematics equation is established, and the inverse kinematics equation is derived according to the Lagrange equation to obtain the dynamic model of the robotic arm.

[0015] Furthermore, the improved DDPG algorithm introducing the HER technology includes an Actor network, a Target Actor network, a Critic network, and a Target Critic network. The specific process of training the robot path planning model by the improved DDPG algorithm introducing the HER technology is as follows:

[0016] Get the current state s of the robot from the robot state space t , according to the current state of the robot t, select the current action a of the robot from the action space of the robot through the Actor network t , a t =μ(s t |θ μ )+N t , where μ is the Actor network, N t is the noise, θ μ Parameters of the Actor network;

[0017] Execute the current action of the robot arm a t , get the next state s of the robot t+1 , the next state of the robot arm is s t+1 The potential target state g is calibrated, and the corresponding reward r is calculated according to the reward function and the potential target state g. t , the information tuple (s t ,a t ,r t ,s t+1 ,g) stored in the experience pool;

[0018] Calculate the next state s of the robot arm through the Target Actor network t+1 The corresponding robot arm motion μ′(s i+1 ), where μ′ is the Target Actor network;

[0019] Randomly extract N groups of samples from the experience pool and calculate the state-action pairs (s t+1 ,μ′(s i+1 ))’s target Q value y i , calculate the state-action pair (s t ,a t )’s Q value Q(s) i ,a i |θ Q ), where Q is the Critic network, θ Q is the parameter of the Critic network;

[0020] Construct the loss function L based on the target Q value and Q value, and use the gradient descent method to update the parameters θ of the Actor network μ and the parameters θ of the Critic network Q ;

[0021] Use soft update to update the parameters θ of the Target Actor network μ′ and the parameter θ of the Target Critic network Q′ . Further, the action pair (s t+1 ,a t+1)’s target Q value y i The calculation formula is as follows:

[0022] y i =r i +γQ′(s i+1 ,μ′(s i+1 ,θ μ′ )|θ Q′ )

[0023] Among them, γ is the discount factor of the reward, Q′ is the Target Critic network, θ Q′ are the parameters of the Target Critic network.

[0024] Furthermore, the expression of the loss function L is as follows:

[0025]

[0026] Furthermore, the soft update method is used to update the parameters θ of the Target Actor network. μ′ and the parameter θ of the Target Critic network Q′ The specific process is as follows:

[0027] θ Q′ ←τθ Q +(1-τ)θ Q′

[0028] θ μ′ ←τθ μ +(1-τ)θ μ′

[0029] Among them, τ is the parameter update rate.

[0030] The present invention also provides an electronic device, comprising a memory, a processor, and a program stored in the memory, wherein the processor implements the above method when executing the program.

[0031] The present invention also provides a computer-readable storage medium on which a computer program is stored, and the program implements the above method when executed by a processor.

[0032] Compared with the prior art, the present invention has the following beneficial effects:

[0033] 1. The present invention provides a robot path planning method based on an improved DDPG algorithm. The robot initial information and target point information are input into a trained robot path planning model to obtain a robot path planning result. The robot path planning model includes a robot state space, a robot action space and a reward function. The robot state space includes the three-dimensional coordinates of the end of the robot, the three-dimensional coordinates of the target point and the attitude angle of the end effector of the robot. The robot action space includes the displacement vector of the end of the robot, the rotation attitude angle of the end effector of the robot and the opening and closing state of the end gripper of the robot. The robot state space and the robot action space can accurately describe the static characteristics and dynamic capabilities of the robot, and improve the control accuracy and flexibility. The robot path planning model is trained by an improved DDPG algorithm that introduces HER technology. HER technology is an experience playback technology. The improved DDPG algorithm that introduces HER technology calibrates the robot state that reaches or does not reach the target point as a potential target state. The reward value is calculated based on the reward function and the potential target state. The existing experience can be fully utilized to obtain more training samples, solve the sparse reward problem, speed up the model training speed, enhance the adaptability and robustness of the algorithm, and realize efficient robot path planning.

[0034] 2. The present invention adopts an improved DH method to establish the kinematic model of the robotic arm. By adding a virtual coordinate system, the description of the relative position relationship between the links of the robotic arm is simplified, the complexity of modeling is reduced, and it is suitable for robotic arms with multiple degrees of freedom. It simplifies the subsequent establishment and solution process of the kinematic equations of the robotic arm. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 This is a flow chart of the traditional DDPG algorithm.

[0036] Among them, optimizer is the optimizer;

[0037] Figure 2 This is a schematic diagram of the Franka Emika Panda robotic arm.

[0038] Among them, d1, d3, d5, d f is the connecting rod length;

[0039] Figure 3 This is a schematic diagram of a custom simulation environment;

[0040] Figure 4 This is a comparison chart of multiple factors between the effect of a single DDPG model and the effect of a model optimized with DDPG+HER.

[0041] Among them, (4a) corresponds to ep_len_mean, which indicates the average number of steps per episode (round), (4b) corresponds to ep_rew_mean, which indicates the average total reward per episode, (4c) corresponds to success_rate, which indicates the average rate of successful task completion, (4d) corresponds to fps, which indicates the number of frames per second, (4e) corresponds to actor_loss, which indicates the Actor network loss, (4f) corresponds to critic_loss, which indicates the Critic network loss, and (4g) corresponds to learning_rate, which indicates the learning rate;

[0042] Figure 5 This is a schematic diagram of a custom obstacle avoidance task. DETAILED DESCRIPTION

[0043] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.

[0044] Example:

[0045] This embodiment provides a robot arm path planning method based on an improved DDPG algorithm, comprising the following steps: obtaining the initial information of the robot arm (including the three-dimensional coordinates of the end of the robot arm, the attitude angle of the end effector of the robot arm, etc.) and the target point information (including the three-dimensional coordinates of the target point, spatial attitude, etc.), inputting the trained robot arm path planning model, and obtaining the robot arm path planning result.

[0046] This embodiment is based on Figure 2 The Franka Emika Panda robot arm shown in the figure is modeled. Franka EmikaPanda is a high-precision lightweight robot designed and developed by the German company Franka Emika. It has 7 degrees of freedom, can flexibly perform various tasks, and has precise force control capabilities. It also supports drag-and-drop teaching operations. The auxiliary programming software can improve programming efficiency. It is superior to other robot arms in terms of ease of use and playability. In order to meet research needs, Franka provides an open source interface, and users can program through C++ and ROS. In addition to the scientific research field, it is also suitable for industrial automation and other fields, such as fine-controlled assembly, screwing and connection, as well as testing, inspection and assembly. It is a collaborative robot arm that integrates high precision, flexibility and safety. The construction process of the robot arm path planning model is as follows:

[0047] S101. Use the improved DH method to establish the kinematic model of the robot arm.

[0048] The DH method, or Denavit-Hartenberg parameter method, is a standard method for describing and calculating the kinematics of serial manipulators. The improved DH method establishes a coordinate system at the head end of each link of the manipulator, describes the relationship between each joint and link of the manipulator through DH parameters, and establishes the kinematic model of the manipulator. The DH parameters include the link length d i , torsion angle α i , connecting rod offset a i and the joint angle θ i , as shown in Table 1.

[0049] Table 1D-H parameters

[0050]

[0051] The robotic arm has seven revolute joints, each equipped with a torque sensor that provides measurements of torque, position, and velocity at each joint.

[0052] S102. Use reverse engineering methods to construct a dynamic model of the robotic arm.

[0053] Based on the kinematic model of the robot arm, the dynamic data of the robot arm is calculated, including the inertia matrix M(q) and gravity vector g(q) of the robot arm, and a symbolic regression matrix is ​​constructed. The dynamic coefficient π is obtained by the least squares method, and the forward kinematic equation is established:

[0054]

[0055] Where q is the joint position, is the joint velocity, is the joint acceleration, are the vectors of the Coriolis force and the centrifugal force.

[0056] Using the estimated dynamic coefficient π, the inverse kinematics equation is derived according to the Lagrange equation to obtain the dynamic model of the robot arm. The inverse kinematics equation is as follows:

[0057]

[0058] in, is the estimated inertia matrix, are the estimated Coriolis and centrifugal forces, is the estimated gravity vector.

[0059] Verification results show that the extracted dynamic parameters can be used for accurate inverse dynamics calculations and Newton-Euler recursive calculations, thus verifying the feasibility of the parameters.

[0060] S103. Construct a robot arm path planning model based on the dynamics model of the robot arm.

[0061] The DH method and the robot dynamics model provide data to support the establishment of a robot path planning model. The robot path planning model includes the robot state space, the robot action space and the reward function.

[0062] (1) Robotic arm state space

[0063] The state of the robot arm at time t is s t , can be expressed as a triple: s t =(pos t ,quat t , c), where is the three-dimensional coordinate of the end of the robot arm, c is the three-dimensional coordinate of the target point, quat t =(w qt , x qt ,y qt , z qt ) is the attitude angle of the end effector of the robot arm.

[0064] (2) Robotic arm motion space

[0065] The action of the robot arm at time t is a t , can be expressed as a triple: a t =(ΔP t , ΔO t , g t ), where ΔP t =(Δx pt , Δy pt , Δz pt ) is the displacement vector of the end of the robot arm, ΔO t =(Δx ot , Δy ot , Δz ot ) is the rotation angle of the end effector of the robot arm, g t It is the opening and closing status of the gripper at the end of the robot arm.

[0066] (3) Reward Function

[0067] The reward function reflects the t Take action a t The expected reward obtained when , is expressed as:

[0068] R(s t ,a t )=E π [R t+1 |s t =t,a t =a]

[0069] By default, the reward is sparse: if the end gripper is at the desired position (with a tolerance of 5cm), it gets a reward of 0, otherwise it gets a reward of -1. For each environment, there is a variant with dense rewards: this reward is the inverse of the distance between the entity to be moved and the desired position.

[0070] In general, sparse reward functions are easier to define, but in the case of sparse rewards, the traditional DDPG algorithm has the problems of low learning efficiency and slow convergence. In reinforcement learning, experience replay is a technique to improve learning efficiency by storing the historical experience of the agent's interaction with the environment in a buffer, and then randomly extracting samples from the buffer to update the model during training. In this embodiment, the robot path planning model is trained by introducing an improved DDPG algorithm with HER (Hindsight Experience Replay) technology. HER is a special type of experience replay buffer. Its basic idea is to train the agent by replaying other possible target states when the agent does not directly achieve the goal. This method can utilize the experience that the agent has already gained, and can provide the agent with useful learning signals even when the original goal is not achieved. Its key innovation is to allow the agent to generate multiple samples for each possible goal from the same experience.

[0071] The process of the traditional DDPG algorithm is as follows Figure 1 As shown, it includes Actor network (realistic strategy network), Target Actor network (target strategy network), Critic network (realistic evaluation network) and Target Critic network (target evaluation network). The algorithm includes the following steps:

[0072] S201, get the current state of the robot arm s t , combined with the Actor network and noise N t , select the current action a of the robot from the robot action space t And pass it to the simulation environment for execution, a t =μ(s t |θ μ )+N t , where μ is the Actor network, θ μ Parameters for the Actor network.

[0073] S202, execute the current action a of the robot arm t After that, the next state s of the robot is obtained t+1 , calculate the corresponding reward r according to the reward function t , the information tuple (s t ,a t ,rt ,s t+1 ) is stored in the experience pool.

[0074] S203, randomly selecting N groups of samples from the experience pool;

[0075] S204, calculate the next state s of the robot arm through the Target Actor network t+1 The corresponding robot arm motion μ′(s i+1 ), where μ′ is the Target Actor network; the state-action pair (s t+1 ,μ′(s i+1 ))’s target Q value y i :

[0076] y i =r i +γQ′(s i+1 ,μ′(s i+1 ,θ μ′ )|θ Q′ )

[0077] Among them, γ is the discount factor of the reward, Q′ is the Target Critic network, θ Q′ are the parameters of the Target Critic network.

[0078] The state-action pair (s) is calculated by the Critic network t ,a t )’s Q value Q(s) i ,a i |θ Q ), where Q is the Critic network, θ Q For the parameters of the Critic network, define the loss function L:

[0079]

[0080] Calculate the gradient of the loss function L, set the learning rate of the Critic network, and update the parameters θ of the Critic network Q .

[0081] S205. Calculate the gradient of the Actor network:

[0082]

[0083] Set the learning rate of the Actor network in the optimizer and update the parameters θ of the Actor network by gradient descent. μ .

[0084] S206, update the parameters θ of the Target Actor network using soft update μ′ and the parameter θ of the Target Critic network Q′ :

[0085] θ Q′ ←τθ Q +(1-τ)θ Q′

[0086] θ μ′ ←τθ μ +(1-τ)θ μ′

[0087] Among them, τ is the parameter update rate.

[0088] The integration of HER technology into the DDPG algorithm is mainly reflected in the modification of the experience replay mechanism: In the traditional DDPG algorithm, experience replay usually involves storing (state, action, reward, next state) information tuples, that is, (s y ,a t ,r t ,s t+1 ). After the introduction of HER, at each time step, when the robot arm performs an action and reaches a new state, regardless of whether this new state is the final goal, the new state is marked as the potential target state g, and the corresponding reward r is calculated based on the reward function and the potential target state g (rather than the original target state). t , the information tuple (s t ,a t ,r t ,s t+1 ,g) stored in the experience pool, which means that even if the original task fails, HER will replay this experience, and the robot arm can get positive feedback from each experience. For each recalibrated experience, the Actor network will try to find a better strategy to reach these target states, and the Critic network will learn to evaluate the value of these strategies accordingly.

[0089] The introduction of HER can improve the performance of the DDPG algorithm in many ways. First, it can solve the sparse reward problem. HER can provide more learning signals to the robot arm by replaying other possible target states, which helps to overcome the problem of sparse rewards. Second, it can improve learning efficiency. HER allows the robot arm to generate multiple samples for each possible target from the same experience, which greatly improves learning efficiency. At the same time, it can also enhance the generalization ability of the strategy. Through HER, the robot arm can learn from the states that achieve other goals and can better understand the relationship between different goals. Finally, it can reduce sample complexity. HER reduces the number of samples required by generating multiple samples for each possible target, thereby reducing sample complexity.

[0090] To verify the effectiveness of the above method, this embodiment conducted a simulation experiment, and the experimental process and experimental results are as follows:

[0091] 1. Create an environment

[0092] Before performing task training, you must first create an agent and an environment. In the code implementation, the content of env is concretized.

[0093] In this embodiment, the function gym.make() is mainly used. The make function is a function in the gym library, which is used to create and return an instance of a specified environment. The parameter of the function is a string representing the name of the required environment. When gym.make("PandaReach-v2") is executed, it will create an instance of the "PandaReach-v2" environment, which can be used to train reinforcement learning models. At the same time, the environment instance provides functions such as execution steps (i.e., selecting actions and obtaining environmental responses), resetting the environment, and rendering the environment. After creating the environment instance, the reinforcement learning model can be trained. During the training process, the model will learn how to complete the task by interacting with the created environment. For example, in "PandaReach-v2", the model needs to learn how to control the robotic arm to reach the target position.

[0094] If there is no pre-written environment like "PandaReach-v2", you need to customize the environment. First, create a new Python class that inherits from gym.Env. This base class needs to provide the basic interface and functions of the reinforcement learning environment. In the constructor of the custom class, you need to initialize the state of the environment, including defining the state space and action space. The state space and action space can be any type in gym.spaces, such as Box (continuous space), Discrete (discrete space), etc. In addition to defining the __init__ function, you also need to define the reset function and the step function. The reset function is responsible for resetting the environment to the initial state. In reinforcement learning, this function will be called at the beginning of each training episode, and it should return the initial observation of the environment. The step function performs an environment simulation for one time step. It accepts an action as input, then updates the environment state based on this action, and returns the next observation, reward, a flag whether the episode is completed, and a dictionary containing additional information. In addition, you can optionally define a render function and a close function to close the environment. The render function can visualize the environment. It is responsible for rendering the state of the environment so that you can intuitively see the behavior of the agent. The close function can be responsible for performing some cleanup operations, such as releasing resources. Figure 3 As shown in the figure, the test environment built outside of this experiment, in addition to the introduction of the Franka Emika Panda robot arm, the urdf file of the wooden board is also introduced as an obstacle, and the position of the sphere is set as the target point.

[0095] 2. Algorithm import

[0096] After creating the environment, you need to select the algorithm model to be used for training from a variety of reinforcement learning algorithms and import it. In the code implementation, the content of the model is concretized. Different algorithm models require different parameters to be imported. Taking the DDPG algorithm as an example, this experiment uses five parameters: policy, env, buffer_size, verbose, and tensorboard_log.

[0097] Policy = "MultiInputPolicy" specifies the type of policy to be used. MultiInputPolicy is a policy suitable for multi-input features, which means that it can handle composite observations composed of multiple different sources (such as different sensors). It is suitable for environments where the state space consists of multiple different types of features, such as position, speed, force, etc. in robotic arm control tasks. This is very useful for processing multi-dimensional observation data in complex environments. Different algorithms support different policy classes. Some common policy classes include MlpPolicy, CnnPolicy, and CustomPolicy. MlpPolicy represents a multi-layer perceptron policy and is suitable for simple environments where the state space is a single or multiple continuous or discrete features. CnnPolicy is a convolutional neural network policy and is suitable for environments where the state space consists of images, such as Atari games. CustomPolicy is a custom policy that requires the user to define their own neural network architecture. The custom policy class must inherit from BasePolicy and implement the necessary methods, and then pass it to the algorithm.

[0098] The env parameter is used to pass the previously created Gym environment env to the algorithm model, that is, to specify the reinforcement learning environment that the agent will interact with. The content of this parameter can be an environment obtained directly from the gym library or a gym environment implemented by the user. If you want to train multiple instances of the environment at the same time, you can use the VecEnv wrapper to create a vector environment, which allows the model to learn in multiple parallel environments at the same time, while also improving sample efficiency and improving training stability. This parameter is necessary because the algorithm needs to understand the state space and action space of the environment in order to learn how to best act in that environment.

[0099] The buffer_size parameter is used to specify the size of the experience replay buffer, that is, the maximum number of experiences gained by the agent in the environment will be stored in this buffer, so this parameter is very important for controlling the balance between exploration and exploitation of the model. The buffer_size parameter can be any positive integer, which represents the maximum number of experiences that can be stored in the buffer. A larger buffer can store more experience, which helps improve the sample efficiency and stability of the model, especially when using experience replay technology. However, an overly large buffer may take up more memory and increase training time. Adjusting buffer_size may affect the performance and training time of the model, so in practical applications, it is necessary to choose a suitable value based on specific needs and available resources.

[0100] The verbose parameter is a parameter that controls the verbosity of log output. Its value can be 0, 1, or 2, representing different levels of output verbosity. 0 means no log information is output, 1 means some basic information is output, such as training progress and basic performance indicators, and 2 means more log information is output, including debugging information. By default, the value of the verbose parameter is 1, which is helpful for monitoring training progress and debugging.

[0101] The tensorboard_log parameter is used to specify the storage path of the TensorBoard log. TensorBoard is a tool used to visualize various metrics during the training process, such as loss function values, rewards, etc. By specifying the log directory, information during the training process can be recorded and viewed in TensorBoard. The tensorboard_log parameter can be a string representing the storage path of the TensorBoard log file, or a function that is called at each iteration and returns a string representing the file name of the TensorBoard log that should be saved for the current iteration.

[0102] 3. Training Results

[0103] With the environment and algorithm, you can start the learning process. Stable Baselines 3 provides a model class that can execute the learning loop with one line of code until the specified total number of time steps total_timesteps is reached. It greatly simplifies the model training process, allowing users to focus on environment design and task requirements without manually writing learning loop code.

[0104] Model is an instance of the reinforcement learning model created previously, which contains the neural network architecture, strategy, optimizer, etc. Learn is a method of the model class that is used to start the learning process of the model. It usually performs the following steps: initialization, start learning loop, and termination condition. First, the model will initialize some necessary parameters, such as experience replay buffer, optimizer, etc. Then, the model will start a loop in which it interacts with the environment, collects experience, updates model parameters, and monitors learning progress. Finally, the learning loop will continue to execute until the specified total number of time steps total_timesteps is reached. Each time step usually includes taking an action from the environment, receiving the environment's response (next state, reward, and completion flag), and updating the model. After reaching total_timesteps, the learning loop will stop and the model will enter the evaluation or testing phase.

[0105] After the model training is completed, use the model.save() function to save the model's parameters and state so that you can load the model later and continue training, or use the model in a different environment. When the model.save() function is called, the model saves all the parameters in the model, including the weights of the neural network, the parameters of the strategy, etc. These parameters can be used to restore the state of the model and continue training or evaluation. If the model is interacting with an environment when it is saved, it will also save the state of the environment so that it can be restored to the same initial state when the model is loaded. Sometimes the model also saves some additional information, such as log files, performance indicators, etc., for easy analysis and debugging. The saved file is usually a .zip compressed file containing all the necessary information.

[0106] To optimize the algorithm, when implementing it in the code, you need to add the replay_buffer_class parameter in the model and set the parameter content to HerReplayBuffer. The replay_buffer_class parameter is used to specify the type of the experience replay buffer. HerReplayBuffer is a special experience replay buffer that inherits from the ReplayBuffer class. It allows the agent to generate multiple samples for each possible target.

[0107] like Figure 4 As shown, this embodiment compares and evaluates the effect of the DDPG model alone (green legend) and the model effect after DDPG+HER optimization (blue legend) from seven aspects (the parameters are ep_len_mean, ep_rew_mean, success_rate, fps, actor_loss, critic_loss and learning_rate). Figure 4(4a) corresponds to ep_len_mean, which indicates the average number of steps per episode (round), (4b) corresponds to ep_rew_mean, which indicates the average total reward per episode, (4c) corresponds to success_rate, which indicates the average rate of successful task completion, (4d) corresponds to fps, which indicates the number of frames per second, (4e) corresponds to actor_loss, which indicates the Actor network loss, (4f) corresponds to critic_loss, which indicates the Critic network loss, and (4g) corresponds to learning_rate, which indicates the learning rate. It can be seen that the optimized model has been greatly improved, the learning efficiency has been improved, and the model converges faster. The evaluation results of the DDPG algorithm after adding HER show that the change range of actor_loss decreases and finally stabilizes at around -4.5. The general trend of critic_loss is no longer an increase first and then a decrease, but a direct decrease. This is because the introduction of HER provides an additional target state, so that the robot arm can get rewards even when the original goal is not achieved. It is no longer dependent on only one goal. The Actor network learns a relatively stable strategy more quickly, and the Critic network can estimate the state value and action value more accurately. This indicates that the network has achieved a good performance level.

[0108] By applying the above algorithm to a custom obstacle avoidance task, we can observe the robot arm's autonomous learning of the obstacle avoidance task, which demonstrates the effectiveness of the algorithm in practical applications. The robot arm can start from scratch and gradually learn how to identify and avoid obstacles. During the training process, the robot arm gradually builds up its understanding of the environment through continuous trial and error, and forms an effective obstacle avoidance strategy. Figure 5 As shown, the robotic arm can complete the predetermined task and reach the preset target point of the sphere.

[0109] The present invention proposes a robot path planning method based on an improved DDPG algorithm that integrates HER experience replay technology. By adding HER technology to the original DDPG algorithm framework, the adaptability and learning efficiency of the robot in uncertain and dynamic environments are effectively improved. HER technology allows the robot to learn from failed experiences. By replaying and recalibrating targets, the robot can learn effective strategies without direct successful experience. This improvement enables the robot to cope with complex tasks more flexibly and improves the robustness and success rate of path planning.

[0110] In the field of industrial automation, the method of the present invention can enable the robot arm to quickly adapt to new layouts and tasks on a constantly changing production line, thereby improving production efficiency and the operational safety of the robot arm; in the field of medical robots, the technology of the present invention can help surgical robots better adapt to different surgical environments and situations, and improve the accuracy and success rate of surgery; in the field of service robots, the method of the present invention can enable robots to provide more stable and reliable services in complex and changing service environments, thereby improving user experience; in the field of space exploration, the method of the present invention can help detection robots effectively plan paths in unknown and extreme environments, thereby ensuring the smooth progress of tasks. In addition, the method of the present invention can also be used as an educational and research tool for research and teaching in the fields of robotics, artificial intelligence, and automated control, thereby promoting the development of related fields.

[0111] If the above method is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0112] The above description of the embodiments is to facilitate the understanding and use of the invention by those skilled in the art. It is obvious that those skilled in the art can easily make various modifications to these embodiments and apply the general principles described herein to other embodiments without creative work. Therefore, the present invention is not limited to the above embodiments, and improvements and modifications made by those skilled in the art based on the disclosure of the present invention without departing from the scope of the present invention should be within the scope of protection of the present invention.

Claims

1. A robot arm path planning method based on an improved DDPG algorithm, characterized in that: The following steps are involved: Obtain the initial information and target point information of the robot arm, input the trained robot arm path planning model, and obtain the robot arm path planning result; The robot path planning model includes a robot state space, a robot action space and a reward function. The robot state space includes the three-dimensional coordinates of the end of the robot, the three-dimensional coordinates of the target point and the attitude angle of the end effector of the robot. The robot action space includes the displacement vector of the end of the robot, the rotation attitude angle of the end effector of the robot and the opening and closing state of the gripper at the end of the robot. The robot path planning model is trained by an improved DDPG algorithm that introduces HER technology. The improved DDPG algorithm that introduces HER technology calibrates the state of the robot that reaches or fails to reach the target point as a potential target state, and calculates the reward value based on the reward function and the potential target state.

2. The robot arm path planning method based on the improved DDPG algorithm according to claim 1, characterized in that: The robot arm path planning model is constructed based on the dynamic model of the robot arm, and the dynamic model of the robot arm is constructed based on the kinematic model of the robot arm.

3. The robot arm path planning method based on the improved DDPG algorithm according to claim 2, characterized in that: The kinematic model of the robotic arm is established using the improved DH method. The specific process is as follows: A coordinate system is established at the head end of each link of the robotic arm, and the relationship between each joint and link of the robotic arm is described by DH parameters to establish a kinematic model of the robotic arm. The DH parameters include link length, torsion angle, link offset and joint angle.

4. The robot arm path planning method based on the improved DDPG algorithm according to claim 2, characterized in that: The reverse engineering method is used to build the dynamic model of the robotic arm. The specific process is as follows: Based on the kinematic model of the robotic arm, the dynamic data of the robotic arm, including the inertia matrix and gravity vector of the robotic arm, is calculated, a symbolic regression matrix is ​​constructed, the dynamic coefficients are obtained by the least squares method, the forward kinematics equation is established, and the inverse kinematics equation is derived according to the Lagrange equation to obtain the dynamic model of the robotic arm.

5. The robot arm path planning method based on the improved DDPG algorithm according to claim 1, characterized in that: The improved DDPG algorithm that introduces HER technology includes an Actor network, a Target Actor network, a Critic network, and a TargetCritic network. The specific process of training the robot path planning model by using the improved DDPG algorithm that introduces HER technology is as follows: Get the current state s of the robot from the robot state space t , according to the current state of the robot t , select the current action a of the robot from the action space of the robot through the Actor network t , a y =μ(s y |θ μ )+N t , where μ is the Actor network, N t is the noise, θ μ Parameters of the Actor network; Execute the current action of the robot arm a t , get the next state s of the robot t+1 , the next state of the robot arm is s t+1 The potential target state g is calibrated, and the corresponding reward r is calculated according to the reward function and the potential target state g. t , the information tuple (s t ,a t ,r t ,s t+1 ,g) stored in the experience pool; Calculate the next state s of the robot arm through the Target Actor network t+1 The corresponding robot arm motion μ′(s i+1 ), where μ′ is the Target Actor network; Randomly extract N groups of samples from the experience pool and calculate the state-action pairs (s t+1 ,μ′(s i+1 ))'s target Q value y i , calculate the state-action pair (s t ,a t )’s Q value Q(s) i ,a i |θ Q ), where Q is the Critic network, θ Q are the parameters of the Critic network; Construct the loss function L based on the target Q value and Q value, and use the gradient descent method to update the parameters θ of the Actor network μ and the parameters θ of the Critic network Q ; Use soft update to update the parameters θ of the Target Actor network μ′ and the parameter θ of the Target Critic network Q′ .

6. The robot arm path planning method based on the improved DDPG algorithm according to claim 5, characterized in that: Action pair (s t+1 ,a t+1 )’s target Q value y i The calculation formula is as follows: y i =r i +γQ′(s i+1 ,μ′(s i+1 ,i μ′ )|θ Q′ ) Among them, γ is the discount factor of the reward, Q′ is the Target Critic network, θ Q′ are the parameters of the Target Critic network.

7. The robot arm path planning method based on the improved DDPG algorithm according to claim 5, characterized in that: The expression of the loss function L is as follows:

8. The robot arm path planning method based on the improved DDPG algorithm according to claim 5, characterized in that: Use soft update to update the parameters θ of the Target Actor network μ′ and the parameter θ of the Target Critic network Q′ The specific process is as follows: i Q′ ←tth Q +(1-τ)θ Q′ i μ′ ←tth μ +(1-τ)θ μ′ Among them, τ is the parameter update rate.

9. An electronic device comprising a memory, a processor, and a program stored in the memory, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.

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

Citation Information

Patent Citations

  • Mechanical arm path planning method integrating reinforcement learning and fuzzy obstacle avoidance

    CN113232016A

  • Path planning method for obstacle avoidance mobile robot

    CN115793634A

  • AUV (Autonomous Underwater Vehicle) motion planning method for water tunnel inspection

    CN116627147A

Cited By

  • Robot scheduling method and device, computer readable storage medium and electronic equipment

    CN119417191A