Mechanical arm control method based on selective state space and model reinforcement learning
Through the method of selective state space and model-based reinforcement learning, the world model is constructed and interactive training is performed, which solves the problems of low sample efficiency and computational efficiency in robotic arm control, and achieves efficient completion of object grabbing tasks, which is suitable for intelligent manufacturing. field.
Patent Information
- Application Number
- CN202411023330.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-29
AI Technical Summary
Existing model-free reinforcement learning algorithms have low sample efficiency and low computational efficiency in robotic arm manipulation, making it difficult to effectively apply in actual deployment. Moreover, traditional model-based reinforcement learning algorithms are slow to train and consume large amounts of computing resources.
A robotic arm control method based on selective state space and model-based reinforcement learning is adopted to achieve efficient robotic arm learning and control by building a world model and conducting interactive training, using components such as observation encoders, image decoders, and sequence models.
It maximizes sample efficiency with a lower number of interactions, reduces computing resource requirements, improves computing efficiency, and enables the robotic arm to complete object grabbing tasks under visual input within 5 to 6 hours. It is suitable for the field of intelligent manufacturing.
Smart Images

Figure CN118721208A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the fields of reinforcement learning technology, deep learning technology, and robotic arm control technology, and in particular relates to a robotic arm control method based on selective state space and model-based reinforcement learning. Background Art
[0002] Reinforcement learning is a paradigm of machine learning, whose goal is to enable intelligent agents to obtain optimal strategies through interactive learning with the environment. Reinforcement learning usually involves agents, environments, states, actions, and rewards. The agent will receive rewards after each interaction with the environment, and obtain feedback (rewards) by trying different actions. Based on these feedbacks, the agent learns to maximize the cumulative reward - the return. With the rapid development of deep learning in recent years, deep reinforcement learning combines the powerful representation learning ability of deep neural networks with the decision-making optimization ability of reinforcement learning, allowing intelligent agents to learn high-level abstract representations from raw environmental data. In game scenarios, such as StarCraft, Atari, and the extremely difficult Go, deep reinforcement learning algorithms have repeatedly broken human records. In real-life application scenarios such as drone racing and robotic arm manipulation, deep reinforcement learning has also achieved breakthrough performance improvements compared to traditional methods.
[0003] Model-free reinforcement learning algorithms such as PPO (Schulman J, Wolski F, Dhariwal P, et al. Proximal Policy Optimization Algorithms. [J]. CoRR, 2017,) and SAC (Haarnoja T, Zhou A, Abbeel P, et al. Soft Actor-Critic: Off-Policy Maximum Entropy Deep Reinforcement Learning with a Stochastic Actor [C] / / Dy J, Krause A. Proceedings of Machine Learning Research: Proceedings of the 35th International Conference on Machine Learning) have achieved excellent results in many fields, but these achievements are often based on tens of millions of interactions. The extremely low sample efficiency limits the practical application of model-free reinforcement learning algorithms in environments with high safety requirements and high costs. In order to improve the sample efficiency of reinforcement learning algorithms, model-based reinforcement learning algorithms have emerged. Given that traditional model-free reinforcement learning methods often require a large number of interaction samples, in practical applications such as robotic arm manipulation, model-free algorithms such as PPO and SAC are usually trained in a simulation environment and then migrated to the real environment through Sim To Real technology. Considering the complex and random dynamics in the real environment, the performance of strategies learned in the simulation environment in actual scenarios is greatly limited. In addition, traditional reinforcement learning algorithms such as PPO and SAC have difficulty processing high-dimensional inputs, which leads to a decrease in their manipulation accuracy in visual tasks.
[0004] Model-based reinforcement learning algorithms model the real environment, and the established model is called a world model. The agent interacts with the learned world model and uses the trajectory generated by the model to train the agent. Compared with model-free reinforcement learning algorithms, model-based reinforcement learning algorithms alleviate the limitation of the number of interactions and significantly improve sample efficiency. The Dreamer algorithm (Hafner D, Lillicrap TP, Norouzi M, et al. Mastering Atari with discrete world models [C] / / International Conference on Learning Representations. 2021) is a typical model-based reinforcement learning algorithm in recent years. Dreamer uses recurrent neural networks as sequence models, establishes a complete variational reasoning process, and builds a recurrent state space model RSSM. Dreamer has demonstrated strong learning capabilities in game environments such as Atari games, DeepMind Control, and Minecraft. However, due to the natural sequential characteristics of RSSM, it is difficult to parallelize the world model during training, resulting in slow training. In the robot arm manipulation task, Dreamer directly learns the dynamics of the environment in the real environment and uses the learned world model to train the agent's decision-making. Thanks to the stochastic nature of the variational autoencoder, the strategy learned by the agent is more robust and can adaptively adjust the strategy according to the disturbance in the real environment. In the end, Dreamer's training effect is 5 to 6 times that of traditional model-based reinforcement learning methods such as PPO and Rainbow. However, due to the difficulty of parallelization during training, the entire training process often lasts nearly 10 hours, and better training results require huge computing resources.
[0005] In recent years, some works have used Transformer as a sequence model in the world model. This structure has shown strong capabilities in natural language processing, computer vision and other fields due to its unique attention mechanism and ability to establish long-term dependencies, as well as the characteristics of large-scale parallel training. IRIS (Micheli V, Alonso E, Fleuret F. Transformers are sample-efficient world models [C] / / The Eleventh International Conference on Learning Representations. 2023) first uses VQ-VAE to encode image observations into 16 word vectors, and then uses the space-time Transformer structure to model the dynamic relationship between the image and between images. The world model built by IRIS is highly accurate, but because the space-time Transformer needs to perform self-attention operations on a large number of word vectors, the training speed is slow. STORM (Zhang W, Wang G, Sun J, et al. STORM: Efficient Stochastic Transformer based World Models for Reinforcement Learning [C] / / Thirty-seventh Conference on Neural Information Processing Systems. 2023) uses a single latent variable to represent the original image observation, and only uses two layers of random Transformers as the sequence model. This ensures modeling accuracy while also making it extremely computationally efficient. It only takes 4.3 hours to complete the training of a single Atari 100K game on a single NVIDIA GeForce RTX 3090. As the sequence grows, the Transformer's reasoning time increases quadratically, which also means that the Transformer cannot provide the agent with long-term information, and the agent's training is affected.
[0006] In addition to Transformer, some scholars use structured state space model (S4) to build world model. This structure has achieved excellent performance in long sequence modeling tasks such as DNA due to its excellent long sequence modeling ability and the characteristics of parallel training through global convolution. R2I (Samsami MR, Zholus A, Rajendran J, et al. Mastering Memory Tasks with World Models [C] / / The Twelfth International Conference on Learning Representations. 2024) and S4WM (Deng F, Park J, Ahn S. Facing Off World Model Backbones: RNNs, Transformers, and S4 [C] / / Thirty-seventh Conference on Neural Information Processing Systems. 2023)
[0007] The excellent performance of structured state space models in environments that require long-term information for decision making, such as MemoryMaze and Discount Chain, is demonstrated. However, in simple environments with limited sample interactions, such as Atari100K, model-based reinforcement learning algorithms based on structured state space models are slightly inferior to model-based reinforcement learning algorithms such as Dreamer.
[0008] The model-based reinforcement learning algorithms listed above can improve the sample efficiency of reinforcement learning in many tasks, but there are still some problems, as shown below:
[0009] 1) The performance of the agent in some environments is still very limited, and the average reward and reward are low, which is far behind human performance;
[0010] 2) The computational efficiency is low, and the computational overhead and energy consumption are large in actual deployment. Summary of the invention
[0011] To solve the above problems, the present invention provides a robotic arm control method based on selective state space and model-based reinforcement learning, which can maximize sample efficiency with a lower number of interactions and enable the robotic arm to learn how to grasp objects using only fewer computing resources, thereby providing an efficient learning method for the robotic arm.
[0012] A method for manipulating a robotic arm based on selective state space and model-based reinforcement learning comprises the following steps:
[0013] S1: Build a world model based on the real environment;
[0014] S2: The robot model interacts with the world model to obtain the action sequence of the robot model under different environmental observations;
[0015] S3: Train the robot model using action sequences observed in different environments;
[0016] S4: Use the trained robotic arm model to control the robotic arm to make corresponding actions in different real environments to realize the manipulation of the robotic arm.
[0017] Furthermore, the world model includes an observation encoder q φ (z t |o t ), Image Decoder Motion Information Mixer φ (z t ,a t ), Sequence Model f φ (e 1:T ,x0), dynamic predictor Reward Predictor Termination Predictor
[0018] The details of building a world model based on the real environment are as follows:
[0019] S11: The fixed image sensor captures the RGB image of the real environment in real time to obtain the environmental observation data o at the current time t t ;
[0020] S12: By observing the encoder q φ (z t |o t ) Environmental observation data t Dimensionality reduction and random sampling are performed in sequence, and the obtained random variables are represented as latent space random variables z using one-hot encoding t ;
[0021] S13: by image decoder For the latent space random variable z t Perform deconvolution to obtain reconstructed environmental observation data
[0022] S14: The latent space random variable z t and the robot model in the environmental observation data o t The next action a t splicing, and the action information mixer m composed of multi-layer perceptron φ (z t ,a t) Map the concatenated data to state e t ;
[0023] S15: Sequence Model based on Mamba Architecture φ (e 1:T ,x0) in state e t and the intermediate vector x at the previous moment t-1 As input, output the loop state h at the current time t t and the intermediate vector x t ;
[0024] S16: By dynamic predictor Receive loop status h t , output the latent space random variable at the next moment
[0025] S17: By Reward Predictor Receive loop status h t and latent space random variables Output the reward at the current time t
[0026] S18: By the termination predictor Receive loop status h t and latent space random variables Output the predicted value of the termination signal at the current time t
[0027] S19: Based on environmental observation data award Termination signal prediction value Construct a loss function and determine whether the loss function at the current time t is less than the set value. If yes, obtain the final world model. If no, proceed to step S110.
[0028] S110: Adjust the observation encoder q φ (z t |o t ), Image Decoder Motion Information Mixer φ (z t ,a t ), Sequence Model f φ (e 1:T ,x0), dynamic predictor Reward Predictor Termination Predictor , and then re-execute steps S11 to S19 until the loss function is less than the set value.
[0029] Furthermore, based on environmental observation data award Termination signal Constructing the loss function as follows:
[0030]
[0031] Where φ is the observation encoder q φ (z t |o t ), Image Decoder Motion Information Mixer φ (z t ,a t ), Sequence Model f φ (e 1:T ,x0), dynamic predictor Reward Predictor Termination Predictor The parameter set of
[0032] is the observation reconstruction loss at the current time t, is the reward prediction loss at the current time t, is the predicted loss of the termination signal at the current time t, is the dynamic prediction loss at the current time t, is the representation loss at the current time t, β1 is the weight of the dynamic prediction loss, and β2 is the weight of the representation loss.
[0033] Furthermore, we observe the reconstruction loss The calculation method is:
[0034]
[0035] Among them, ||·||2 means calculating the Euclidean distance;
[0036] Reward prediction loss The calculation method is:
[0037]
[0038] Among them, twohot means double hot encoding, symlog(r t )=sign(r t )ln(|r t |+1), Reward Logits is the reward predictor Output reward regression vector;
[0039] Termination signal prediction loss The calculation method is:
[0040]
[0041] Among them, c t is the actual value of the termination signal at the current time t;
[0042] Dynamic prediction loss The calculation method is:
[0043]
[0044] Representation loss The calculation method is:
[0045]
[0046] Among them, sg() is the termination gradient operator, z t+1 is the latent space random variable at the next moment, o t+1 is the environmental observation data captured by the image sensor at the next moment, KL[] represents the KL divergence, It represents the dynamic predictor with h t Predicted for input distribution.
[0047] Furthermore, the robot model interacts with the world model, and the action sequence of the robot model under different environmental observations is obtained as follows:
[0048] S21: Input the historical environmental observation data o0~o7 of 8 consecutive time steps and the historical actions a0~a7 performed by the robot under the environmental observation data o0~o7 into the world model to obtain the initialization intermediate vector x0, the loop state h0 and the latent space random variable z1;
[0049] S22: The world model passes h0 and z1 to the robot model, and the robot model outputs the decision action
[0050] S23: The action information mixer combines z1 with Concatenate and map to e1. The sequence model takes e1 and x0 as input and outputs the loop state h1 and the intermediate vector x1 of the current time step;
[0051] S24: Input h1 into the dynamic predictor and map h1 to a 1024-dimensional regression vector Logits;
[0052] S25: Divide the regression vector Logits into 32 groups of 32-dimensional vectors, perform activation function softmax operation, and output 32 groups of prior distributions;
[0053] S26: Randomly sample 32 groups of prior distributions and use one-hot encoding to represent the sampling results, then sequentially concatenate the 32 groups of sampling results represented by one-hot encoding back to 1024 dimensions to obtain the latent space random variables of the next time step predicted by the dynamic predictor
[0054] S27: h1, Pass it to the reward predictor, terminate the predictor, and get the predicted reward and termination signal prediction value
[0055] S28: Repeat steps S22 to S27 until T sets of trajectory data are obtained, wherein the T sets of trajectory data include the cycle state h 0:T-1 , the predicted latent space random variable Prediction Rewards Predicted termination signal prediction value
[0056] Furthermore, the training of the robot model using the action sequences observed in different environments specifically includes the following steps:
[0057] S31: respectively convert the T groups of trajectory data into With h t-1 Splice and get T states s t ;
[0058] S32: Based on the rewards in the trajectory data of group T Get each state s separately t The corresponding value function V ψ (s t );
[0059] S33: Each state s t Input the robot model and output the robot's decision action;
[0060] S34: According to the value function V ψ (s t ), the decision action constructs the training loss function of the robot arm model, and determines whether the training loss function is less than the set value. If yes, the final robot arm model is obtained; if not, proceed to step S35;
[0061] S35: Change the parameters of the robot model and re-execute steps S31 to S34 until the training loss function is less than the set value.
[0062] Furthermore, the training loss function of the robotic arm model is as follows:
[0063]
[0064] Among them, θ is the parameter to be optimized of the policy function, is the loss function corresponding to the strategy function, ψ is the parameter to be optimized of the value function, is the loss function corresponding to the value function, sg() is the termination gradient operator, B is the training batch, L is the length of the trajectory data used in each batch, S is the set reduction factor, For state s t Next select action Strategy function, HL() represents Histogram encoding, max() represents the maximum value, η represents the set weight, represents the entropy of the policy function, the activation function Where V represents the value function V ψ () in s t is the original output of the input, a vector of dimension 255, v j represents the value of the jth dimension of V, To estimate the true value function by time difference, we have:
[0065]
[0066] Among them, λ is the set weight and γ is the attenuation coefficient.
[0067] Furthermore, the movement of the robot arm is a seven-dimensional vector. The first three dimensions represent the coordinate changes of the robot arm end controller along the x-axis, y-axis, and z-axis in the Cartesian coordinate system; the middle three dimensions represent the rotation angles of the robot arm end controller with the x-axis, y-axis, and z-axis as the rotation axes; and the last dimension represents the opening and closing of the gripper at the end of the robot arm.
[0068] Beneficial effects:
[0069] The present invention provides a method for manipulating a robotic arm based on selective state space and model-based reinforcement learning. First, a world model is constructed according to a real environment. The world model processes high-dimensional visual images from a third-person perspective, extracts image features and integrates sequence state-action information. The robotic arm model then makes decisions and learns based on the feature information extracted by the world model. The sample efficiency can be maximized at a low number of interactions, and the robotic arm can learn a method for grasping objects using only a small number of computing resources. The versatility of the model-based reinforcement learning algorithm in different task scenarios can be improved, the training cost and the difficulty of deployment in a practical environment can be reduced, and the computing efficiency can be improved. In other words, the present invention utilizes the powerful sequence modeling capability of the selective state space model and the efficient parallel training method, so that the robotic arm can efficiently complete the object grasping task under visual input after 5 to 6 hours of training, providing a potential solution for the intelligentization of production tasks, and is particularly suitable for the field of intelligent manufacturing. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 is a schematic diagram of the world model of the present invention during parallel training;
[0071] Figure 2 is a schematic diagram of the world model of the present invention when interacting with the robot arm model;
[0072] Figure 3 It is a schematic diagram of the algorithm flow provided by the present invention;
[0073] Figure 4 This is the network information flow diagram provided by the present invention. DETAILED DESCRIPTION
[0074] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0075] like Figure 1 As shown, a method for manipulating a robotic arm based on selective state space and model-based reinforcement learning includes the following steps:
[0076] S1: Construct a world model based on the real environment; the world model includes an observation encoder q φ (z t |o t ), Image Decoder Motion Information Mixer φ (z t ,a t ), Sequence Model f φ (e 1:T ,x0), dynamic predictor Reward Predictor Termination Predictor
[0077] Observation encoder: z t ~q φ (z t |o t )
[0078] Image Decoder:
[0079] Action information mixer: e t =m φ (z t ,a t )
[0080] Sequence Model: h 1:T ,x 1:T =f φ (e 1:T,x0)
[0081] Dynamic Predictor:
[0082] Reward Predictor:
[0083] Termination Predictor
[0084] Among them, the observation encoder q φ (z t |o t ) and image decoder Variational autoencoders that compose discrete distributions;
[0085] like Figure 4 As shown in the figure, the world model is constructed according to the real environment as follows:
[0086] S11: The fixed image sensor captures the RGB image of the real environment in real time to obtain the environmental observation data o at the current time t t ;
[0087] It should be noted that environmental observation data t It is a 64×64 high-dimensional RGB image captured in real time by a fixed image sensor; the dimension of the high-dimensional environmental observation data is above 3000 dimensions, and the dimension of the low-dimensional latent space random variable is below 1500 dimensions.
[0088] S12: Observation encoder q consisting of a convolutional neural network φ (z t |o t ) Environmental observation data t Dimensionality reduction and random sampling are performed in sequence, and the obtained random variables are represented as latent space random variables z using one-hot encoding t ;
[0089] Specifically, observe the encoder q φ (z t |o t ) The high-dimensional environmental observation data o t Encoded into the regression vector Logits with a dimension of 1024. Logits can be divided into 32 groups of 32-dimensional vectors, which are converted into 32 discrete arrays after the activation function softmax operation; these 32 groups of arrays are used for random sampling, and the random variables obtained by sampling are represented by one-hot encoding. These 32 random variables are concatenated in order to obtain a 1024-dimensional latent space random variable z t ; z t It can be regarded as a high-dimensional observation t The feature vector extracted by convolutional neural network and multi-layer perceptron includes ot All important feature information; It should be noted that the discrete sampling step cannot pass the gradient. The present invention uses the "directly through the gradient" method for sampling (as shown in the following formula), allowing the gradient to be passed from the decoder to the encoder through the probability probs. Where sg() represents the termination gradient operator:
[0090] z t =z t +probs-sg(probs)
[0091] S13: Image decoder composed of deconvolutional neural network For the latent space random variable z t Perform deconvolution to obtain reconstructed environmental observation data
[0092] Latent space random variable z t As the image decoder Input, Right t After deconvolution, the reconstructed environmental data is obtained; thus, the present invention converts high-dimensional environmental observation data into t Encoded as a low-dimensional latent space random variable z t , referred to as hidden variable z t , z t Contains characteristic information of environmental observations.
[0093] S14: The latent space random variable z t and the robot model in the environmental observation data o t The next action a t splicing, and the action information mixer m composed of multi-layer perceptron φ (z t ,a t ) Map the concatenated data to state e t ;
[0094] It should be noted that the movement of the robot arm is a seven-dimensional vector. The first three dimensions represent the coordinate changes of the robot end controller along the x-axis, y-axis, and z-axis in the Cartesian coordinate system; the middle three dimensions represent the rotation angles of the robot end controller with the x-axis, y-axis, and z-axis as the rotation axes; the last dimension represents the opening and closing of the gripper at the end of the robot arm.
[0095] Hidden variable z t and the action a selected by the robot in the current state of the environment and the current time step t After splicing, the action information mixer m is composed of a multi-layer perceptron φ (z t ,a t) is mapped to state e t , e t It can be regarded as a state variable that contains the observation information and action information of the current time step.
[0096] S15: Sequence Model based on Mamba Architecture φ (e 1:T ,x0) in state e t and the intermediate vector x at the previous moment t-1 As input, output the loop state h at the current time t t and the intermediate vector x t ;
[0097] The sequence model f in the present invention φ (e 1:T ,x0) with e t The sequence is taken as input and the corresponding loop state h containing historical observation and action information is output. t . Sequence model f φ (e 1:T ,x0) uses a selective state space model, also known as Mamba. When training the world model, since the complete sequence information can be received in advance, Mamba does not need to perform single-step reasoning, and the intermediate state x t The calculation is done inside Mamba, no input or output is required.
[0098] S16: By dynamic predictor Receive loop status h t , output the latent space random variable at the next moment
[0099] Specifically, the present invention uses a dynamic predictor composed of a multi-layer perceptron h t Mapped to the 1024-dimensional regression variable Logits; the present invention divides the Logits into 32 groups of 32-dimensional vectors, and these 32 groups of vectors output 32 groups of prior distributions after the activation function softmax operator Randomly sample these 32 sets of prior distributions, and the sampling results are represented by one-hot encoding. These 32 sets of sampling results are sequentially spliced back to 1024 dimensions to obtain the hidden variables of the next time step predicted by the dynamic predictor
[0100] S17: By Reward Predictor Receive loop status h t and latent space random variables Output the reward at the current time t
[0101] It should be noted that the reward It is a simple 0-1 signal. If the item r is grabbed at the current moment t is 1, otherwise it is 0; the present invention uses a multi-layer perceptron to form a reward predictor With the cycle state h t and the hidden variable at the next time step As input, the output dimension is 255-dimensional reward regression vector Reward Logits. After the activation function softmax operation, Reward Logits obtains a set of weights The present invention provides a set of equally spaced reference vectors [-20, -20+bin, ..., 20-bin, 20] with a dimension of 255, wherein the step size bin = 40 / 254. The reference vectors and the weights One-to-one correspondence, the vector and the weight Perform matrix multiplication to obtain the predicted compression reward, and the range of the compression reward is between [-20, 20]. The present invention uses symexp = sign (x) (e |x| -1) Decompress the compressed reward to get the predicted value of the environment reward at the current time step
[0102] S18: By the termination predictor Receive loop status h t and latent space random variables Output the predicted value of the termination signal at the current time t
[0103] It should be noted that the termination signal prediction value The same 0-1 signal limits the maximum time of a single interaction to 6 hours. 1, after reaching the maximum interaction time is 0, the training ends; the present invention uses a multi-layer perceptron to form a termination predictor With the cycle state h t and the latent variable at the next time step predicted by the dynamic predictor As input, the termination signal of the current time step is predicted, which is the output of the termination predictor
[0104] S19: Based on environmental observation data award Termination signal prediction value Construct a loss function and determine whether the loss function at the current time t is less than the set value. If yes, obtain the final world model. If no, proceed to step S110.
[0105] It should be noted that the world model in the present invention is trained in an end-to-end manner using the Adam optimizer in a gradient descent manner, wherein the world model is trained in an end-to-end manner using the Adam optimizer in a gradient descent manner according to the environmental observation data. award Termination signal Constructing the loss function as follows:
[0106]
[0107] Where φ is the observation encoder q φ (z t |o t ), Image Decoder Motion Information Mixer φ (z t ,a t ), Sequence Model f φ (e 1:T ,x0), dynamic predictor Reward Predictor Termination Predictor The parameter set of
[0108] is the observation reconstruction loss at the current time t, where the superscript rec is the abbreviation of reconstruction; is the reward prediction loss at the current time t, where the superscript rew is the abbreviation of reward; is the predicted loss of the termination signal at the current time t, where the superscript con is the abbreviation of continuous; is the dynamic prediction loss at the current time t, where the superscript dyn is the abbreviation of dynamic; is the representation loss at the current time t, where the superscript rep is the abbreviation of representation; β1 is the weight of the dynamic prediction loss, and β2 is the weight of the representation loss; optionally, weight β1 = 0.5, weight β2 = 0.1.
[0109] In each round of training, after calculating the overall loss function L(φ), the Adam optimizer is used to perform gradient descent updates on the world model parameters.
[0110] Furthermore, we observe the reconstruction loss It is used to update the encoder observation encoder and image decoder to improve the reconstruction accuracy of the world model. Its calculation method is:
[0111]
[0112] Among them, ||·||2 means calculating the Euclidean distance;
[0113] Reward prediction loss It is used to update the reward predictor and improve the reward prediction accuracy. The calculation method is:
[0114]
[0115] Among them, twohot means double hot encoding, symolg(r t )=sign(r t )ln(|r t |+1), Reward Logits is the reward predictor Output reward regression vector;
[0116] Termination signal prediction loss It is used to update the termination predictor and improve the prediction accuracy of the termination signal. The calculation method is:
[0117]
[0118] Among them, c t is the actual value of the termination signal at the current time t;
[0119] Dynamic prediction loss The calculation method is:
[0120]
[0121] Representation loss The calculation method is:
[0122]
[0123] Among them, sg() is the termination gradient operator, z t+1 is the latent space random variable at the next moment, o t+1 is the environmental observation data captured by the image sensor at the next moment, KL[] represents the KL divergence, It represents the dynamic predictor with h t Predicted for input distribution.
[0124] It should be noted that the dynamic loss function And the representation loss function The two are almost identical in form, and both are updated by maximizing the KL divergence. The two are only distinguished by the termination gradient operator sg(). The role of the dynamic loss function is to improve the prediction accuracy of the dynamic predictor, and the role of the representation loss function is to reduce the difficulty of dynamic prediction.
[0125] S110: Adjust the observation encoder q φ (z t|o t ), Image Decoder Motion Information Mixer φ (z t ,a t ), Sequence Model f φ (e 1:T ,x0), dynamic predictor Reward Predictor Termination Predictor , and then re-execute steps S11 to S19 until the loss function is less than the set value.
[0126] After the world model is trained, it interacts with the robot model through autoregression to generate imaginary trajectory data, as shown in the attached figure. Figure 2 In the imagination stage, the present invention uses the loop reasoning mode of Mamba. At each step of reasoning, the sequence model constructed by Mamba needs to input the intermediate vector x of the previous time step. t , output the intermediate vector x of the next time step t+1 , see step S2 for details.
[0127] S2: The robot model interacts with the world model to obtain the action sequence of the robot model under different environmental observations, such as Figure 3 As shown, the specific steps include:
[0128] S21: Input the historical environmental observation data o0~o7 of 8 consecutive time steps and the historical actions a0~a7 performed by the robot under the environmental observation data o0~o7 into the world model to obtain the initialization intermediate vector x0, the loop state h0 and the latent space random variable z1;
[0129] S22: The world model passes h0 and z1 to the robot model, and the robot model outputs the decision action
[0130] S23: The action information mixer combines z1 with Concatenate and map to e1. The sequence model takes e1 and x0 as input and outputs the loop state h1 and the intermediate vector x1 of the current time step;
[0131] S24: Input h1 into the dynamic predictor and map h1 to a 1024-dimensional regression vector Logits;
[0132] S25: Divide the regression vector Logits into 32 groups of 32-dimensional vectors, perform activation function softmax operation, and output 32 groups of prior distributions;
[0133] S26: Randomly sample 32 groups of prior distributions and use one-hot encoding to represent the sampling results, then sequentially concatenate the 32 groups of sampling results represented by one-hot encoding back to 1024 dimensions to obtain the latent space random variables of the next time step predicted by the dynamic predictor
[0134] S27: h1, Pass it to the reward predictor, terminate the predictor, and get the predicted reward and termination signal prediction value
[0135] S28: Repeat steps S22 to S27 until T sets of trajectory data are obtained, wherein the T sets of trajectory data include the cycle state h 0:T-1 , the predicted latent space random variable Prediction Rewards Predicted termination signal prediction value like Figure 3 shown.
[0136] The subscript 0:T-1 indicates the period from the 0th time step to the T-1th time step. For example, h 0:T-1 Represents the cycle state from the 0th time step to the T-1th time step.
[0137] S3: Train the robot model using action sequences observed in different environments;
[0138] That is, step S3 trains the operation of the robot arm based on the trajectory data generated in step S2, with the goal of allowing the robot arm model to grab objects greater than a set value within a limited time, and by maximizing the cumulative reward, allowing the robot arm to grab as many objects as possible within a limited time;
[0139] The data used in the training of the robot model in the present invention all come from the interaction with the world model in step S2. The training of the robot uses the actor-critic framework, where the actor is the parameterized strategy function π θ , according to the feature information extracted after sorting out the environmental information in the world model, the robot arm action is directly controlled. The critic is the parameterized value function V ψ , which is used to estimate the expected discounted cumulative reward under the current policy function. The value function can guide the policy function for training; the specific framework is shown in the following formula:
[0140] state:
[0141] Critic:
[0142] Actor: a t~π θ (a t |s t )
[0143] Among them, s t Will With h t-1 The splicing is called a state. θ is a parameterized policy function, which is used to directly control the action taken by the robot at any time step. The subscript θ here is the parameter of the policy function; V ψ is a parameterized value function used to estimate the cumulative discounted reward under the current strategy. Here, the subscript ψ is the parameter of the value function, and γ = 0.975 is the attenuation coefficient. Represents the environmental reward generated by the world model at the t+kth time step. for The present invention uses Monte Carlo sampling to approximate the dynamic expectation of the robot arm motion and the world model.
[0144] Specifically, the training method of the robotic arm model includes the following steps:
[0145] S31: respectively convert the T groups of trajectory data into With h t-1 Splice and get T states s t ;
[0146] S32: Based on the rewards in the trajectory data of group T Get each state s separately t The corresponding value function V ψ (s t );
[0147] S33: Each state s t Input the robot model and output the robot's decision action;
[0148] S34: According to the value function V ψ (s t ), the decision action constructs the training loss function of the robot arm model, and determines whether the training loss function is less than the set value. If yes, the final robot arm model is obtained; if not, proceed to step S35;
[0149] The training loss function of the robotic arm model is as follows:
[0150]
[0151] Among them, θ is the parameter to be optimized of the policy function, is the loss function corresponding to the strategy function, ψ is the parameter to be optimized of the value function, is the loss function corresponding to the value function, sg() is the termination gradient operator, B is the training batch, L is the length of the trajectory data used in each batch, S is the set reduction factor, For state s t Next select action Strategy function, HL() represents Histogram encoding, max() represents the maximum value, η represents the set weight, represents the entropy of the policy function, the activation function Where V represents the value function V ψ () in s t is the original output of the input, a vector of dimension 255, v j represents the value of the jth dimension of V, To estimate the true value function by time difference, we have:
[0152]
[0153] Among them, λ is the set weight and γ is the attenuation coefficient.
[0154] It should be noted that S limits the gradient size when the strategy is updated, representing all current The difference between the first 5% and the last 5% of the medium and large rankings; HL() represents the Histogram code, where V ψ (s t ) uses a similar structure to the reward predictor, and the output is Logits with a dimension of 255, but the reward predictor uses TwoHot encoding for the encoding of the calibration data. Use Histogram encoding. For the Histogram encoding method, refer to Stop Regressing. In the form of cross entropy error, Update the value function V for the reference quantity ψ Parameters; Update the policy function π by using policy gradient θ , updated in the direction of maximizing the cumulative reward, where is the entropy of the policy function. At the beginning of training, we hope that the entropy of the policy function is greater than a certain value to ensure sufficient exploration. During training, the robot learns in the direction of maximizing the cumulative reward, and finally learns how to extract information z from the world model at the current time step. t and h t-1 , performing continuous translation, rotation, opening and closing of the gripper to complete the task of grasping objects; the robotic arm model also uses the Adam optimizer during training, and is optimized in a gradient descent manner.
[0155] S35: Change the parameters of the robot model and re-execute steps S31 to S34 until the training loss function is less than the set value.
[0156] S4: Use the trained robotic arm model to control the robotic arm to make corresponding actions in different real environments to realize the manipulation of the robotic arm.
[0157] In summary, the present invention provides a method for manipulating a robot arm based on selective state space and model-based reinforcement learning. First, a world model is constructed between the task scene and the robot arm model; then the robot arm model interacts with the world model to predict the trajectory data of the real environment in an autoregressive manner; finally, the robot arm model is trained based on the predicted trajectory data generated in step S2; based on this, the present invention has the following advantages:
[0158] When training the world model, the present invention uses the Mamba hardware-aware acceleration algorithm to accelerate training by parallel scanning. Thanks to this, the training speed of the present invention is comparable to that of Transformer-based model-based reinforcement learning algorithms such as STORM, and it only takes 4.5 hours to complete training under a single Atari100K game.
[0159] In step S2, the present invention uses Mamba's loop mode for fast reasoning. At this time, Mamba needs to input an additional intermediate vector x t , except for the loop state h when outputting t In addition, the intermediate vector x of the next time step is output t+1 At this time, the present invention can perform fast single-step reasoning like DreamerV3 and other RNN-based model algorithms.
[0160] In step S3, the present invention uses a policy gradient algorithm to train the robot model; different from DreamerV3 and STORM algorithms, the present invention updates the value function V ψ When , Histogram encoding is used instead of the original TwoHot encoding, so that the robot model can learn better strategies.
[0161] Of course, the present invention may have many other embodiments. Without departing from the spirit and essence of the present invention, those skilled in the art may certainly make various corresponding changes and modifications based on the present invention, but these corresponding changes and modifications should all fall within the scope of protection of the claims attached to the present invention.
Claims
1. A robotic arm manipulation method based on selective state space and model-based reinforcement learning, It is characterized in that The following steps are involved: S1: Build a world model based on the real environment; S2: The robot model interacts with the world model to obtain the action sequence of the robot model under different environmental observations; S3: Train the robot model using action sequences observed in different environments; S4: Use the trained robotic arm model to control the robotic arm to make corresponding actions in different real environments to realize the manipulation of the robotic arm.
2. A method for manipulating a robotic arm based on selective state space and model-based reinforcement learning as claimed in claim 1, It is characterized in that The world model includes an observation encoder q φ (z t |o t ), Image Decoder Motion Information Mixer φ (z t ,a t ), Sequence Model f φ (e 1:T ,x 0 ), Dynamic Predictor Reward Predictor Termination Predictor The details of building a world model based on the real environment are as follows: S11: The fixed image sensor captures the RGB image of the real environment in real time to obtain the environmental observation data o at the current time t t ; S12: By observing the encoder q φ (z t |o t ) Environmental observation data t Dimensionality reduction and random sampling are performed in sequence, and the obtained random variables are represented as latent space random variables z using one-hot encoding t ; S13: by image decoder For the latent space random variable z t Perform deconvolution to obtain reconstructed environmental observation data S14: The latent space random variable z t and the robot model in the environmental observation data o t The next action a t splicing, and the action information mixer m composed of multi-layer perceptron φ (z t ,a t ) Map the concatenated data to state e t ; S15: Sequence Model based on Mamba Architecture φ (e 1:T ,x 0 ) with state e t and the intermediate vector x at the previous moment t-1 As input, output the loop state h at the current time t t and the intermediate vector x t ; S16: By dynamic predictor Receive loop status h t , output the latent space random variable at the next moment S17: By Reward Predictor Receive loop status h t and latent space random variables Output the reward at the current time t S18: By the termination predictor Receive loop status h t and latent space random variables Output the predicted value of the termination signal at the current time t S19: Based on environmental observation data award Termination signal prediction value Construct a loss function and determine whether the loss function at the current time t is less than the set value. If yes, obtain the final world model. If no, proceed to step S110. S110: Adjust the observation encoder q φ (z t |o t ), Image Decoder Motion Information Mixer φ (z t ,a t ), Sequence Model f φ (e 1:T ,x 0 ), Dynamic Predictor Reward Predictor Termination Predictor , and then re-execute steps S11 to S19 until the loss function is less than the set value.
3. A method for manipulating a robotic arm based on selective state space and model-based reinforcement learning as claimed in claim 2, It is characterized in that According to environmental observation data award Termination signal Constructing the loss function as follows: Where φ is the observation encoder q φ (z t |o t ), Image Decoder Motion Information Mixer φ (z t ,a t ), Sequence Model f φ (e 1:T ,x 0 ), Dynamic Predictor Reward Predictor Termination Predictor A set of parameters; is the observation reconstruction loss at the current time t, is the reward prediction loss at the current time t, is the predicted loss of the termination signal at the current time t, is the dynamic prediction loss at the current time t, is the representation loss at the current time t, β 1 is the weight of the dynamic prediction loss, β 2 is the weight representing the loss.
4. A method for manipulating a robotic arm based on selective state space and model-based reinforcement learning as claimed in claim 3, It is characterized in that Observation reconstruction loss The calculation method is: Among them, ||·|| 2 Indicates calculation of Euclidean distance; Reward prediction loss The calculation method is: Among them, twohot means double hot encoding, symlog(r t )=sign(r t )ln(|r t |+1), Reward Logits is the reward predictor Output reward regression vector; Termination signal prediction loss The calculation method is: Among them, c t is the actual value of the termination signal at the current time t; Dynamic prediction loss The calculation method is: Representation loss The calculation method is: Among them, sg() is the termination gradient operator, z t+1 is the latent space random variable at the next moment, o t+1 is the environmental observation data captured by the image sensor at the next moment, KL[ ] represents the KL divergence, It represents the dynamic predictor with h t Predicted for input distribution.
5. A method for manipulating a robotic arm based on selective state space and model-based reinforcement learning as claimed in claim 2, It is characterized in that The robot model interacts with the world model, and the action sequence of the robot model under different environmental observations is obtained as follows: S21: The historical environmental observation data of 8 consecutive time steps o 0 ~o 7 , the robot arm observes the data in the environment o 0 ~o 7 The historical action a executed 0 ~a 7 Input into the world model to get the initial intermediate vector x 0 , loop state h 0 and the latent space random variable z 1 ; S22: The world model will h 0 With z 1 Passed to the robotic arm model, the robotic arm model outputs the decision action S23: The action information mixer will z 1 and Splicing, mapping to e 1 , the sequence model is based on e 1 and x 0 As input, output the loop state h of the current time step 1 and the intermediate vector x 1 ; S24: h 1 Input to the dynamic predictor, h 1 Mapped to 1024-dimensional regression vector Logits; S25: Divide the regression vector Logits into 32 groups of 32-dimensional vectors, perform activation function softmax operation, and output 32 groups of prior distributions; S26: Randomly sample 32 groups of prior distributions and use one-hot encoding to represent the sampling results, then sequentially concatenate the 32 groups of sampling results represented by one-hot encoding back to 1024 dimensions to obtain the latent space random variables of the next time step predicted by the dynamic predictor S27: h 1 , Pass it to the reward predictor, terminate the predictor, and get the predicted reward and termination signal prediction value S28: Repeat steps S22 to S27 until T sets of trajectory data are obtained, wherein the T sets of trajectory data include the cycle state h 0:T-1 , the predicted latent space random variable Prediction Rewards Predicted termination signal prediction value 6. A method for manipulating a robotic arm based on selective state space and model-based reinforcement learning as claimed in claim 5, It is characterized in that Training the robot model using action sequences observed in different environments specifically includes the following steps: S31: respectively convert the T groups of trajectory data into With h t-1 Splice and get T states s t ; S32: Based on the rewards in the trajectory data of group T Get each state s separately t The corresponding value function V ψ (s t ); S33: Each state s t Input the robot model and output the robot's decision action; S34: According to the value function V ψ (s t ), the decision action constructs the training loss function of the robot arm model, and determines whether the training loss function is less than the set value. If yes, the final robot arm model is obtained; if not, proceed to step S35; S35: Change the parameters of the robot model and re-execute steps S31 to S34 until the training loss function is less than the set value.
7. A method for manipulating a robotic arm based on selective state space and model-based reinforcement learning as claimed in claim 6, It is characterized in that The training loss function of the robotic arm model is as follows: Among them, θ is the parameter to be optimized of the policy function, is the loss function corresponding to the strategy function, ψ is the parameter to be optimized of the value function, is the loss function corresponding to the value function, sg() is the termination gradient operator, b is the training batch, L is the length of the trajectory data used in each batch, S is the set reduction factor, For state s t Next select action Strategy function, HL() represents Histogram encoding, max() represents the maximum value, η represents the set weight, represents the entropy of the policy function, the activation function Where V represents the value function V ψ () in s t is the original output of the input, a vector of dimension 255, v j represents the value of the jth dimension of V, To estimate the true value function by time difference, we have: Among them, λ is the set weight and γ is the attenuation coefficient.
8. A method for manipulating a robotic arm based on selective state space and model-based reinforcement learning as claimed in any one of claims 1 to 7, It is characterized in that The movement of the robot arm is a seven-dimensional vector. The first three dimensions represent the coordinate changes of the robot end controller along the x-axis, y-axis, and z-axis in the Cartesian coordinate system; the middle three dimensions represent the rotation angles of the robot end controller with the x-axis, y-axis, and z-axis as the rotation axes; the last dimension represents the opening and closing of the gripper at the end of the robot arm.
Citation Information
Patent Citations
Mechanical arm pushing and grabbing cooperation method suitable for dense environment
CN112643668A
Industrial mechanical arm motion planning method based on reinforcement learning algorithm
CN113510704A
Deep reinforcement learning mechanical arm motion planning method based on maximum entropy frame
CN115091469A
Intelligent agent control method based on deep reinforcement learning and conditional entropy bottleneck
CN115167136A
Strategy learning method based on optimizable image conversion for mechanical arm grabbing
CN116175577A
Cited By
Vision-based sample tube selection and exception decision processing method and system
CN119246530A
Transform-based method and device for constructing sample efficient world model
CN119271974A
Sequence parallel model-based reinforcement learning method
CN119692422A
Robot time sequence imitation learning method and system based on Mama coding complete history
CN120791743A
Surgical robot control method and system based on world model and reinforcement learning and robot system
CN120791749A
