Snakelike robot swing motion gait generation method and system based on reinforcement learning
By designing the oscillation gait of the snake-like robot based on reinforcement learning methods, the torque saturation problem of the snake-like robot in the large-scale cross-pole movement between trees is solved, the movement efficiency is improved, and it provides a better solution for its tasks among trees. the basis of.
Patent Information
- Application Number
- CN202410842965.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-27
AI Technical Summary
Existing snake-like robots have a torque saturation problem when moving across a large range of poles between trees, resulting in low movement efficiency and difficulty in achieving efficient tree climbing and reconnaissance tasks.
Using a method based on reinforcement learning, the snake-like robot swing motion simulation environment is established, the optimal joint parameters and strategies are calculated, the joint swing torque size and direction are designed, an efficient swing motion gait is generated, and the joints are optimized using reinforcement learning models and cloning models. Torque control.
It effectively solves the problem of torque saturation, improves the efficiency and speed of the snake robot's large-scale cross-bar movement between trees, and provides a better foundation for its movement between trunks and branches, branches and trees, and can be applied to Force control for other high-redundancy robots.
Smart Images

Figure CN118752479A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of snake-like robot motion gait design, and in particular to a method and system for generating a swinging motion gait of a snake-like robot based on reinforcement learning. Background Art
[0002] As a bionic robot, the snake-like robot can form a variety of gaits and configurations through its own configuration changes, thus adapting to a variety of environments, and also has a simple orthogonal joint configuration. Among them, the three-dimensional snake-like robot without passive wheels is expected to achieve bionic functions such as climbing trees, and then perform tasks such as reconnaissance.
[0003] The snake robot's ability to move between trees is the basis for these reconnaissance missions. The ability to move between trunks and branches, branches and branches, and trees and trees allows the snake robot to better complete reconnaissance missions. To improve the snake robot's ability to move between trees, an efficient inter-tree movement gait is essential.
[0004] At present, there are two major methods for the gait design of snake-like robots. The first is the wave function method. [1] , that is, a trigonometric function of the joint ordinal number and time is assigned to each joint of the snake-like robot. The other given parameters are different and are calculated through the gait geometry parameters. Substituting the time and joint angle ordinal number at each moment can calculate a set of angles that allow the snake-like robot to present a gait; the second type is the curve planning method [2] , split the target gait curve into simple curve segments with known geometric parameters and clarify the positional relationship between the curve segments. The snake robot is shorter than the target gait curve and is a segment of the target gait curve. According to the position of the snake robot on the target curve, the current joint angle can be calculated by the integration method.
[0005] Using curve splicing or wave function-based methods to construct motion gaits, snake robots can achieve movements such as climbing tree trunks and ladders. However, using static planning methods, namely curve splicing and wave function methods, can only achieve single-pole climbing or small-scale cross-pole movement, and the movement time is long and the speed is slow. For large-scale cross-pole movement between trunks and branches, branches and branches, and trees and trees, it is difficult to overcome the problem of torque saturation using static planning methods.
[0006] Therefore, how to design the tree-to-tree locomotion gait of the snake-like robot to achieve better locomotion performance is an issue that needs to be addressed urgently. Summary of the invention
[0007] In order to solve the above technical problems, the present invention provides a method and system for generating a swinging motion gait of a snake-like robot based on reinforcement learning.
[0008] According to one aspect of the present invention, a method for generating a swinging motion gait of a snake-like robot based on reinforcement learning is proposed, the method comprising:
[0009] Establishing a simulation environment for the swinging motion of a snake-like robot, and obtaining optimal joint parameters based on the optimal excitation trajectory calculation; wherein the multiple joints of the snake-like robot are arranged orthogonally and alternately, and each joint contains multiple joint parameters;
[0010] The optimal joint parameters are used as a reinforcement learning environment to train and obtain a reinforcement learning strategy, wherein the strategy is the swing torque of each joint of the snake-like robot;
[0011] Design the swing torque direction of each joint of the snake robot based on energy pumping and collision rules;
[0012] The swinging motion gait is generated according to the magnitude and direction of the swing torque of each joint of the snake-like robot.
[0013] Furthermore, the joint parameters of each joint include: joint mass, joint coordinates, principal moment of inertia of the joint, joint coordinate transformation vector, armature inertia and friction coefficient.
[0014] Furthermore, the method of obtaining the optimal joint parameters based on the optimal excitation trajectory includes: determining the optimal excitation trajectory; in an actual environment, making the snake-like robot move according to the optimal excitation trajectory, obtaining the actual value of the swing torque of each joint of the snake-like robot, determining the objective function as: the difference between the actual value and the theoretical value of the swing torque, and determining the constraint conditions; using simulation software to optimize and solve the objective function to obtain the optimal joint parameters.
[0015] Furthermore, the determining of the optimal excitation trajectory includes: establishing a dynamic model T of the snake-like robot; linearizing the dynamic model, expressed as: T=W×P, W represents a matrix composed of joint angles, angular velocities, and angular accelerations, and P represents all joint parameters; performing QR decomposition on the linearized dynamic model to obtain the maximum linearly independent matrix W min and the minimum parameter set P min , the linearized dynamic model is converted into: T′=W min ×P min ; Solve multiple groups of excitation trajectories so that the maximum linearly independent matrix W min The excitation trajectory with the smallest condition number is the optimal excitation trajectory.
[0016] Furthermore, the dynamic model T is composed of multiple T i Composition, T i It is expressed as:
[0017]
[0018] Among them, n iz represents the moment n at the i-th joint i The Z-axis component of ai represents the armature inertia of the i-th joint; ddQZ i represents the coordinate of the angular acceleration of the i-th joint in the joint coordinate system; f vi , f ci Denote the friction coefficient respectively; dQZ i represents the coordinate of the angular velocity of the i-th joint in the joint coordinate system; sgn represents the sign function.
[0019] Furthermore, the multiple groups of excitation trajectories are solved so that the maximum linearly independent matrix W min The excitation trajectory with the smallest condition number is the optimal excitation trajectory, which includes: multiple groups of excitation trajectories are composed of 1st to 5th order sine curves and 1st to 5th order cosine curves, and the joint angle, angular velocity, and angular acceleration are obtained by sampling at the actual sampling frequency, and the maximum linearly independent matrix W is obtained by substitution. min , the condition number is optimized and solved using simulation software to obtain the optimal excitation trajectory.
[0020] Furthermore, the objective function corresponding to the difference between the actual value and the theoretical value of the swing torque is expressed as:
[0021] min((ww×P min ′-T″) 2 );
[0022] Where min means minimization; ww represents the maximum linear independent matrix corresponding to the actual value of the swing torque; T″ represents the theoretical value of the swing torque composed of multiple joint torques without considering friction and armature inertia; P min ′ represents the minimum parameter set corresponding to the actual value of the swing torque;
[0023] The constraint condition is set as: joint mass m i The error with the actual weighing does not exceed the preset threshold; the center of mass coordinates of the joint m i1 , m i2 , m i3 The main moment of inertia of the joint is not more than the length, width and height of the joint itself; i11 , I i22 , I i33 The sum of any two terms is greater than the third term; the sum of the squares of the sine and cosine values of the fixed angles α1, β1, and γ1 in the joint coordinate transformation vector is 1, and the sine and cosine values are between ±1; the armature inertia of the joint I ai , friction coefficient f vi , f ci Both are greater than 0.
[0024] Furthermore, the reinforcement learning strategy includes an expert oscillating motion strategy in a non-delay environment and an expert oscillating motion strategy in a delayed environment, wherein the expert oscillating motion strategy in the non-delay environment corresponds to a first reinforcement learning model, and the expert oscillating motion strategy in the delayed environment corresponds to a second behavior cloning model;
[0025] Using the optimal joint parameters as the environment for reinforcement learning, the strategy for training to obtain reinforcement learning includes:
[0026] When sampling, the state-action pair at the current moment is used to obtain the state at the next moment, and the state at the next moment is used as the input of the first reinforcement learning model to generate the action a at the next moment. t+1 At the same time, the state-action pair at the current moment is used as input, and the policy network of the second behavior cloning model is used to generate the action a′ at the next moment t+1 , action a′ t+1 Interact with the environment as the action input for the next moment; repeat the above sampling process to obtain sequence data, form a trajectory, and put the obtained sequence data into the experience replay pool;
[0027] During the update, N samples are randomly drawn from the experience replay pool and the action a generated by the first reinforcement learning model is t+1 As the teacher network, the second line is the action a′ generated by the policy network of the clone model t+1 As a student network, the loss function is calculated as follows:
[0028]
[0029] Then back propagation is performed to calculate the gradient and update the weights of the policy network.
[0030] Furthermore, the design rules for the swing torque direction of each joint of the snake-like robot include:
[0031] In the snake robot swing motion simulation environment, the snake robot is wound around a horizontal bar, and a reference axis l1 parallel to the horizontal bar and a reference axis l2 perpendicular to the ground and upward are established; the reference axis l1 is connected to the joint axis l j The angle between the reference axis l2 and the joint axis l is denoted as α. j The angle is recorded as β, and the jth joint and the joints after it are determined as pitch joints or yaw joints according to the size relationship between α and β;
[0032] The direction of the pitch joint torque is consistent with the angular velocity of the first joint;
[0033] When the angular velocity of the first joint is positive and swings to the right, the yaw joint moves to the left; when the angular velocity of the first joint is negative and swings to the left, the yaw joint moves to the right.
[0034] According to another aspect of the present invention, a snake-like robot swinging motion gait generation system based on reinforcement learning is proposed, the system comprising:
[0035] An environmental data acquisition module, which is configured to establish a simulation environment for the swinging motion of a snake-like robot and obtain optimal joint parameters based on the optimal excitation trajectory calculation; wherein the multiple joints of the snake-like robot are arranged orthogonally and alternately, and each joint includes multiple joint parameters;
[0036] A strategy training module, configured to use the optimal joint parameters as a reinforcement learning environment to train and obtain a reinforcement learning strategy, wherein the strategy is the swing torque of each joint of the snake-like robot;
[0037] A direction design module configured to design the direction of the swing torque of each joint of the snake-like robot based on energy pumping and collision rules;
[0038] The gait generation module is configured to generate a swinging motion gait according to the magnitude and direction of the swing torque of each joint of the snake-like robot.
[0039] The present invention has the following technical effects:
[0040] The present invention designs an efficient swinging motion gait based on reinforcement learning for the inter-tree motion of the snake-like robot. Compared with the gaits designed by the existing static planning methods such as curve splicing and wave functions, the present invention can effectively solve the problem of torque saturation and provide a basis for the large-scale cross-pole motion of the snake-like robot between tree trunks and branches, branches and branches, and trees and trees. Furthermore, the swinging motion gait designed by the present invention can be applied to other high-redundancy robots controlled by torque to complete other functions. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 A flowchart of a method for generating a swinging motion gait of a snake-like robot based on reinforcement learning according to an embodiment of the present invention;
[0043] Figure 2 It is a front view of the swinging experimental frame of the snake-type robot in the embodiment of the present invention;
[0044] Figure 3 It is a right view of the snake-type robot swinging experimental frame in an embodiment of the present invention;
[0045] Figure 4 A top view of a snake-type robot swinging experimental frame in an embodiment of the present invention;
[0046] Figure 5 It is a diagram of the algorithm framework in a non-delay environment in an embodiment of the present invention;
[0047] Figure 6 It is a diagram of an algorithm framework in a delayed environment in an embodiment of the present invention;
[0048] Figure 7 Schematic diagram of the experimental platform in the embodiment of the present invention;
[0049] Figure 8 It is an experimental effect diagram in the embodiment of the present invention;
[0050] Fig. 9 This is a schematic diagram of the structure of a snake-like robot swinging motion gait generation system based on reinforcement learning described in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.
[0052] The embodiment of the present invention proposes a method for generating a swinging motion gait of a snake-like robot based on reinforcement learning, such as Figure 1 As shown, the method comprises the following steps:
[0053] S1. Establish a simulation environment for the swinging motion of a snake-like robot, and obtain optimal joint parameters based on the optimal excitation trajectory calculation; wherein, multiple joints of the snake-like robot are arranged orthogonally and alternately, and each joint contains multiple joint parameters; the joint parameters contained in each joint include: joint mass, joint coordinates, principal moment of inertia of the joint, joint coordinate conversion vector, armature inertia and friction coefficient;
[0054] S2, using the optimal joint parameters as the environment for reinforcement learning, training to obtain a reinforcement learning strategy, wherein the strategy is the swing torque of each joint of the snake-like robot;
[0055] S3. Design the swing torque direction of each joint of the snake robot based on energy pumping and collision rules;
[0056] S4. Generate a swinging motion gait according to the magnitude and direction of the swing torque of each joint of the snake-like robot.
[0057] The method starts from S1. In S1, a simulation environment for the swinging motion of a snake robot is established, and optimal joint parameters are obtained based on the optimal excitation trajectory calculation.
[0058] According to an embodiment of the present invention, firstly, a simulation environment for the swinging motion of a snake-like robot is constructed based on semi-positive definite programming system identification.
[0059] Figure 2-Figure 4 The schematic diagram of the snake robot swinging experimental frame is shown. The blue curve is the fixed base part of the snake robot, which is fixed; the white circle represents a joint of the snake robot swinging part; the black dotted line represents the reference axis l1 parallel to the horizontal crossbar, and its direction is perpendicular to the paper and outward; the red dotted line represents the joint axis l j ; The green dotted line represents the reference axis l2 that is perpendicular to the ground and upward, and α is l1, l j The angle between l2 and l j The angle; j1, j2, j3, j4... represent the joint 1, joint 2, joint 3, joint 4... of the swinging part of the snake-like robot.
[0060] The swinging part of the snake robot has 8 joints, each with 16 joint parameters: m i , m i1 , m i2 , m i3 , I i11 , I i22 , I i33 , sinα1, sinβ1, sinγ1, cosα1, cosβ1, cosγ1, I ai , f vi , f ci Among them, m i is the mass of the i-th joint, m i1 , m i2 , m i3 is the coordinate of the i-th joint in the link coordinate system, I i11 , I i22 , I i33 is the principal moment of inertia of the i-th joint module; the joint coordinate transformation vectors include sinα1, sinβ1, sinγ1, cosα1, cosβ1, cosγ1, α1, β1, γ1 are the XYZ fixed angles of the joint coordinate system of the i-th joint module rotated to the spindle coordinate system, sinα1, sinβ1, sinγ1, cosα1, cosβ1, cosγ1 are their respective sine and cosine values; I ai represents the armature inertia, f vi , f ci Represents the friction coefficient.
[0061] Then, execute the following steps: S11, determine the optimal excitation trajectory; S12, in the actual environment, make the snake-like robot move along the optimal excitation trajectory, obtain the actual value of the swing torque of each joint of the snake-like robot, determine the objective function as: the difference between the actual value and the theoretical value of the swing torque, and determine the constraint conditions; S13, use simulation software to optimize and solve the objective function to obtain the optimal joint parameters.
[0062] Among them, determining the optimal excitation trajectory in S11 includes: S111, establishing a dynamic model T of the snake-like robot; S112, linearizing the dynamic model, expressed as: T=W×P, W represents a matrix composed of joint angles, angular velocities, and angular accelerations, and P represents all joint parameters; S113, performing QR decomposition on the linearized dynamic model to obtain the maximum linearly independent matrix W min and the minimum parameter set P min , the linearized dynamic model is converted into: T′=W min ×P min ; S114, solving multiple groups of excitation trajectories, so that the excitation trajectory with the smallest maximum linear independent matrix condition number is the optimal excitation trajectory.
[0063] Specifically, in S111, the swinging part of the snake-like robot is dynamically modeled. Since the fixed base part of the snake-like robot is fixed and does not move, which is equivalent to the flange of the mechanical arm, the swinging part of the snake-like robot can be modeled as a mechanical arm. The dynamic modeling is performed using the Newton-Euler method as follows.
[0064] The length of each joint link is d, and the joint angle of the i-th joint is q i , the angular velocity of the i-th joint is recorded as dq i , the joint angular acceleration of the i-th joint is recorded as ddq i , the rotation coordinate system from the i-th joint to the i+1-th joint is:
[0065] i is an even number;
[0066] i is an odd number;
[0067] Among them, c i+1 ,s i+1 represents the sine and cosine values of the i-th joint angle, i = 0, 1, 2, ..., 7. Among them, i = 0 represents the world coordinate system, and the others represent the i-th joint coordinate system.
[0068] Then vectorize:
[0069]
[0070] Among them, dQZi Represents the coordinate of the angular velocity of the i-th joint in the joint coordinate system.
[0071]
[0072] Among them, ddQZ i Represents the coordinate of the angular acceleration of the i-th joint in the joint coordinate system.
[0073]
[0074]
[0075] in, Represents the coordinates of the distance between the origin of the world coordinate system and the first joint coordinate system in the world coordinate system. Represents the distance between the origin of the i-th joint coordinate system and the i+1-th joint coordinate system in the i-th joint coordinate system.
[0076]
[0077] Among them, P ci Represents the coordinates of the center of mass of the i-th joint in the i-th joint coordinate system.
[0078]
[0079] Among them, I comi Represents the inertia matrix of the i-th joint module in the spindle coordinate system.
[0080]
[0081] Among them, R comi Represents the rotation matrix from the coordinate system with the origin at the center of mass and the same posture as the i-th joint coordinate system to the i-th joint spindle coordinate system.
[0082] I ci =R comi ×I comi ×R comi T ;
[0083] Among them, I ci Represents the inertia matrix of the i-th joint module in the coordinate system with the origin at the center of mass and the same posture as the joint coordinate system.
[0084]
[0085]
[0086]
[0087] Among them, ω0 represents the angular velocity of the world coordinate system, dω0 represents the angular acceleration of the world coordinate system, and dv0 represents the linear acceleration of the world coordinate system.
[0088] Next, extrapolate to find the velocity and acceleration:
[0089]
[0090]
[0091]
[0092] dv ci+1 =dω i+1 ×P ci+1 +ω i+1 ×(ω i+1 ×P ci+1 )+dv i+1 ;
[0093] F i+1 =m i+1 ×dv ci+1 ;
[0094] N i+1 =I ci+1 ×dω i+1 +ω i+1 ×(I ci+1 ×ω i+1 );
[0095] Where i = 0, 1, 2, ..., 7. i+1 represents the angular velocity of the i+1th joint coordinate system, dω i+1 represents the angular acceleration of the i+1th joint coordinate system, dv i+1 Represents the linear acceleration of the i+1th joint coordinate system. dv ci+1 Represents the linear acceleration of the center of mass of the i+1th joint module. i+1 Indicates that dv is generated at the center of mass of the i+1th joint ci+1 The force required for the linear acceleration. N i+1 Indicates that dω is generated at the mass center of the i+1th joint i+1 The torque required for the angular acceleration.
[0096] Next, the joint torque is obtained by internalization:
[0097] f i =f i+1 +F i ;
[0098]
[0099]
[0100] Among them, i=1, 2, ..., 7, 8, f9=0, n9=0, F9=0, f9=0, f i represents the required force at the i-th joint, n i It represents the torque required for the i-th joint when friction and armature inertia are not considered, which includes three components of X, Y, and Z axes: n ix 、n iy 、n iz .
[0101] Finally, the armature inertia is added and the friction is overcome to obtain the final joint torque required at the i-th joint:
[0102]
[0103] Among them, T i represents the joint torque at the i-th joint; n iz represents the i-th joint torque n without considering friction and armature inertia i The Z-axis component of ai represents the armature inertia of the i-th joint; ddQZ i represents the coordinate of the angular acceleration of the i-th joint in the joint coordinate system; f vi , f ci Denote the friction coefficient respectively; dQZ i represents the coordinate of the angular velocity of the i-th joint angle in the joint coordinate system; sgn represents the sign function. i = 1, 2, ..., 7, 8.
[0104] In S112, the dynamic model is linearized and expressed as: T = W × P.
[0105] Specifically, all joint parameters of all the swinging joints of the snake robot are recorded as P, which is a vector of 128×1. The goal of linearization is to find the matrix W so that the following equation holds:
[0106] T = W × P;
[0107] Among them, T represents the joint torque, which is an 8×1 vector, and W is an 8×128 matrix, which consists only of the joint angle q i , angular velocity dq i , angular acceleration ddq i composition.
[0108] For the matrix value W[j, k] to be obtained, set the kth parameter of the joint in the dynamic equation to 1 and all other parameters to 0, and obtain i , dq i,ddq i The matrix value W[j, k] is composed of.
[0109] In S113, the linearized dynamic model is subjected to QR decomposition to obtain the maximum linearly independent matrix W min and the minimum parameter set P min , the linearized dynamic model is converted into: T′=W min ×P min .
[0110] Specifically, for matrix W, its column vectors are not linearly independent. Therefore, it is necessary to find the largest linearly independent group of its column vectors to form the matrix W min , the corresponding parameter set is the minimum parameter set P min , so that:
[0111] T′=W min ×P min ;
[0112] Use QR decomposition to find the minimum parameter set: randomly generate joint angles, angular velocities, and angular accelerations q i , dq i ,ddq i , substitute into the matrix W, perform QR decomposition on it to get the matrix R, if R[k, k] is not equal to 0, then the kth parameter belongs to the minimum parameter set, and the kth column of the matrix W belongs to the matrix W min ; Otherwise, the kth parameter does not belong to the minimum parameter set, and the kth column of matrix W does not belong to matrix W min . From this we can get the matrix W min , the corresponding parameter set is the minimum parameter set P min For example, if W is a 8×128 matrix, the largest linearly independent matrix of its column vectors is from column 1 to column 100, and the corresponding P min That is, rows 1 to 100 of P.
[0113] In S114, multiple groups of excitation trajectories are solved so that the excitation trajectory with the smallest maximum linear independent matrix condition number is the optimal excitation trajectory.
[0114] Specifically, it is assumed that the multiple sets of excitation trajectories of the swinging part of the snake-like robot are composed of first to fifth order sine curves and first to fifth order cosine curves; the joint angle, angular velocity, and angular acceleration q are obtained by sampling at the actual sampling frequency. i , dq i ,ddq i , substituting into the matrix W min , all W min In the row direction, a matrix ww is formed; multiple groups of excitation trajectories are optimized and solved so that the generated matrix W minThe condition number is minimized. As an example, use the matlab fmincon() function to optimize the matrix W min Condition number, and obtain the optimal excitation trajectory.
[0115] Then in S12, the snake-like robot is made to move along the optimal excitation trajectory in the actual environment, the actual value of the swing torque of each joint of the snake-like robot is obtained, the objective function is determined as: the difference between the actual value and the theoretical value of the swing torque, and the constraint conditions are determined.
[0116] Specifically, first, the optimal excitation trajectory is sent to the snake robot in the actual environment as a position command, the angle, angular velocity, and current of the actual snake robot are read, the angular velocity is differentiated to obtain the angular acceleration, and the current is converted into torque according to the current-torque performance curve of the servo. Then, the obtained angle, angular velocity, angular acceleration, and torque are filtered. As an example, the filter is selected by the butter() function of matlab. Then, the parameter identification of the robot with constraints is converted into a semi-positive programming problem. As an example, the YAMLIP toolbox can be used for optimization.
[0117] The filtered angle, angular velocity, and angular acceleration q i , dq i ,ddq i Substituting in, we get the matrix W min , all W min In the row direction, a matrix ww is formed to obtain the equation of the actual value of the torque: T 实 =ww×P min , then the objective function is to minimize the difference between the actual value and the theoretical value of the swing torque, expressed as:
[0118] min((ww×P min ′-T″) 2 );
[0119] Where min means minimization; ww represents the maximum linear independent matrix corresponding to the actual value of the swing torque; T″ represents the theoretical value of the swing torque composed of multiple joint torques without considering friction and armature inertia; P min ′ represents the minimum parameter set corresponding to the actual value of the swing torque;
[0120] The constraint conditions are set as: joint mass m i The error with the actual weighing does not exceed the preset threshold (for example, 0.1kg); the center of mass coordinates of the joint m i1 , m i2 , m i3 The main moment of inertia of the joint is not more than the length, width and height of the joint itself; i11 , I i22 , I i33The sum of any two terms is greater than the third term; the sum of the squares of the sine and cosine values of the fixed angles α1, β1, and γ1 in the joint coordinate transformation vector is 1, and the sine and cosine values are between ±1; the armature inertia of the joint I ai , friction coefficient f vi , f ci Both are greater than 0.
[0121] Then, in S13, the objective function is optimized and solved using simulation software to obtain the optimal joint parameters. As an example, the solvesdp() function of the YAMLIP toolbox is used for optimization, and the minimum parameter set is obtained as the optimal joint parameters.
[0122] Furthermore, the matrix R obtained by QR decomposition is used to transform the optimal joint parameters into a complete parameter set, and the complete parameter set is matched one by one with the parameters in the file of the open source simulation environment to obtain a simulation environment that conforms to reality.
[0123] Then, after obtaining the optimal joint parameters based on the optimal excitation trajectory calculation, S2 is executed. In S2, the optimal joint parameters are used as the environment of reinforcement learning to train and obtain the reinforcement learning strategy, wherein the strategy is the swing torque of each joint of the snake-like robot; wherein the reinforcement learning strategy includes the swinging motion expert strategy in a non-delay environment and the swinging motion expert strategy in a delayed environment, wherein the swinging motion expert strategy in the non-delay environment corresponds to the first reinforcement learning model, and the swinging motion expert strategy in the delayed environment corresponds to the second behavior cloning model.
[0124] According to an embodiment of the present invention, the first reinforcement learning model corresponding to the expert strategy of the swinging motion in the non-delay environment can adopt an existing model, such as Figure 5 As shown, as an example, the first reinforcement learning model structure includes an action value function network, a hidden state encoding network, a dynamics model network, a reward network, and a strategy network. The input of the action value function network is the hidden state and action, and the output is the state value function; the input of the hidden state encoding network is the state, and the output is the encoded hidden state; the input of the dynamics model network is the hidden state and action, and the output is the hidden state at the next moment; the input of the reward network is the hidden state and action, and the output is the reward at the next moment; the input of the strategy network is the state, and the output is the action; the reward is set as the mechanical energy of the swinging part of the snake robot.
[0125] The loss functions of the hidden state encoding network, dynamics model network, reward network, and action value function network are as follows:
[0126]
[0127]
[0128]
[0129] loss=consistent_loss+reward_loss+value-loss;
[0130] Where N represents the number of samples drawn from the experience replay pool; horizon represents the horizon of model predictive control; z i+t represents the state at time i+t; z i+tDred Represents the state prediction at time i+t; r i+t represents the return at time i+t; r i+tDred represents the predicted return at time i+t; represents the output of the action value function network at time i+t; (Q(z i+t , a i+t )-(r+Q(z i+t+1 , a i+t+1 ))) 2 Represents the td error of the action-value function network at time i+t; rho represents a constant factor that attenuates the error at subsequent moments.
[0131] Update the policy network according to the following formula:
[0132]
[0133] Among them, Q(z i+t , a i+t ) represents the output of the action-value function network at time i+t, and rho represents a constant factor that attenuates the output of the action-value network at subsequent times.
[0134] Each time the model samples one or more trajectories to reach the set data volume, the weights of the hidden state encoding network, dynamics model network, reward network, action value function network and policy network are updated once. Each weight update includes the following two steps:
[0135] 1) Sampling: First, use the hidden state encoding network to encode the current state s t Encoded as hidden state z t , the current policy network π is based on the hidden state z t Get the mean μ of the Gaussian strategy and get a series of actions a using Gaussian distribution sampling π Next, enter the loop and use the action predicted at time t and later as the mean. If there is no mean, set the mean to 0 and use Gaussian distribution sampling to obtain a series of actions a g , using the dynamics model network, reward network, and action value function network to analyze action a g and action a π Evaluate and select a certain number of actions with the highest cumulative discount returnelite , generate the mean and variance for the next cycle to generate a g After the loop is completed, the optimal sequence action a of the evaluation function is generated, which is a sequence action a with a length of horizon t , a t+1 , .., a t+horizon . t As input, interact with the environment to get the state s at the next moment t+1 , get the immediate reward r at this moment t , and then according to the state s at the next moment t+1 , repeat the previous action selection process to get the action a at the next moment t+1 ; Repeat the sampling process to obtain sequence data and form a trajectory Where T is the termination time. The obtained sequence data is put into the experience replay pool.
[0136] 2) Update: Randomly extract N samples from the experience replay pool and calculate loss and L using the loss function described above π , then back-propagation is performed to calculate the gradient and update the weights of the hidden state encoding network, dynamics model network, reward network, action value function network, and policy network.
[0137] However, in actual environments, there are delay problems caused by communication delay and computational delay. Therefore, the present invention further designs a second behavior cloning model to train an expert strategy for oscillating motion in a delayed environment.
[0138] like Figure 6 As shown in the simulation environment with delay, the system uses the current state action pair (s t , a t ) Calculate the action a at the next moment t+1 , as the action input for the next moment, and obtain the state-action pair for the next moment (s t+1 , a t+1 ), repeat the above process to get a trajectory. The second line of the cloning model structure includes a policy network, the input of the policy network is the current state action pair (s t , a t ), the output is the action a at the next moment t+1 Each time the model samples a step, the weights of the policy network are updated. Each weight update includes the following two steps:
[0139] 1) Sampling: Use the current state-action pair (s t , a t ) Get the state s at the next moment t+1 , using the next moment state s t+1As the input of the first reinforcement learning model, generate the action a at the next moment t+1 At the same time, the current state action pair (s t , a t ) as input, and use the second behavior as the policy network of the clone model to generate the action a′ at the next moment t+1 , action a′ t+1 As the action input for the next moment to interact with the environment. Repeat the sampling process to obtain sequence data, form a trajectory, and put the obtained sequence data into the experience replay pool.
[0140] 2) Update: Randomly extract N samples from the experience replay pool, and the action a generated by the first reinforcement learning model t+1 As the teacher network, the second line is the action a′ generated by the policy network of the clone model t+1 As a student network, the loss function is calculated as follows:
[0141]
[0142] After calculating the loss, back propagation is performed to calculate the gradient and update the weights of the policy network.
[0143] Then, S3 is executed. In S3, the swing torque direction of each joint of the snake-like robot is designed based on the energy pumping and collision rules; including: in the snake-like robot swinging motion simulation environment, the snake-like robot is wrapped around a horizontal crossbar, and a reference axis l1 parallel to the horizontal crossbar and a reference axis l2 perpendicular to the ground and upward are established; the reference axis l1 is connected to the joint axis l2. j The angle between the reference axis l2 and the joint axis l is denoted as α. j The angle is recorded as β, and the j-th joint and the subsequent joints are determined as pitch joints or yaw joints according to the size relationship between α and β; the torque direction of the pitch joint is consistent with the angular velocity of the first joint; when the angular velocity of the first joint is positive and swings to the right, the yaw joint moves to the left; when the angular velocity of the first joint is negative and swings to the left, the yaw joint moves to the right.
[0144] According to an embodiment of the present invention, the present invention proposes a rule for setting the torque direction of the joint module so that the snake-like robot moves in a swinging gait. The adjacent joints of the snake-like robot are arranged orthogonally. First, for the first joint j1 of the swinging part of the snake-like robot, if α>β, then the joint is recorded as a pitch joint, and the subsequent joints j2, j3, j4 are respectively yaw joints, pitch joints, yaw joints... If α<β, then the joint is recorded as a yaw joint, and the subsequent joints j2, j3, j4 are respectively pitch joints, yaw joints, pitch joints... Then, based on the rule of pumping energy, the pitch joint torque direction must be consistent with the angular velocity of the first joint, and energy is pumped in to increase the total mechanical energy of the system. Secondly, based on the principle of avoiding collision with the base part, the yaw joint torque direction is further determined. Figure 2 As shown in the figure, when the first joint angular velocity of the snake robot is positive and it swings to the right, it needs to avoid collision with the base part, so the yaw joint should move to the left. When the first joint angular velocity of the snake robot is negative and it swings to the left, the yaw joint should move to the right. The first joint can be determined by the order from top to bottom.
[0145] Finally, S4 is executed, in which a swinging motion gait is generated according to the magnitude and direction of the swing torque of each joint of the snake-like robot.
[0146] The technical effect of the present invention is further verified through experiments.
[0147] like Figure 7 As shown in the figure, the snake robot has 26 joints, a total length of 1.9m, a diameter of 0.066m, and weighs about 7kg. The servos used are Dynamixel XH540-W270, and the motors are divided into two groups. The axes of the servos in the same group are parallel to each other and face the same direction. The axes of adjacent servos are perpendicular to each other. Self-designed connectors are used between the servos, and a comb-shaped nylon shell is installed on the outside for protection. Starting from the head, 19 modules are wrapped around the horizontal crossbar and fixed by a fixing, which is the base part. The remaining 8 joints are suspended in the air, which is the swing part. After generating the swing strategy in a delayed environment, establish communication between the PC and the snake robot, power it through the power supply, use the 485 serial port to read the servo angle and angular velocity, input it into the swing strategy to calculate the joint torque in real time and send it to the robot.
[0148] The experimental results are as follows Figure 8 As shown, Figure 8 The oscillating motion capability of the snake-like robot in the three-dimensional motion gait designed by the present invention is demonstrated. The time interval between each small picture is 0.2s. Figure 8 It can be seen that the gait of the present invention imitates the swinging motion, can accumulate energy under a smaller torque limit, and reach a higher swinging height and swinging speed.
[0149] The embodiment of the present invention proposes a method for generating the swinging motion gait of a snake-like robot based on reinforcement learning. Compared with the gaits designed by existing static planning methods such as curve splicing and wave functions, it can effectively solve the problem of torque saturation, and provides a basis for the subsequent large-scale cross-pole movement of the snake-like robot between tree trunks and branches, branches and branches, and trees and trees. Therefore, it has high practical application value.
[0150] Another embodiment of the present invention provides a snake-like robot swinging motion gait generation system based on reinforcement learning, such as Fig. 9 As shown, the system includes:
[0151] An environmental data acquisition module 910 is configured to establish a simulation environment for the swinging motion of a snake-like robot and to obtain optimal joint parameters based on the optimal excitation trajectory calculation; wherein the multiple joints of the snake-like robot are arranged orthogonally and alternately, and each joint includes multiple joint parameters; the joint parameters included in each joint include: joint mass, joint coordinates, principal moment of inertia of the joint, joint coordinate conversion vector, armature inertia and friction coefficient;
[0152] A strategy training module 920 is configured to use the optimal joint parameters as a reinforcement learning environment to train and obtain a reinforcement learning strategy, wherein the strategy is the swing torque of each joint of the snake-like robot;
[0153] A direction design module 930, which is configured to design the direction of the swing torque of each joint of the snake-like robot based on energy pumping and collision rules;
[0154] The gait generation module 940 is configured to generate a swinging motion gait according to the magnitude and direction of the swing torque of each joint of the snake-like robot.
[0155] In this embodiment, preferably, the method of obtaining the optimal joint parameters based on the optimal excitation trajectory in the environmental data acquisition module 910 includes: determining the optimal excitation trajectory; in the actual environment, making the snake-like robot move according to the optimal excitation trajectory, obtaining the actual value of the swing torque of each joint of the snake-like robot, determining the objective function as: the difference between the actual value and the theoretical value of the swing torque, and determining the constraint conditions; using simulation software to optimize and solve the objective function to obtain the optimal joint parameters.
[0156] In this embodiment, preferably, the determining of the optimal excitation trajectory in the environmental data acquisition module 910 includes: the determining of the optimal excitation trajectory includes: establishing a dynamic model T of the snake-like robot; linearizing the dynamic model, expressed as: T = W × P, W represents a matrix composed of joint angles, angular velocities, and angular accelerations, and P represents all joint parameters; performing QR decomposition on the linearized dynamic model to obtain the maximum linearly independent matrix W min and the minimum parameter set P min, the linearized dynamic model is converted into: T′=W min ×P min ; Solve multiple groups of excitation trajectories so that the maximum linearly independent matrix W min The excitation trajectory with the smallest condition number is the optimal excitation trajectory.
[0157] In this embodiment, preferably, the objective function corresponding to the difference between the actual value and the theoretical value of the swing torque in the environmental data acquisition module 910 is expressed as:
[0158] min((ww×P min ′-T″) 2 );
[0159] Where min means minimization; ww represents the maximum linear independent matrix corresponding to the actual value of the swing torque; T″ represents the theoretical value of the swing torque composed of multiple joint torques without considering friction and armature inertia; P min ′ represents the minimum parameter set corresponding to the actual value of the swing torque;
[0160] The constraint condition is set as: joint mass m i The error with the actual weighing does not exceed the preset threshold; the center of mass coordinates of the joint m i1 , m i2 , m i3 The main moment of inertia of the joint is not more than the length, width and height of the joint itself; i11 , I i22 , I i33 The sum of any two terms is greater than the third term; the sum of the squares of the sine and cosine values of the fixed angles α1, β1, and γ1 in the joint coordinate transformation vector is 1, and the sine and cosine values are between ±1; the armature inertia of the joint I ai , friction coefficient f vi , f ci Both are greater than 0.
[0161] In this embodiment, preferably, the reinforcement learning strategy in the strategy training module 920 includes a swinging motion expert strategy in a non-delay environment and a swinging motion expert strategy in a delayed environment, wherein the swinging motion expert strategy in the non-delay environment corresponds to a first reinforcement learning model, and the swinging motion expert strategy in the delayed environment corresponds to a second behavior cloning model; using the optimal joint parameters as the reinforcement learning environment, training to obtain the reinforcement learning strategy includes:
[0162] When sampling, the state-action pair at the current moment is used to obtain the state at the next moment, and the state at the next moment is used as the input of the first reinforcement learning model to generate the action a at the next moment. t+1 At the same time, the state-action pair at the current moment is used as input, and the policy network of the second behavior cloning model is used to generate the action a′ at the next momentt+1 , action a′ t+1 Interact with the environment as the action input for the next moment; repeat the above sampling process to obtain sequence data, form a trajectory, and put the obtained sequence data into the experience replay pool;
[0163] During the update, N samples are randomly drawn from the experience replay pool and the action a generated by the first reinforcement learning model is t+1 As the teacher network, the second line is the action a′ generated by the policy network of the clone model t+1 As a student network, the loss function is calculated as follows:
[0164]
[0165] Then back propagation is performed to calculate the gradient and update the weights of the policy network.
[0166] In this embodiment, preferably, the design rules of the swing torque direction of each joint of the snake-like robot in the direction design module 930 include: in the snake-like robot swing motion simulation environment, the snake-like robot is wound on a horizontal crossbar, and a reference axis l1 parallel to the horizontal crossbar and a reference axis l2 perpendicular to the ground and upward are established; the reference axis l1 is connected to the joint axis l2. j The angle between the reference axis l2 and the joint axis l is denoted as α. i The angle is recorded as β, and the j-th joint and the subsequent joints are determined as pitch joints or yaw joints according to the size relationship between α and β; the torque direction of the pitch joint is consistent with the angular velocity of the first joint; when the angular velocity of the first joint is positive and swings to the right, the yaw joint moves to the left; when the angular velocity of the first joint is negative and swings to the left, the yaw joint moves to the right.
[0167] For the undetailed parts of the snake-like robot swinging motion gait generation system based on reinforcement learning according to an embodiment of the present invention, please refer to the above detailed description of the method embodiment.
[0168] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments may still be modified, or some or all of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the technical solutions of the embodiments of the present invention.
[0169] The documents cited in the present invention are as follows:
[0170] [1]M.Tesch,K.Lipkin,I.Brown,R.Hatton,A.Peck,J.Rembisz&H.Choset(2009)Parameterized and Scripted Gaits for Modular Snake Robots,Advanced Robotics,vol.23,no.9,pp.1131-1158,DOI:10.1163 / 156855309X452566.
[0171] [2]T.Takemori,M.Tanaka and F.Matsuno(2018)Gait Design for a SnakeRobot by Connecting Curve Segments and Experimental Demonstration,IEEETransactions on Robotics,vol.34,no.5,pp.1384-1391,doi:10.1109 / TRO.2018.28303。
Claims
1. A method for generating swinging motion gait of a snake-like robot based on reinforcement learning, characterized in that: include: Establishing a simulation environment for the swinging motion of a snake-like robot, and obtaining optimal joint parameters based on the optimal excitation trajectory calculation; wherein the multiple joints of the snake-like robot are arranged orthogonally and alternately, and each joint contains multiple joint parameters; The optimal joint parameters are used as a reinforcement learning environment to train and obtain a reinforcement learning strategy, wherein the strategy is the swing torque of each joint of the snake-like robot; Design the swing torque direction of each joint of the snake robot based on energy pumping and collision rules; The swinging motion gait is generated according to the magnitude and direction of the swing torque of each joint of the snake-like robot.
2. The method for generating a swinging motion gait of a snake-like robot based on reinforcement learning according to claim 1, characterized in that: The joint parameters of each joint include: joint mass, joint coordinates, joint principal moment of inertia, joint coordinate transformation vector, armature inertia and friction coefficient.
3. The method for generating a swinging motion gait of a snake-like robot based on reinforcement learning according to claim 2, characterized in that: The method of obtaining the optimal joint parameters based on the optimal excitation trajectory includes: determining the optimal excitation trajectory; in an actual environment, making the snake-like robot move according to the optimal excitation trajectory, obtaining the actual value of the swing torque of each joint of the snake-like robot, determining the objective function as: the difference between the actual value and the theoretical value of the swing torque, and determining the constraint conditions; using simulation software to optimize and solve the objective function to obtain the optimal joint parameters.
4. The method for generating a swinging motion gait of a snake-like robot based on reinforcement learning according to claim 3, characterized in that: The determination of the optimal excitation trajectory includes: establishing a snake-like robot dynamics model T; linearizing the dynamics model, expressed as: T = W × P, W represents a matrix composed of joint angles, angular velocities, and angular accelerations, and P represents all joint parameters; performing QR decomposition on the linearized dynamics model to obtain the maximum linearly independent matrix W min and the minimum parameter set P min , the linearized kinetic model is converted to: T ′ =W min ×P min ; Solve multiple groups of excitation trajectories so that the maximum linearly independent matrix W min The excitation trajectory with the smallest condition number is the optimal excitation trajectory.
5. The method for generating a swinging motion gait of a snake-like robot based on reinforcement learning according to claim 4, characterized in that: The kinetic model T consists of multiple T i Composition, T i It is expressed as: Among them, n iz represents the i-th joint torque n without considering friction and armature inertia i The Z-axis component of ai represents the armature inertia of the i-th joint; ddQZ i represents the coordinate of the angular acceleration of the i-th joint in the joint coordinate system; f vi ,f ci Denote the friction coefficient respectively; dQZ i represents the coordinate of the angular velocity of the i-th joint in the joint coordinate system; sgn represents the sign function.
6. The method for generating a swinging motion gait of a snake-like robot based on reinforcement learning according to claim 5, characterized in that: The multiple groups of excitation trajectories are solved so that the maximum linearly independent matrix W min The excitation trajectory with the smallest condition number is the optimal excitation trajectory. Including: multiple groups of excitation trajectories are composed of 1st to 5th order sine curves and 1st to 5th order cosine curves, sampling at the actual sampling frequency to obtain the joint angle, angular velocity, and angular acceleration, and substituting them into the maximum linearly independent matrix W min , the condition number is optimized and solved using simulation software to obtain the optimal excitation trajectory.
7. The method for generating a swinging motion gait of a snake-like robot based on reinforcement learning according to claim 3, characterized in that: The objective function corresponding to the difference between the actual value and the theoretical value of the swing torque is expressed as: min((ww×P min ′-T″) 2 ); In the formula, min means minimization; ww represents the maximum linear independent matrix corresponding to the actual value of the swing torque; T″ represents the theoretical value of the swing torque composed of multiple joint torques without considering friction and armature inertia; P min ′ represents the minimum parameter set corresponding to the actual value of the swing torque; The constraint condition is set as: joint mass m i The error with the actual weighing does not exceed the preset threshold; the center of mass coordinates of the joint m i1 ,m i2 ,m i3 The main moment of inertia of the joint is not more than the length, width and height of the joint itself; i11 ,I i22 ,I i33 The sum of any two terms is greater than the third term; the sum of the squares of the sine and cosine values of the fixed angles α1, β1, and γ1 in the joint coordinate transformation vector is 1, and the sine and cosine values are between ±1; the armature inertia of the joint I ai , friction coefficient f vi ,f ci Both are greater than 0.
8. The method for generating a swinging motion gait of a snake-like robot based on reinforcement learning according to claim 1, characterized in that: The reinforcement learning strategy includes an expert oscillating motion strategy in a non-delay environment and an expert oscillating motion strategy in a delayed environment, wherein the expert oscillating motion strategy in the non-delay environment corresponds to a first reinforcement learning model, and the expert oscillating motion strategy in the delayed environment corresponds to a second behavior cloning model; Using the optimal joint parameters as the environment for reinforcement learning, the strategy for training to obtain reinforcement learning includes: When sampling, the state-action pair at the current moment is used to obtain the state at the next moment, and the state at the next moment is used as the input of the first reinforcement learning model to generate the action a at the next moment. t+1 At the same time, the state-action pair at the current moment is used as input, and the policy network of the second behavior cloning model is used to generate the action a′ at the next moment t+1 , action a′ t+1 Interact with the environment as the action input for the next moment; repeat the above sampling process to obtain sequence data, form a trajectory, and put the obtained sequence data into the experience replay pool; During the update, N samples are randomly drawn from the experience replay pool and the action a generated by the first reinforcement learning model is t+1 As the teacher network, the second line is the action a′ generated by the policy network of the clone model t+1 As a student network, the loss function is calculated as follows: Then back propagation is performed to calculate the gradient and update the weights of the policy network.
9. The method for generating a swinging motion gait of a snake-like robot based on reinforcement learning according to claim 1, characterized in that: The design rules for the swing torque direction of each joint of the snake-like robot include: In the snake robot swing motion simulation environment, the snake robot is wound around a horizontal bar, and a reference axis l1 parallel to the horizontal bar and a reference axis l2 perpendicular to the ground and upward are established; the reference axis l1 is connected to the joint axis l j The angle between the reference axis l2 and the joint axis l is denoted as α. j The angle is recorded as β, and the jth joint and the joints after it are determined as pitch joints or yaw joints according to the size relationship between α and β; The direction of the pitch joint torque is consistent with the angular velocity of the first joint; When the angular velocity of the first joint is positive and swings to the right, the yaw joint moves to the left; when the angular velocity of the first joint is negative and swings to the left, the yaw joint moves to the right.
10. A snake-like robot swinging motion gait generation system based on reinforcement learning, characterized in that: include: An environmental data acquisition module, which is configured to establish a simulation environment for the swinging motion of a snake-like robot and obtain optimal joint parameters based on the optimal excitation trajectory calculation; wherein the multiple joints of the snake-like robot are arranged orthogonally and alternately, and each joint includes multiple joint parameters; A strategy training module, configured to use the optimal joint parameters as a reinforcement learning environment to train and obtain a reinforcement learning strategy, wherein the strategy is the swing torque of each joint of the snake-like robot; A direction design module configured to design the direction of the swing torque of each joint of the snake-like robot based on energy pumping and collision rules; The gait generation module is configured to generate a swinging motion gait according to the magnitude and direction of the swing torque of each joint of the snake-like robot.
Citation Information
Patent Citations
Snakelike robot control method based on data driving
CN113290557A
Identification method for kinetic parameters of robot
CN114169230A
Method for controlling movement and exploration of snakelike robot in narrow irregular environment
CN117901076A
Modeling a neuronal controller exhibiting human postural sway
US20200305800A1
Neural oscillator-based method and system for controlling rhythmic motion of robot
WO2023184933A1
Cited By
Three-dimensional snakelike structure nonlinear vibration characteristic analysis method and device
CN119358058A
