General mechanical arm inverse kinematics solving method and system based on comparative learning
By constructing a two-stage graph neural network model based on contrastive learning, the problems of dependence on single-configuration robotic arms and high data preparation costs in existing inverse kinematics solution methods are solved, and adaptation and efficient solution for multiple configuration robotic arms are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- UNIV OF SCI & TECH BEIJING
- Filing Date
- 2026-01-12
- Publication Date
- 2026-05-12
AI Technical Summary
Existing inverse kinematics solutions are often designed for single-configuration robotic arms, lack generalization ability, rely on label data of specific robotic arms, have high data preparation costs, are difficult to meet the needs of complex scenarios, and are difficult to generate multiple sets of feasible solutions naturally.
A two-stage graph neural network model based on contrastive learning is constructed, including a query encoder and a momentum key encoder. A training dataset is generated through self-supervised learning, enabling contrastive training without the need for ground truth labels for joint angles. A unified model architecture is constructed to adapt to various robotic arm configurations.
It enables a single model to be adapted to multiple configurations of robotic arms, reduces data preparation costs, meets the needs of multiple feasible solutions in complex scenarios, and improves the versatility and efficiency of the solution.
Smart Images

Figure CN122008192A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of robotic arm kinematics and artificial intelligence, and in particular to a general method and system for solving the inverse kinematics of robotic arms based on contrastive learning. Background Technology
[0002] Inverse kinematics (IK) is a core problem in robotic arm motion planning and control. Its goal is to determine the angles of each joint of the robotic arm based on the target pose of the end effector. With the development of industrial production and intelligent control, robotic arms with different degrees of freedom and different topologies are widely used, which places higher demands on the versatility and adaptability of IK methods. There is an urgent need for an efficient solution that can adapt to various robotic arm configurations.
[0003] In existing technologies, inverse kinematics solutions mainly include analytical methods, numerical methods, intelligent optimization algorithms, and neural network methods. Analytical methods offer high solution accuracy, numerical methods have strong versatility, intelligent optimization algorithms achieve joint angle combination solutions through iterative optimization, and neural networks, with their powerful nonlinear mapping capabilities, have become a mainstream research direction in recent years. By generating paired data through forward kinematics models for training, they provide diverse technical support for the precise control of robotic arms.
[0004] However, existing technologies still have certain limitations. For example, the models are often designed for a single configuration of robotic arm, resulting in insufficient generalization ability. The solution process relies heavily on the label data of specific robotic arms, leading to high data preparation costs. Some methods struggle to naturally generate multiple sets of feasible solutions, making it difficult to meet the needs of complex scenarios. Summary of the Invention
[0005] To address the technical problems that models are often designed for single-configuration robotic arms, have insufficient generalization ability, rely heavily on label data of specific robotic arms for the solution process, have high data preparation costs, and some methods are unable to naturally generate multiple sets of feasible solutions, thus failing to meet the needs of complex scenarios, this invention provides a general robotic arm inverse kinematics solution method and system based on contrastive learning.
[0006] The technical solutions provided by the embodiments of the present invention are as follows: The first aspect of this invention provides a general method for solving the inverse kinematics of a robotic arm based on contrastive learning, comprising: S1: Obtain the structural parameters of the robotic arm; S2: Based on the structural parameters of the robotic arm, construct a geometric representation model of the robotic arm; S3: Construct a training dataset based on the structural parameters of various robotic arm configurations; S4: Based on the features of the geometric graph representation model, a two-stage graph neural network model is constructed, which includes a query encoder, a momentum key encoder, and a conditional graph decoder. S5: Input the training dataset into the momentum bond encoder and query encoder respectively, and perform the first stage of comparative training on the two-stage graph neural network model until the comparative training loss function value is less than the preset comparative training loss function value. S6: Input the training dataset and the output vector of the pre-trained query encoder into the conditional graph decoder, and perform the second stage decoding training on the two-stage graph neural network model until the reconstruction loss function value is less than the preset reconstruction loss function value. S7: Obtain the structural parameters of the target robotic arm; S8: Input the structural parameters of the target robotic arm into the trained two-stage graph neural network model and output the joint angles.
[0007] A second aspect of this invention provides a general inverse kinematics solution system for robotic arms based on contrastive learning, comprising: processor; The memory stores computer-readable instructions that, when executed by the processor, implement the general inverse kinematics solution method for robotic arms based on contrastive learning as described in the first aspect.
[0008] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the general inverse kinematics solution method for a robotic arm based on contrastive learning as described in the first aspect.
[0009] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: In this embodiment of the invention, to address the limitation of insufficient model generalization ability, a training dataset is automatically generated based on the structural parameters of various robotic arm configurations, and a unified two-stage graph neural network model is constructed, enabling a single model to adapt to multiple configurations. To address the issue of relying on specific labeled data, a model architecture including an encoder and decoder is designed, and a first-stage comparative training that does not rely on the ground truth labels of joint angles is performed based on the training dataset, achieving self-supervised learning. To address the limitation of difficulty in generating multiple sets of feasible solutions, after the model training is completed, multiple sets of joint angle solutions can be directly output based on the structural parameters of the new robotic arm configuration, meeting the demand for diverse solutions in complex scenarios. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a flowchart illustrating a general inverse kinematics solution method for a robotic arm based on contrastive learning, provided in an embodiment of the present invention.
[0012] Figure 2 This is a detailed 3D structural diagram of a 7-DOF robotic arm sample from a training model input dataset provided in an embodiment of the present invention.
[0013] Figure 3 This is a graph showing the contrast loss function and reconstruction loss function for model training, provided as an embodiment of the present invention.
[0014] Figure 4 This is a data graph provided for training and testing a single robotic arm, as an embodiment of the present invention.
[0015] Figure 5 This is a universal test diagram for various robotic arms provided as an embodiment of the present invention.
[0016] Figure 6 This is a schematic diagram of a general inverse kinematics solution system for a robotic arm based on contrastive learning, provided in an embodiment of the present invention. Detailed Implementation
[0017] The technical solution of the present invention will now be described with reference to the accompanying drawings.
[0018] In embodiments of the present invention, words such as "exemplarily," "for example," etc., are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" in the present invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present the concept in a concrete manner. Furthermore, in embodiments of the present invention, the meaning expressed by "and / or" can be both, or either one.
[0019] In the embodiments of this invention, the terms "image" and "picture" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning. Similarly, the terms "of," "corresponding (relevant)," and "corresponding" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning.
[0020] In this embodiment of the invention, sometimes a subscript such as W1 may be written in a non-subscript form such as W1. When the difference is not emphasized, the meaning they express is the same.
[0021] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.
[0022] Reference manual attached Figure 1 The diagram shows a flowchart of a general inverse kinematics solution method for a robotic arm based on contrastive learning, provided by an embodiment of the present invention.
[0023] This invention provides a method for solving the inverse kinematics of a general-purpose robotic arm based on contrastive learning. This method can be implemented using a device for solving the inverse kinematics of a general-purpose robotic arm based on contrastive learning, which can be a terminal or a server. The processing flow of this method may include the following steps:
[0024] S1: Obtain the structural parameters of the robotic arm.
[0025] Among them, structural parameters refer to the core attribute data of the robotic arm, such as joint type, range of motion, and link geometry information.
[0026] Optionally, the robotic arm's structural parameters include joint and link information.
[0027] Specifically, the joint and link information includes joint type, joint range of motion, and link geometry.
[0028] S2: Based on the structural parameters of the robotic arm, construct a geometric representation model of the robotic arm.
[0029] Among them, the geometric representation model refers to a standardized data model that abstracts the joints of a robotic arm as nodes and the connection relationships of links as edges.
[0030] In one possible implementation, S2 specifically includes sub-steps S201 to S207: S201: Define the joints of the robotic arm as nodes and the link connections as edges.
[0031] Specifically, the geometric model is denoted as G =( V,E ), node set V Each node in v i A unique joint corresponding to the robotic arm, the edge set E Each edge in e ij Strictly correspond to the parent-child connection relationship of the link.
[0032] For example, the node corresponding to joint 1 (revolute joint) of a 6-DOF robotic arm. v 1. Joint 2 (revolute joint) corresponding node v 2. The corresponding sides of the connecting rods that link the two e 12 The edge features contain information about the DH parameter with a fixed offset of 0.15m.
[0033] S202: Determine the end effector of the robotic arm.
[0034] In this context, "end effector" is a standard term for robotic arms, referring to the tool or gripper installed at the end of the robotic arm.
[0035] Specifically, the end effector is the terminal component of a robotic arm that directly performs tasks, and its type must match the task requirements.
[0036] For example, a pneumatic gripper can be used as the end effector in a handling task, while a welding gun can be used in a welding task. The subsequent target pose data will be developed around the desired state of the component.
[0037] S203: Based on the structural parameters of the robotic arm, obtain the target pose data of the end effector.
[0038] Among them, target pose data refers to the expected position and orientation information of the end effector in three-dimensional space.
[0039] Furthermore, the target pose data is typically expressed as a homogeneous transformation matrix. T ee ∈ SE (3) In terms of form, the matrix contains both position and attitude information.
[0040] For example, if the target position that the end effector needs to reach is (0.5m, 0.3m, 0.8m), and the target orientation is 30° around the X-axis, 45° around the Y-axis, and 60° around the Z-axis, then T ee These spatial states will be quantified using matrix elements.
[0041] S204: The target pose data is transformed into vector form through the Lie algebra mapping algorithm.
[0042] Among them, the Lie algebra mapping algorithm refers to... SE (3) Mathematical operations that linearize a homogeneous transformation matrix in space into a 6-dimensional vector through a logarithmic mapping.
[0043] Specifically, the core of Lie algebraic mappings is the logarithmic mapping operation, with the formula:
[0044] in, τ This represents the end effector target pose vector after transformation by Lie algebra mapping. T ee This indicates the target pose of the robotic arm's end effector. log ( )express SE (3) Standard logarithmic mapping of space R 6 This represents a 6-dimensional real vector space.
[0045] For example, regarding the above T ee The 6-dimensional vector obtained after mapping τ =[0.5,0.3,0.8,0.523,0.785,1.047], where the first 3 dimensions are translation components (unit: m) and the last 3 dimensions are rotation components (unit: rad, converted from angle).
[0046] S205: Broadcast the transformed target pose vector to all nodes.
[0047] Broadcasting refers to the operation of copying the same vector and assigning it to every node in the graph.
[0048] It should be noted that the broadcast operation involves transmitting the 6-dimensional pose vector. τ Copy and assign to each node in the geometry G to ensure that each node can access the global task information.
[0049] For example, if the robotic arm has 6 joint nodes ( v 1 to v 6), then each node will receive synchronously. τ The vector is [0.5, 0.3, 0.8, 0.523, 0.785, 1.047].
[0050] S206: The transformed target pose vector is fused with the inherent feature vectors of each node to form multiple enhanced node features.
[0051] Among them, enhanced node features refer to composite feature vectors that integrate node attributes with global task information.
[0052] Furthermore, feature fusion is achieved through vector concatenation:
[0053] in, Indicates the first i Enhanced feature vectors of each node, h i Indicates the first i The original feature vectors of each node, v i Representing geometric figuresG The first in i 1 node V Representing geometric figures G The set of nodes, This indicates a splicing operation. A universal quantifier.
[0054] S207: Combine nodes, edges, and the features of each enhanced node to construct a geometric representation model of the robotic arm.
[0055] Specifically, the final constructed geometric graph G integrates three types of core information: nodes (joints), edges (linkage relationships and features), and enhanced node features (integrating inherent attributes and global task information).
[0056] For example, a certain geometric graph contains 6 nodes and 5 edges. Each node has 16-dimensional augmented features, and the edges contain information such as connection type and DH fixed offset. This model provides a standardized data format for subsequent multi-configuration dataset generation and general model training.
[0057] It should be noted that the above sub-steps achieve unified encoding of the robotic arm structure and the target task through the logic of "structural abstraction - task data acquisition - vector transformation - feature fusion - model construction". Lie algebra mapping ensures the linearization of pose information, feature fusion enriches node information, and the finally constructed standardized model breaks down the data barriers of heterogeneous robotic arms, laying a solid foundation for subsequent cross-model generalization learning.
[0058] In this embodiment of the invention, this step achieves a unified and standardized representation of the structure of different robotic arms, effectively breaking down the data barriers of heterogeneous robotic arms, providing a consistent data input format for subsequent cross-model generalization learning, enhancing the model's adaptability to diverse configurations, and laying the core foundation for universal solutions.
[0059] S3: Construct a training dataset based on the structural parameters of various robotic arm configurations.
[0060] The training dataset refers to a set of self-supervised learning samples containing geometric data of robotic arms with various configurations.
[0061] In one possible implementation, S3 specifically includes sub-steps S301 to S305: S301: Obtain joint and link information from the structural parameters of various robotic arms.
[0062] Specifically, structural parameters can be automatically parsed from URDF files or DH parameter tables, covering the number and type of joints, range of motion, and link geometry.
[0063] For example, after parsing the URDF file of a 6-10 degree-of-freedom robotic arm, core information such as joint type (revolute or prismatic joint), range of motion, and link geometry can be obtained.
[0064] Reference manual attached Figure 2 The diagram shows a detailed 3D structure of a 7-DOF robotic arm sample from the input dataset of a training model provided by the present invention.
[0065] Specifically, Figure 2 Core parameters include the links and joints of the robotic arm, and the local coordinate system corresponding to the joints (e.g., ...). x 1 / y 1 / z 1. x 3 / y 3 / z 3. x 4 / y 4 / z 4), and geometric model G =( V,E The nodes (dots in the diagram) and edges (lines connecting nodes) in the graph. The node set... V Feature points and edge sets corresponding to the links and joints of the robotic arm E The topological relationships corresponding to these feature points. In terms of inclusion relationships, Figure 2 This integrates the topology of the robotic arm (links and joints), the local coordinate system of the joints, and the geometric graph node-edge elements, corresponding to the geometric graph representation fields of the training dataset. In terms of connectivity, the links and joints of the robotic arm are sequentially connected to form the body structure. The edge associations of the geometric graph correspond to the topological relationships between links and joints. x / y / z Axis identifiers represent local motion constraint parameters, supporting joint angle configuration and forward kinematics calculations.
[0066] It should be noted that, Figure 2 The correspondence between the robotic arm's body structure and its geometric model is clearly presented, verifying the standardized characteristics of the dataset's "unified geometric representation" and providing an intuitive structural reference for the unified encoding and generalization learning of multi-configuration robotic arm data.
[0067] S302: Based on the joint motion range in the joint and link information, joint angle configurations are generated by randomly sampling the joint space formed by the joint motion ranges. The joint space refers to the parameter space jointly defined by the motion ranges of each joint, and each point in the space uniquely corresponds to a set of joint angle configurations for the robotic arm.
[0068] Among them, joint angle configuration refers to a specific set of joint angle values used to define the posture of the robotic arm.
[0069] Furthermore, the random sampling employs a uniform distribution strategy to ensure that the sampling results cover the entire range of motion of the joint.
[0070] For example, given the range of motion constraints of a certain joint, joint angles that meet the conditions are generated through uniform random sampling, ultimately forming a complete set of joint angle configurations.
[0071] S303: Perform forward kinematics calculations on the joint angle configuration to determine the end effector pose and link position.
[0072] Among them, forward kinematics calculation refers to the process of calculating the position and attitude of each link and end effector of the robotic arm based on the joint angles.
[0073] It should be noted that the forward kinematics calculation is achieved through relevant algorithms, which derive the spatial state of the linkage and end effector based on the joint angles.
[0074] For example, by substituting the sampled joint angle configuration into the forward kinematics model, the corresponding end effector pose and the spatial position of all link coordinate systems can be calculated.
[0075] S304: Encodes joint and link information, joint angle configuration, end effector pose, and link position into geometric data objects.
[0076] Among them, geometric graph data objects refer to complete data instances containing structured information such as nodes, edges, features, and masks.
[0077] Specifically, a geometric graph data object is a structured, complete data instance that includes joint coordinates, joint type, fully connected edge index, edge distance attribute, end-target pose, and mask.
[0078] For example, in a data object, the joint type is identified as a revolute joint or a prismatic joint, the edge distance attribute corresponds to the link geometry, and the mask is used to distinguish between anchor points and non-anchor points.
[0079] S305: Construct a training dataset based on geometric data objects.
[0080] Furthermore, the training dataset consists of a large number of geometric data objects of robotic arms with different configurations, requiring no manual annotation.
[0081] For example, the dataset contains samples of robotic arms with various topologies ranging from 6 to 10 degrees of freedom, covering different joint configurations and end-effector poses, providing sufficient samples for self-supervised learning of the model.
[0082] It should be noted that the above sub-steps enable the automatic generation of multi-configuration training data without manual annotation. Random sampling covers the range of joint motion, forward kinematics calculations ensure data authenticity, and the encoding process unifies the data format. The final dataset covers diverse configurations, providing sufficient samples for the model to learn general structural features and reducing data preparation costs.
[0083] In this embodiment of the invention, this step uses multi-configuration robotic arm data coverage to enable the model to learn general structural features. Moreover, the automatic generation process does not require manual labeling of joint angles, completely eliminating the dependence on specific label data, significantly reducing the manpower and time costs of data preparation, and improving the convenience of model training.
[0084] S4: Based on the features of the geometric graph representation model, a two-stage graph neural network model is constructed, which includes a query encoder, a momentum key encoder, and a conditional graph decoder.
[0085] The two-stage graph neural network model refers to a network architecture consisting of an encoder responsible for feature extraction and a decoder responsible for joint coordinate reconstruction. The query encoder extracts query vectors from the partial graph, while the momentum-key encoder extracts key vectors from the complete graph and maintains parameter stability through a momentum mechanism. The conditional graph decoder is a neural network module that reconstructs complete joint coordinates from a partial graph based on latent vectors.
[0086] Specifically, both employ a graph neural network (GNN) structure, with the core function of mapping a geometric graph G into graph-level latent vectors. z ∈ ,in d z The dimension is the implicit vector dimension.
[0087] GNN updates node features through a multilayer perceptron:
[0088] in, Indicates the l+th l In a layered graphical neural network (GNN), the first... i The updated feature vector of each node. l This indicates the number of layers in a graph neural network. i This indicates the node number in the robotic arm's geometry. σ This represents a non-linear activation function, with optional types including ReLU or SiLU. Indicates the first i Summation operation is performed on all neighboring nodes of each node. N ( i ) represents a node i The neighborhood group, jIndicates the sequence number of the neighboring node. c ij Represents the normalization constant. W (l) Indicates the first l The weight matrix of the layer, h j (l) Indicates the first l The first in the layer j The original feature vectors of the neighboring nodes, b (l) Indicates the first l The bias vector of the layer.
[0089] After obtaining the final feature representations of all nodes, the query encoder needs to extract graph-level semantics through global pooling operations, aggregating node-level features into graph-level latent vectors. The mathematical expression for this aggregation process is as follows:
[0090] in, z Represents graph-level latent vectors. GlobalPool This indicates a global pooling operation. Indicates the first i The final feature representation of each node, v i Representing geometric figures G The first in i 1 node V Representing geometric figures G The set of nodes, A universal quantifier.
[0091] Specifically, the conditional graph decoder is also built on GNN, and its input includes the original graph structure information and the latent vector generated by the query encoder. z .
[0092] For example, the decoder receives the latent vector. z By supplementing the coordinates of non-anchor nodes with a partial graph containing only anchor point information through feature transfer and aggregation, a reverse mapping from task to joint configuration is achieved.
[0093] Among them, the two-stage graph neural network model refers to a training architecture consisting of an encoder stage (contrastive learning) and a decoder stage (reconstruction learning).
[0094] It should be noted that the two-stage architecture is divided into a contrastive learning stage and a decoding training stage. The encoder is responsible for extracting the general structure - task representation, and the decoder is responsible for high-precision reconstruction of joint coordinates.
[0095] For example, the model first learns cross-configuration general features by performing comparative training on unlabeled data through the encoder, then freezes the encoder parameters and fine-tunes only the decoder to improve joint prediction accuracy, ensuring the consistency between feature extraction and solution output.
[0096] In this embodiment of the invention, the architecture is deeply adapted to the features of geometric graph data, realizing efficient connection between feature extraction and joint solution output, providing an optimized carrier for subsequent phased training, ensuring the continuity and relevance of the solution process, and improving the overall efficiency of inverse kinematics solution.
[0097] S5: Input the training dataset into the momentum bond encoder and query encoder respectively, and perform the first stage of comparative training on the two-stage graph neural network model until the comparative training loss function value is less than the preset comparative training loss function value.
[0098] Among them, contrastive training refers to the training method of optimizing encoder parameters by comparing the similarity between positive and negative samples.
[0099] In one possible implementation, S5 specifically includes sub-steps S501 to S510: S501: Construct complete and partial geometry graphs based on the training dataset.
[0100] Among them, a complete geometry graph refers to a graph in which all joint coordinates are known, while a partial geometry graph refers to a graph in which only the end-effector coordinates are known, and the coordinates of the remaining joints are masked.
[0101] Specifically, a partial geometry corresponds to the same robotic arm sample as the complete geometry. The partial geometry retains the end effector nodes as anchor nodes, while the spatial coordinates of the remaining joint nodes are occluded. This is used to simulate a scenario in inverse kinematics where only the target end effector pose is known, but the intermediate joint configurations are unknown. During the contrastive training phase, the partial geometry is input as a query view to the query encoder. During the decoding training and inference phases, it serves as a conditional input, working together with the latent vectors output by the query encoder into the conditional graph decoder.
[0102] To precisely define the rules for constructing the node coordinates of the training observation graph, its mathematical expression can be represented as:
[0103] in, Indicating the first observation in the training part of the graph i The coordinates of each node, Represents the first in the complete geometric figure i The actual coordinates of each node v i Representing geometric figures G The first in i 1 node This indicates an optional random perturbation.
[0104] For example, in a complete graph containing the true spatial coordinates of all joints, in the corresponding partial observation graph, only the coordinates of the last anchor node are retained, while the coordinates of the remaining nodes are set to zero or initialized with Gaussian noise.
[0105] S502: Input the complete geometry into the momentum key encoder to generate the key vector.
[0106] Here, the key vector refers to the stable feature representation extracted by the momentum-bond encoder for contrastive learning.
[0107] Specifically, the key vector is a low-dimensional feature representation of the complete graph encoded by the momentum-bond encoder, with the dimension being the same as that of the latent vector. d z Consistent.
[0108] For example, after the complete graph is processed by the encoder, a key vector containing the joint semantics of the complete graph structure and the task is generated.
[0109] S503: Input a portion of the geometry into the query encoder to generate a query vector.
[0110] The query vector refers to the feature representation extracted by the query encoder and used for similarity matching with the key vector.
[0111] For example, after the observation map in the training part is processed by the query encoder to extract features, a query vector is generated. q This vector needs to be matched with the key vector of the corresponding complete graph. k Positive sample pairs are formed for subsequent similarity calculations.
[0112] S504: Determine positive sample pairs based on the key vector and query vector.
[0113] S505: Calculate the sine and cosine similarity of positive sample pairs.
[0114] Specifically, the formulas for sine and cosine similarity are:
[0115] in, Representing vectors u with vector v cosine similarity, u Representing vectors u with vector v dot product, Describing the L2 norm, T This indicates transpose.
[0116] To further strengthen the feature association of positive sample pairs (making the complete and partial representations of the same robotic arm closer in the latent space), the cosine similarity results need to be exponentially transformed to obtain the similarity score of the positive sample pairs. The specific formula is as follows:
[0117] in, l pos This represents the similarity score between positive sample pairs. exp This represents the natural exponential function with base e. Represents the query vector q transpose, q Represents the query vector. k Represents the key vector. a This represents the temperature coefficient.
[0118] S506: Obtain the negative sample queue generated during training, wherein the negative sample queue includes multiple normalized key vectors.
[0119] The negative sample queue refers to key vectors from different samples or historical batches, used for negative constraints in contrastive learning.
[0120] For example, the queue stores key vectors of different samples that do not belong to the same robotic arm sample as the current query vector q, serving as a negative constraint.
[0121] For example, the query vector can be calculated using the cosine similarity formula. q With queue Q Each negative sample key vector k The similarity between - provides a basis for subsequent loss calculation.
[0122] Since the negative samples come from the key vector queue Q (dynamically caching key vectors of multiple sets of different robotic arm samples) of the historical training batches, it is necessary to summarize the similarity scores of all negative samples and the query vector to form the sum of negative sample similarities. The mathematical expression for this summarization process is as follows:
[0123] in, l neg This represents the sum of the similarity scores for negative samples. This indicates that the summation operation is performed on all negative samples in the negative sample queue. Q This represents a queue for storing negative samples. k - Represents the negative sample key vector. Represents the query vector q With negative sample key vector k − The dot product.
[0124] S507: Calculate the negative cosine similarity between the query vector and each normalized key vector.
[0125] S508: Determine the contrastive training loss function in the form of InfoNCE based on sine and cosine similarity:
[0126] in, I InfoNCE Represents the contrast loss in the form of InfoNCE, - log ( ) represents the negative logarithmic function. This indicates an exponential transformation of the similarity between positive samples. This represents the summation of the similarity index transformation results between all negative samples and the query vector.
[0127] Furthermore, the total contrastive loss can be directly defined by the sum of the positive sample similarity scores (lpos) and the negative sample similarity scores (lneg). The simplified calculation expression is as follows:
[0128] in, I contrastive This represents the total comparative loss.
[0129] S509: Based on the contrastive training loss function, update the weights of the momentum key encoder through the momentum synchronization mechanism:
[0130] in, θ k This represents the network parameters of the momentum key encoder. m Indicates the momentum coefficient. θ q This indicates that the updated parameters of the encoder are being queried.
[0131] Among them, the momentum synchronization mechanism refers to the strategy of slowly updating the weights of the momentum encoder through a weighted average method.
[0132] S510: Repeat steps S502 to S509 until the comparison training loss function value is less than the preset comparison training loss function value, and complete the first stage of comparison training.
[0133] It should be noted that the above sub-steps achieve label-free contrast training, construct positive and negative sample pairs from the complete image and partial images, accurately measure feature associations using cosine similarity, enhance general feature learning using the InfoNCE loss function, and ensure training stability using momentum synchronization. Ultimately, this improves the encoder's adaptability to different robotic arm configurations, laying a core foundation for cross-model generalization.
[0134] In this embodiment of the invention, this step does not rely on the true value label of the joint angle. Instead, it mines general features through the geometric consistency of the data itself, which greatly improves the encoder's adaptability to different configurations of robotic arms and lays a solid core foundation for the model's cross-model generalization.
[0135] S6: Input the training dataset and the output vector of the pre-trained query encoder into the conditional graph decoder, and perform the second stage of decoding training on the two-stage graph neural network model until the reconstruction loss function value is less than the preset reconstruction loss function value.
[0136] Among them, decoding training refers to the training process of focusing on optimizing the decoder to improve the accuracy of joint coordinate prediction after freezing the encoder.
[0137] In one possible implementation, S6 specifically includes sub-steps S601 to S605: S601: Freeze all parameters of the query encoder and momentum key encoder.
[0138] Freezing refers to fixing the parameters of certain network layers during training, preventing them from participating in gradient updates.
[0139] Specifically, the freeze operation fixes the encoder's weights, biases, and other parameters so that they do not participate in gradient updates during the decoding training phase, thus preserving the learned cross-configuration general features.
[0140] For example, the GNN layer weights and global pooling layer parameters of the query encoder remain unchanged, while only the parameters of the conditional graph decoder can be optimized.
[0141] S602: Input a portion of the geometry into the pre-trained query encoder to obtain the output vector, where the output vector is specifically the conditional latent vector.
[0142] Among them, the decoding conditional latent vector refers to the implicit feature vector extracted by the encoder as a conditional input during the decoding stage.
[0143] For example, the observation graph in the decoding training part has the same structure as the partial graph in the first stage, only retaining the anchor node information. After inputting the frozen query encoder, it outputs the decoding conditional latent vector containing the global association information between the topology of the robotic arm and the target task.
[0144] S603: Input the conditional latent vector and a portion of the geometry into the conditional graph decoder and output the predicted joint coordinates.
[0145] Among them, the predicted joint coordinates refer to the estimated joint spatial positions output by the decoder.
[0146] Furthermore, the decoder performs feature transfer and aggregation through its internal GNN, completing the coordinates of non-anchor nodes. The mapping formula is as follows:
[0147] in, This represents the predicted joint coordinates output by the conditional graph decoder. D Represents the decoder function. G partial This represents a partial geometry diagram containing only anchor point information. z This represents a graph-level hidden vector.
[0148] S604: Calculate the reconstruction loss function value between the predicted joint coordinates and the corresponding true joint coordinates.
[0149] In one possible implementation, S604 specifically includes sub-steps S6041 to S6043: S6041: Defines the masking functions for anchor joints and non-anchor joints of the end effector in a robotic arm.
[0150] Anchor joints refer to the joints corresponding to the end effector, while non-anchor joints refer to intermediate joints.
[0151] Specifically, the mask function Manchor ( ) marks the anchor point joint as 1, and the rest as 0. Mnon-anchor ( ) marks non-anchor joints as 1, and the rest as 0.
[0152] For example, anchor joints are the joints corresponding to the end effector, and non-anchor joints are intermediate connecting joints, whose positions are accurately identified by two sets of mask functions.
[0153] S6042: Based on the mask function, and combined with the mean square error between the predicted joint coordinates and the actual joint coordinates, anchor point joint errors and non-anchor point joint errors are filtered out.
[0154] For example, the actual joint coordinates are P gt The predicted coordinates are P Through the mask function Manchor ( )and Mnon- anchor ( ) respectively filter out the coordinate deviations of anchor joints and non-anchor joints to realize the regional calculation of error.
[0155] S6043: Weight the anchor joint error and the non-anchor joint error to determine the reconstruction loss function value:
[0156] in, L recon Indicates the weighted reconstruction loss. α This represents the regularization coefficient for anchor point joint errors. Manchor This represents the anchor joint mask function. P gt Represents the true value of the joint coordinates. β This represents the regularization coefficient for non-anchor joint errors. M non-anchor This represents a non-anchor joint mask function.
[0157] The regularization weights are used to adjust the contribution ratio of different joint errors to the total loss.
[0158] It should be noted that the above sub-steps use a mask function to accurately filter different types of joint errors, and regularization weights highlight the accuracy priority of anchor joints. The final calculated weighted reconstruction loss ensures both the accuracy of the end effector pose and the rationality of the intermediate joint configuration, so that the joint configuration output by the decoder meets both the task requirements and the motion is smooth.
[0159] S605: Iteratively update the parameters of the conditional graph decoder until the reconstruction loss function value is less than the preset reconstruction loss function value, and complete the second stage of decoding training.
[0160] Reference manual attached Figure 3 The diagram shows the contrast loss function and reconstruction loss function curves for model training provided by this invention.
[0161] Specifically, Figure 3 The left subplot shows the "Contrastive Learning Loss Curve (0-100 epochs)," with the InfoNCE loss value (range 0-3.5) on the vertical axis and the number of training epochs (0-100 epochs) on the horizontal axis, used to illustrate the loss changes in the first stage of the model (contrastive training stage). The right subplot shows the "Decoder Reconstruction Loss Curve (100-150 epochs)," with the reconstruction loss value (range 0-6) on the vertical axis and the number of training epochs (100-150 epochs) on the horizontal axis, used to illustrate the loss changes in the second stage of the model (decoder fine-tuning stage).
[0162] Furthermore, in terms of inclusion relationships, Figure 3 The overall training loss is integrated into two subgraphs, each corresponding to a different training phase. In terms of connectivity, the end point of 100 training rounds in the left subgraph connects to the starting point of 100 training rounds in the right subgraph, reflecting the two-stage training logic of "pre-training first, then fine-tuning the decoder." In the first stage, the contrastive learning loss continuously decreases (from approximately 3.5 to below 0.5), indicating that the encoder has learned the general structure—the task representation. In the second stage, the reconstruction loss gradually decreases from approximately 5 to below 1, indicating that after freezing the encoder, the decoder can accurately reconstruct the joint coordinates through learning.
[0163] It should be noted that, Figure 3By clearly presenting the two-stage loss reduction trend, the effectiveness and convergence of the model training are intuitively verified: the decrease in contrastive learning loss proves the effectiveness of general representation learning, and the decrease in reconstruction loss proves that the joint reconstruction accuracy is gradually improved, providing support at the training process level for the high accuracy and robustness of subsequent cross-aircraft inverse kinematics solutions.
[0164] It should be noted that the above sub-steps achieve decoupled training of general features and accurate decoding, freeze the encoder to retain the learned generalization ability, use latent vectors and partial graphs as joint input to ensure the specificity of decoding, use weighted reconstruction loss to focus on core errors, and use backpropagation to efficiently optimize the decoder. Finally, without losing generalization, the prediction accuracy of joint angle solutions is greatly improved.
[0165] In this embodiment of the invention, this step decouples general feature learning from precise decoding optimization, preserving the encoder's cross-model generalization capability while specifically improving the joint angle prediction accuracy of the decoder, perfectly balancing the versatility of the solution and the accuracy of the solution.
[0166] S7: Obtain the structural parameters of the target robotic arm.
[0167] The target robotic arm refers to a type of robotic arm that has not appeared in the training dataset.
[0168] In this embodiment of the invention, this step continues the simplified data input logic of the previous step. Only the core structural parameters of the new configuration robotic arm need to be obtained to start the solution process. No additional model adaptation or data format conversion is required, which facilitates rapid deployment across different models and reduces the application threshold of heterogeneous robotic arm systems.
[0169] S8: Input the structural parameters of the target robotic arm into the trained two-stage graph neural network model and output the joint angles.
[0170] Among them, joint angle refers to the configuration of the joint angles of the robotic arm to meet the pose requirements of the end-effector target.
[0171] In one possible implementation, S8 specifically includes sub-steps S801 to S806: S801: Construct the geometry of the target part based on the structural parameters of the target robotic arm and the target pose data of the corresponding end effector.
[0172] Among them, the target part geometry refers to the geometry constructed for the target robotic arm that only contains end-effector information.
[0173] S802: Input the target partial geometry into the trained query encoder and output the target conditional latent vector.
[0174] Among them, the target condition latent vector refers to the latent vector extracted by the encoder during the inference phase.
[0175] For example, after the target geometry is extracted by the encoder, an inference condition latent vector containing the target structural features and target task information is generated.
[0176] S803: Based on a preset scale parameter, the target conditional latent vector is subjected to multiple random perturbations to generate multiple differentiated conditional latent vectors.
[0177] in, z (i) Indicates the first i A differentiated graph-level latent vector after random perturbation z (0) This represents the initial graph-level latent vector. σ 2 This represents the variance of the Gaussian distribution. I Represents the identity matrix. i The index indicates the number of perturbations. N This indicates the preset number of sampling times.
[0178] Random perturbation refers to the operation of adding Gaussian noise to the latent vector to generate diverse solutions.
[0179] It should be noted that those skilled in the art can set the size of the preset scale parameters according to actual needs, and this invention does not limit this.
[0180] It should be noted that those skilled in the art can set the preset number of sampling times according to actual needs, and this invention does not limit this.
[0181] S804: Pair the target geometry with each differential conditional latent vector to obtain multiple sets of decoding input pairs.
[0182] S805: Input each decoding input pair into the trained conditional graph decoder in sequence to obtain multiple joint coordinate prediction results.
[0183] The joint coordinate prediction result refers to the joint position estimate output by the decoder.
[0184] Furthermore, each differential latent vector is input into the decoder along with a partial graph, and a set of joint coordinate prediction results are output.
[0185] S806: Convert all joint coordinate prediction results into physically feasible joint angles and output the joint angles.
[0186] Among them, physically feasible joint angles refer to joint angle combinations that satisfy practical constraints such as joint range of motion and no self-collision.
[0187] Reference manual attached Figure 4 The diagram illustrates a data graph provided by the present invention for training and testing a single robotic arm.
[0188] Specifically, Figure 4 The core parameters involved include the type of robotic arm (UR5, KUKA, Panda), as well as positional errors (average error, minimum error, maximum error, unit: mm) and rotational errors (average error, minimum error, maximum error, unit: degrees). Specifically, the UR5 has positional errors of 19.7 mm (average), 12.5 mm (minimum), and 22.3 mm (maximum), and rotational errors of 2.9° (average), 1.3° (minimum), and 4.8° (maximum). The KUKA has corresponding errors of 11.4 mm, 7.5 mm, and 16.8 mm, and 2.3°, 0.9°, and 3.6°. The Panda has corresponding errors of 6.3 mm, 1.1 mm, and 13.2 mm, and 1.8°, 0.7°, and 3.2°.
[0189] Furthermore, in terms of inclusion relationships, Figure 4 The system integrates training and testing data from three individual robotic arms, covering multi-dimensional evaluation metrics for position and rotation errors. In terms of connectivity, each robotic arm type is directly correlated with its corresponding average, minimum, and maximum error metrics, clearly demonstrating the solution accuracy of a single robotic arm under this method. The error metrics complement each other, comprehensively reflecting the testing performance of individual models.
[0190] It should be noted that, Figure 4 By accurately presenting the error data for three individual robotic arms, the method effectively verifies its high precision and stability on a single robotic arm model. The data shows that all robotic arms maintain low position and rotation errors, with the Panda robotic arm exhibiting the best error performance. This confirms that the method can achieve accurate solutions without requiring customized training for a single robotic arm model, providing solid data support at the single-arm model level for its core advantage of "one-time training, applicable to multiple robotic arms," highlighting the method's reliability in practical applications.
[0191] Reference manual attached Figure 5 The diagram illustrates a universality test pattern for various robotic arms provided by the present invention.
[0192] Specifically, Figure 5 The data includes two sub-figures: a comparison of positional errors (in meters) and a comparison of rotational errors (in rad) for each robotic arm. The core parameters involved are positional error and rotational error. The comparison objects are three different robotic arms: Franka EmikaPanda, KUKA LBR iiwa7, and UR5. These two parameters are used to quantify the positional matching accuracy and rotational matching accuracy of the robotic arm's end effector, respectively.
[0193] Furthermore, in terms of inclusion relationships, Figure 5 The overall system integrates two performance evaluation subplots, each containing the identification of the robot arm type and the corresponding error distribution (including error bars). In terms of connectivity, each subplot uses the robot arm type as the x-axis and the corresponding error parameter as the y-axis, horizontally comparing the same error parameter across the three robot arm configurations. This clearly presents the accuracy differences between different robot arm configurations under the same solution method. Furthermore, the two subplots form a complementary relationship in terms of position and rotation accuracy, intuitively reflecting the method's versatility.
[0194] It should be noted that, Figure 5 By showcasing the position and rotation error data of three robotic arms with different configurations, the cross-model versatility and stability of the proposed method are strongly verified: all three robotic arms maintain low position and rotation errors, and there are no significant fluctuations in accuracy due to configuration differences. This result directly confirms the core advantage of the method, "one-time training, applicable to multiple machines," breaking through the dependence of traditional methods on specific robotic arms. It provides solid performance data support for the rapid deployment and intelligent control of heterogeneous robotic arm systems, and also highlights the potential for large-scale application of the method in industrial scenarios.
[0195] It should be noted that coordinate transformation is achieved by inversely solving for joint angles, ensuring that the results meet constraints such as joint range of motion and no self-collision.
[0196] For example, N The predicted joint coordinates are converted into physically feasible joint angle configurations, and multiple joint angle solutions that meet the pose requirements of the end-effector are output, adapting to complex scenario requirements.
[0197] It should be noted that the above sub-steps realize multi-solution across configurations, adapt the observation map of the new configuration to the model input format, generate diverse feature vectors through random perturbation, output multiple sets of prediction results by the decoder, and finally convert the physical feasible joint angle solution to meet the trajectory planning and obstacle avoidance requirements of complex scenarios, achieve the core goal of "one-time training, multi-machine application", and improve application flexibility.
[0198] In this embodiment of the invention, this step relies on the results of previous training to achieve the core objective of "one-time training, applicable to multiple machines", quickly outputting multiple sets of physically feasible joint angle solutions, specifically meeting the trajectory planning and obstacle avoidance needs in complex scenarios, and improving the application flexibility and practicality of the solution.
[0199] Reference manual attached Figure 6 The diagram shows a schematic of the structure of a general inverse kinematics solution system for a robotic arm based on contrastive learning provided by the present invention.
[0200] This invention also provides a general robotic arm inverse kinematics solution system 20 based on contrastive learning, applied to the aforementioned general robotic arm inverse kinematics solution method based on contrastive learning, comprising: Processor 201.
[0201] The memory 202 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 201, they implement the general inverse kinematics solution method for robotic arms based on contrastive learning, as described in the method embodiment.
[0202] The inverse kinematics solution system 20 for a general robotic arm based on contrastive learning provided by this invention can execute the inverse kinematics solution method for a general robotic arm based on contrastive learning described above and achieve the same or similar technical effects. To avoid repetition, this invention will not elaborate further.
[0203] It should be understood that the processor in the embodiments of the present invention can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0204] It should also be understood that the memory in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0205] The above embodiments can be implemented, in whole or in part, by software, hardware (such as circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.
[0206] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. A and B can be singular or plural. Additionally, the character " / " in this article generally indicates an "or" relationship between the preceding and following related objects, but it can also represent an "and / or" relationship. Please refer to the context for a more accurate understanding.
[0207] In this invention, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or a plurality of items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be a single item or multiple items.
[0208] It should be understood that, in various embodiments of the present invention, the order of the above-mentioned process numbers does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0209] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0210] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0211] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0212] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0213] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0214] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0215] This invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the general inverse kinematics solution method for a robotic arm based on contrastive learning as described in the method embodiment.
[0216] The present invention provides a computer-readable storage medium that can implement the steps and effects of the general inverse kinematics solution method for robotic arms based on contrastive learning in the above-described method embodiments. To avoid repetition, the present invention will not elaborate further.
[0217] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
[0218] The following points need to be explained: (1) The accompanying drawings of the embodiments of the present invention only involve the structures involved in the embodiments of the present invention. Other structures can refer to the general design.
[0219] (2) For clarity, the thickness of layers or regions is enlarged or reduced in the drawings used to describe embodiments of the invention, i.e., these drawings are not drawn to scale. It is understood that when an element such as a layer, film, region or substrate is referred to as being “above” or “below” another element, the element may be “directly” located “above” or “below” the other element or there may be intermediate elements.
[0220] (3) Where there is no conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other to obtain new embodiments.
[0221] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. The scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A general method for solving the inverse kinematics of a robotic arm based on contrastive learning, characterized in that, include: S1: Obtain the structural parameters of the robotic arm; S2: Based on the structural parameters of the robotic arm, construct a geometric representation model of the robotic arm; S3: Construct a training dataset based on the structural parameters of various robotic arm configurations; S4: Based on the features of the geometric graph representation model, a two-stage graph neural network model is constructed, wherein the two-stage graph neural network model includes a query encoder, a momentum key encoder, and a conditional graph decoder. S5: Input the training dataset into the momentum bond encoder and the query encoder respectively, and perform the first stage of comparative training on the two-stage graph neural network model until the comparative training loss function value is less than the preset comparative training loss function value; S6: Input the training dataset and the output vector of the pre-trained query encoder into the conditional graph decoder, and perform the second stage decoding training on the two-stage graph neural network model until the reconstruction loss function value is less than the preset reconstruction loss function value; S7: Obtain the structural parameters of the target robotic arm; S8: Input the structural parameters of the target robotic arm into the trained two-stage graph neural network model and output the joint angles.
2. The method for solving the inverse kinematics of a general robotic arm based on contrastive learning according to claim 1, characterized in that, The structural parameters of the robotic arm include joint and link information; Specifically, the information about the joints and links includes the joint type, the range of motion of the joints, and the geometric information of the links.
3. The method for solving the inverse kinematics of a general robotic arm based on contrastive learning according to claim 1, characterized in that, S2 specifically includes: S201: Define the joints of the robotic arm as nodes and the link connections as edges; S202: Determine the end effector of the robotic arm; S203: Based on the structural parameters of the robotic arm, obtain the target pose data of the end effector; S204: Convert the target pose data into vector form using the Lie algebra mapping algorithm; S205: Broadcast the transformed target pose vector to all nodes; S206: The transformed target pose vector is fused with the inherent feature vectors of each node to form multiple enhanced node features; S207: Combining the nodes, the edges, and the features of each of the enhanced nodes, construct a geometric representation model of the robotic arm.
4. The method for solving the inverse kinematics of a general robotic arm based on contrastive learning according to claim 1, characterized in that, S3 specifically includes: S301: Obtain joint and link information from the structural parameters of various configuration robotic arms; S302: Based on the joint motion range in the joint and link information, generate joint angle configuration by randomly sampling the joint space formed by the joint motion range; S303: Perform positive kinematic calculations on the joint angle configuration to determine the end effector pose and link position; S304: Encode the joint, the link information, the joint angle configuration, the end effector pose, and the link position into a geometric data object; S305: Construct the training dataset based on the geometric data object.
5. The method for solving the inverse kinematics of a general robotic arm based on contrastive learning according to claim 1, characterized in that, S5 specifically includes: S501: Based on the training dataset, construct the complete geometry and partial geometry; S502: Input the complete geometry into the momentum key encoder to generate a key vector; S503: Input the partial geometry into the query encoder to generate a query vector; S504: Determine positive sample pairs based on the key vector and the query vector; S505: Calculate the sine and cosine similarity of the positive sample pairs; S506: Obtain the negative sample queue generated during the training process, wherein the negative sample queue includes multiple normalized key vectors; S507: Calculate the negative cosine similarity between the query vector and each of the normalized key vectors respectively; S508: Based on the sine and cosine similarities, determine the contrastive training loss function in the form of InfoNCE; S509: Based on the contrastive training loss function, update the weights of the momentum key encoder through the momentum synchronization mechanism; S510: Repeat steps S502 to S509 until the contrastive training loss function value is less than the preset contrastive training loss function value, and complete the first stage of contrastive training.
6. The method for solving the inverse kinematics of a general robotic arm based on contrastive learning according to claim 1, characterized in that, S6 specifically includes: S601: Freeze all parameters of the query encoder and the momentum key encoder; S602: Input the partial geometry into the pre-trained query encoder to obtain an output vector, wherein the output vector is specifically a conditional latent vector; S603: Input the conditional latent vector and the partial geometry into the conditional graph decoder, and output the predicted joint coordinates; S604: Calculate the reconstruction loss function value between the predicted joint coordinates and the corresponding true joint coordinates; S605: Iteratively update the parameters of the conditional graph decoder until the reconstruction loss function value is less than the preset reconstruction loss function value, and complete the second stage of decoding training.
7. The method for solving the inverse kinematics of a general robotic arm based on contrastive learning according to claim 6, characterized in that, Specifically, S604 includes: S6041: Define the mask functions for the anchor joints and non-anchor joints of the end effector in the robotic arm; S6042: Based on the mask function, and combined with the mean square error between the predicted joint coordinates and the actual joint coordinates, filter out anchor joint errors and non-anchor joint errors. S6043: Weight the anchor joint error and the non-anchor joint error to determine the reconstruction loss function value.
8. The method for solving the inverse kinematics of a general robotic arm based on contrastive learning according to claim 1, characterized in that, S8 specifically includes: S801: Construct a geometric diagram of the target part based on the structural parameters of the target robotic arm and the target pose data of the corresponding end effector; S802: Input the target partial geometry into the trained query encoder and output the target conditional latent vector; S803: Based on a preset scale parameter, the target conditional latent vector is subjected to multiple random perturbations to generate multiple differentiated conditional latent vectors. S804: Pair the target part geometry with each of the differential conditional latent vectors to obtain multiple sets of decoding input pairs; S805: Input each of the aforementioned decoding input pairs into the trained conditional graph decoder in sequence to obtain multiple joint coordinate prediction results; S806: Convert all joint coordinate prediction results into physically feasible joint angles and output the joint angles.
9. A general inverse kinematics solution system for robotic arms based on contrastive learning, characterized in that, include: processor; A memory storing computer-readable instructions, which, when executed by the processor, implement the general inverse kinematics solution method for a robotic arm based on contrastive learning as described in any one of claims 1 to 8.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the general inverse kinematics solution method for a robotic arm based on contrastive learning as described in any one of claims 1 to 8.